将一个二维寄存器数组转储到文本文件中

huangapple go评论55阅读模式
英文:

Dumping a 2D register array into a text file

问题

当我使用以下代码:

$writememb(dump_location, "array_name");

生成的文件被创建了,但保持为空。

英文:

I'm trying to dump a 2D array into a text file with dimension [100] width [200] height with each value stored being a 2-bit binary value.
Declared like this:

logic [1:0] array_name [99:0][199:0];

When I use:

$writememb(dump_location, "array_name");

the resulting file is created, but it remains empty.

答案1

得分: 1

当我运行你的代码时,我收到一个错误消息,指向了问题:

错误-[STASKEC_IAFMEMT2] 内存任务的非法参数
tb.sv, 4
tb, "array_name"
  $writememb的第二个参数必须是一个内存。给定的参数是
  "array_name"。
  请修正系统任务调用并重新编译。

你需要删除内存名称周围的引号(array_name):

module tb;
    logic [1:0] array_name [99:0][199:0];
    string dump_location = "file.txt";
    initial $writememb(dump_location, array_name);
endmodule

这会创建一个名为file.txt的文件,其中包含了array_name的内容(全部是x)。

请参阅IEEE Std 1800-2017,第21.5节《将内存数组数据写入文件》。

英文:

When I run your code, I get an error message which points to the problem:

Error-[STASKEC_IAFMEMT2] Illegal argument to memory task
tb.sv, 4
tb, "array_name"
  Argument no. 2 to $writememb must be a memory. Argument given is 
  "array_name".
  Please correct the system task call and recompile.

You need to delete the quotes around the memory name (array_name):

module tb;
    logic [1:0] array_name [99:0][199:0];
    string dump_location = "file.txt";
    initial $writememb(dump_location, array_name);
endmodule

This creates the file named file.txt with the contents of array_name (all x's).

Refer to IEEE Std 1800-2017, section 21.5 Writing memory array data to a file.

huangapple
  • 本文由 发表于 2023年4月4日 16:01:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75926901.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定