【发布时间】:2019-03-07 22:16:53
【问题描述】:
首先我想说的是,我正在通过在 ModelSim 中编译的 Verilog 模型在 ADS(Advanced Design System 2017)中运行仿真。
我的目标是将 .txt 文件中的数据作为输入加载到测试台中,以便运行模拟,然后将此模拟的结果保存在另一个 .txt 文件中。
以下是名为“param.txt”的输入测试 .txt 文件的内容:
1
2
3
4
5
这是我的 Verilog 测试平台代码:
`include "disciplines.vams"
module resistor(p,n);
electrical p,n;
parameter real R=50.0;
integer file;
integer out;
real pwm_A[0:10];
integer i;
integer count;
analog begin
@(initial_step) // Initial Conditions
begin
////////////// Read
file=$fopen("param.txt","r");
if (file) $display("File was opened successfully : %0d", file);
else $display("File was NOT opened successfully : %0d", file);
for (i=1; i<=5; i=i+1) begin
count = $fscanf(file,"%d",pwm_A[i]);
end
////////////// Write
out=$fopen("out.txt","w");
for (i=1; i<=5; i=i+1) begin
$fwrite(out,"%d\n",pwm_A[i]);
end
$fclose(file);
$fclose(out);
end
// Simulation (doesnt matter)
V(p,n) <+ R * I(p,n);
end
endmodule
模拟抛出此错误:
Error: Incorrect target supplied to integer-valued $fscanf field.
谁能发现问题?
提前致谢。
【问题讨论】:
-
不是重复的,只是另一个问题!
-
嗨 davmc!是的,但是您的源代码仍然包含与上一个问题相同的问题,其中 Matthew 建议将
pwm_A[i]=$fscanf(file,"%d",j);更改为count = $fscanf(file,"%d",pwm_A[i]);。 -
您将
pwm_A声明为real。您是否尝试将其声明为integer?根据您提供的错误消息,这可能是问题所在。如果您确实需要加载实数而不是整数,您可能需要更改%d说明符。有关几个 C 说明符,请参见 this reference。 -
C 和 Verilog-AMS 格式的输入和输出之间存在差异。选择 Verilog-AMS 标准accellera.org/images/downloads/standards/v-ams/VAMS-LRM-2-4.pdf。