Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在verilog或systemverilog中,每个时钟从文件中读取行_Verilog_Simulation_System Verilog - Fatal编程技术网

在verilog或systemverilog中,每个时钟从文件中读取行

在verilog或systemverilog中,每个时钟从文件中读取行,verilog,simulation,system-verilog,Verilog,Simulation,System Verilog,我想测试一个模块,它接受每个时钟周期文件中的数字,并且所需的数据太长。我无法将完整的文件存储在内存中,因此我需要在文件的每个时钟周期将数据馈送到I_数据 有什么方法可以用verilog或systemverilog来实现吗 简而言之:在每个时钟的边缘读一行,一直读到文件的末尾 你的问题的答案是肯定的:是的 使用$fopen打开文件,然后$fscanf读取每一行并将值存储到变量中 有许多示例正如Dave建议的那样,您可以使用fopen和fscanf来实现此目的。示例代码如下所示: integer o

我想测试一个模块,它接受每个时钟周期文件中的数字,并且所需的数据太长。我无法将完整的文件存储在内存中,因此我需要在文件的每个时钟周期将数据馈送到I_数据

有什么方法可以用verilog或systemverilog来实现吗


简而言之:在每个时钟的边缘读一行,一直读到文件的末尾

你的问题的答案是肯定的:是的

使用
$fopen
打开文件,然后
$fscanf
读取每一行并将值存储到变量中


有许多示例

正如Dave建议的那样,您可以使用fopen和fscanf来实现此目的。示例代码如下所示:

integer outfile0; //file descriptor

initial begin

    outfile0=$fopen("file_to_be_read.txt","r");   //"r" means reading and "w" means writing
    //read line by line.
    while (! $feof(outfile0)) begin //read until an "end of file" is reached.
        $fscanf(outfile0,"%h\n",A); //scan each line and get the value as an hexadecimal, use %b for binary and %d for decimal.
        #10; //wait some time as needed.
    end 
    //once reading and writing is finished, close the file.
    $fclose(outfile0);
end

更多解释和详细代码可用。

文件有多大,需要读取多少元素?我尝试使用$readmemh,有点凌乱,我跳过了它。谢谢你们的帮助:)我用以下代码完成了:整数I,j,fd,rv;初始开始fd=$fopen(“/home/haider/workspace/c/gen_file_1280x960.file”,“r”);对于(i=0;i<960;i=i+1)对于(j=0;j<1280;j=j+1)rv=$fscanf(fd,“%h”,mem[i][j]);结束