如果这个系统Verilog或只是Synopsis专有的东西?
在任何情况下,将文本值写入文件的常用方法是使用$ fwrite。
您在初始块中打开文件,然后您可以根据需要随时写入(附加数据)。
它非常像$ write,或者如果你对C更熟悉,那就像fprintf。
另请注意,您可以选择打开“附加”的现有文件,这意味着您可以继续在多个模拟运行中附加数据(不确定是否需要...)
例:
整数i,dumpfile;
参数RAMSIZE = 2048;
initial dumpfile = $ fopen(“dump_file.hex”,“w”);
//将“w”更改为“a”以将数据附加到现有文件
。
。
。
for(i = 0; i 以下为原文
$writememb is not in my Verilog book. If this System Verilog or just something proprietary to Synopsis?
In any case the usual way to write text values to a file is to use $fwrite. You open the file in an initial block, and then you can write to it (which appends data) as often as you need. It works very much like $write, or if you are more familiar with C, then it's like fprintf. Also note that you have the option to open an existing file for "append" which means you can continue to append data on multiple simulation runs (not sure if you want that...)
Example:
integer i, dumpfile;
parameter RAMSIZE = 2048;
initial dumpfile = $fopen ("dump_file.hex","w"); // Change the "w" to "a" to append data to an existing file
. . .
for (i = 0;i < RAMSIZE;i = i + 1)
if ((i & 'hF) == 'hF) $fwrite (dumpfile,"%bn",uut.memoryinst); // New line after every 16 words
else $fwrite ("%b ",uut.memoryinst);
. . .
You could make a task to do the memory write loop, if you use it an many places.
-- GaborView solution in original post