I need to verify my hardware design in an automatic way. What I was used to do with VHDL was to:
Create .txt file with random data, more than 200k (in Python).
Through VHDL testbench acquire data, put them as the input of my hardware design, then collect results.
Compare results with those produced by a model written in C/C++/Python etc.
Everything is done by a script, launched in the terminal.
I'd like to do the same thing in system Verilog, but I'm getting some troubles.
A typical line of the input data file (out of 200k) is: 1 00000000000000000000000001110101 00000000000000000000000000001010
This is my code:
initial begin
fin_pointer= $fopen("../common/divisorInSample.txt","r");
fout_pointer= $fopen("../common/divisorHWResults.txt","w");
@(posedge rst_n);
@(posedge clk);
while (! $feof(fin_pointer)) begin
$fscanf(fin_pointer,"%b %b %b\n",usigned,dividend,divisor);
valid=1;
@(posedge clk);
valid=0;
@(posedge res_ready);
$fwrite(fout_pointer,"%b %b\n",quotient,reminder);
end
$finish;
$fclose(fin_pointer);
$fclose(fout_pointer);
end
I tried different formats in the fscanf like "%b%b%b". But I'm always getting the same behavior: Code seems to stop after the first execution of "fwrite", because I can see the right results in the output file. How can I solve this problem? Thanks