我期待在verilog HDL中實現32位並行並行輸出。這是我寫的代碼...在verilog中實現PIPO
module pipo(input_seq, answer,reset, clock);
input [31:0] input_seq;
input reset,clock;
output [31:0] answer;
always @ (reset)
begin
if(!reset)
begin
answer[31:0]<=1'b0;
end
end
always @ (posedge clock)
begin
answer[31:1]<=input_seq[30:0];
end
endmodule
然而,這會導致下面的錯誤日誌(使用iverilog
):
pipo.v:10: error: answer['sd31:'sd0] is not a valid l-value in pipo.
pipo.v:4: : answer['sd31:'sd0] is declared here as wire.
pipo.v:16: error: answer['sd31:'sd1] is not a valid l-value in pipo.
pipo.v:4: : answer['sd31:'sd1] is declared here as wire.
Elaboration failed
究竟是什麼問題?
您不應該將寄存器的復位邏輯和寄存器的時鐘邏輯拆分爲不同的塊。你應該有一個塊'always @(posedge clock或negedge reset)'。在您的設計中,如果時鐘在置位復位時切換,那麼時鐘模塊仍將被執行,這不是模擬觸發器的正確方法。 – Tim