First of all I want to say that I'm running the simulation in ADS (Advanced Design System 2017) through a Verilog model compiled in ModelSim.
My objective is loading data from a .txt file into the testbench as input in order to run the simulation, and afterwards save the results of this simulation in another .txt file.
Here is the content for the input test .txt file called "param.txt":
1
2
3
4
5
And here is my Verilog testbench code:
`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
The simulation throws this error:
Error: Incorrect target supplied to integer-valued $fscanf field.
May anyone spot the problem?
Thanks in advance.
pwm_A[i]=$fscanf(file,"%d",j);
tocount = $fscanf(file,"%d",pwm_A[i]);
. – Silicon1602pwm_A
as areal
. Did you try to declare it as aninteger
? Based on the error message you provided, this could be the problem. If you actually need to load real numbers instead of integers, you might want to change the%d
specifier. See this reference on the several C specifiers. – Silicon1602