FPGA 關於錯誤(10200)

本人在調試FPGA時有時會出現以下錯誤:

Error (10200): Verilog HDL Conditional Statement error at delay.v(23): cannot match operand(s) in the condition to the corresponding edges in the enclosing event control of the always construct

問題原因在於筆者用了以下語句
always@(posedge clk or negedge rst_n)
卻粗心的忘了對rst_n進行判斷了寫成如下語句了

always@(posedge clk or negedge rst_n)
begin 
 if(txd_flag)
    if(state < 4'd9)
           state<=state+1;
    else
          state<=0;
 else 
            state<=state;
end

而正確的應該是

always@(posedge clk or negedge rst_n)
begin 
 if(!rst_n)
        begin
            state<=0;
        end
 else if(txd_flag)
    if(state < 4'd9)
           state<=state+1;
    else
          state<=0;
 else 
            state<=state;
end
發佈了46 篇原創文章 · 獲贊 141 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章