I'm trying to write a testbench that will output all the values read and evaluated from a file into a text file. But I can only get a 1 line in the output file instead of the 32 lines. Can someone shed some light?
`timescale 100ns/1ps
module multtest;
reg clk,reset;
reg signed [7:0] a, b;
reg signed [15:0] result,res;
integer fread, fw;
reg [7:0] in_a, in_b;
reg [47:0] in_r;
wire signed[15:0] result1;
mult mult_0 (.clk(clk) , .reset(reset), .A(a), .B(b), .result(result1));
initial
begin
fread = $fopen ("goldenresult","r");
fw = $fopen ("goldresult.txt","w");
clk = 1'b0;
reset = 1'b1;
#200;
reset = 1'b0;
#200;
reset = 1'b1;
end
always
#2.5 clk = ~clk;
//conditon for reset
always @ (reset == 1'b1)
begin
a <= 0;
b <= 0;
result <= 0;
end
always @(posedge clk)
begin
//Verifying the result when testmode = 0 and reset = 0
if (reset == 1'b0)
begin
while ($fscanf(fread, "%s = %b, %s = %b, %s = %b", in_a, a, in_b, b, in_r, result) != 6) begin end
$display ("a = %b, b = %b, result = %b", a, b, result);
end
end
/*always @(posedge clk)
@(negedge reset)
if (reset == 1'b0)
begin
while ($fscanf(fread, "%s = %b, %s = %b, %s = %b", in_a, a, in_b, b, in_r, result) != 6) begin end
$fwrite(fw, "%s = %b, %s = %b, %s = %b", in_a, a, in_b, b, in_r, res);
end*/
endmodule
I've commented out the portion of the code that was supposed to write. Am i doing anything wrong. The output is in this format:
a = 10111010, b = 00111011, result = 0000000000000000
Its supposed to write all 32 lines but instead writes only 1. Although it correctly displays the output in modelsim.