Verilog Loop Condition

后端 未结 3 1993
礼貌的吻别
礼貌的吻别 2021-01-22 12:38

I am completely new to verilog and I have to know quite a bit of it fairly soon for a course I am taking in university. So I am play around with my altera DE2 board and quartis2

3条回答
  •  深忆病人
    2021-01-22 12:48

    I don't think you want to use a while loop there. How about:

       always@ (posedge CLOCK_50 or negedge reset_n) begin
               if(!reset_n)
                   count <= 0;
               else if (enable)
                   count <= count + 1;
        end
    

    I also added non-blocking assignments <=, which are more appropriate for synchronous logic.

提交回复
热议问题