英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论