我正在嘗試編寫一個測試臺,它將從文件讀取和評估的所有值輸出到文本文件中。但我只能在輸出文件中獲得1行而不是32行。有人可以點亮一些光線嗎?無法在verilog中輸出文件中輸出所有32行輸出
`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
我已經註釋了應該寫的代碼部分。我做錯了什麼?輸出是以下格式:
α= 10111010,B = 00111011,結果= 0000000000000000
及其應該寫所有32條線,但雖然正確顯示在用modelsim輸出代替僅1.寫入。
法蘭德不工作,而且fclose似乎不工作。只有當我關閉modelsim時,才能將輸出寫入.txt文件。此外,輸出不是逐行顯示,而是顯示在同一行上。我如何使它出現在不同的線路上? – JUBER
請添加所有模塊的完整代碼,我可以模擬它 – Roman