关于always块内for循环的执行方式

//该模块主要用来说明for结构在时序逻辑中的执行方式
module for_test(input clk_1,nrst,output now_nine,nrst_pos,output reg[9:1] eq_dly
    );
    integer i;
    parameter eq=1'b1;
 always @(posedge clk_1 or negedge nrst)   
    begin
      if (!nrst) 
           for (i=1; i<=9; i=i+1)
               eq_dly[i] <= 0;  
       else    
         begin
           eq_dly[1] <= eq; 
          for (i=1; i<9; i=i+1)  //说明了整个 eq_dly[9:1]=9'b111111111;并不是一个时钟周期就完成了赋值。而是经过个九个时钟沿!!!!
               eq_dly[i+1] <= eq_dly[i];
         end            
    end      
     
     assign now_nine = !(&(eq_dly));  
     assign nrst_pos = !(eq && now_nine); 

endmodule

波形文件如下:

猜你喜欢

转载自www.cnblogs.com/shaonianpi/p/9432226.html