1
使用ModelSim。試圖模擬一個上下兩位計數器。編譯罰款,但是當我嘗試運行模擬我得到以下錯誤:Verilog - 錯誤:模擬時出現「Unresolved reference」
** Error: (vsim-3043) D:/ModelSim/examples/Lab7.v(46): Unresolved reference to 'state'.
模塊是:
module TwoBitCounter(input Dir, clock, reset);
reg[1:0] state;
parameter S0 = 2'b00, S1=2'b01, S2=2'b10, S3 = 2'b11;
always @(posedge clock or negedge reset)
if (reset == 0) state<=S0;
else case(state)
S0: if(Dir) state = S1; else state = S3;
S1: if(Dir) state = S2; else state = S0;
S2: if(Dir) state = S3; else state = S1;
S3: if(Dir) state = S0; else state = S2;
endcase
endmodule
測試平臺:
module Counter_TB;
reg Dir, clock, reset;
TwoBitCounter DA0(.Dir(Dir), .clock(clock), .reset(reset));
initial begin
reset = 0;
Dir = 1;
#5 reset = 1;
forever #205 Dir = ~Dir;
end
initial begin
clock = 0;
forever #25 clock = ~clock;
end
initial #800 $stop;
initial $monitor ("State AB: %b", state);
endmodule
我GOOGLE了,但我發現當在always塊中使用這個東西時會出現這個錯誤,但是我並沒有在always塊中使用它。
謝謝!
'S0:state <=(Dir)? :S1:S3;'等 – toolic