If statement 如何在每个时钟边缘进行一次迭代,而不是在一个时钟边缘进行所有迭代

If statement 如何在每个时钟边缘进行一次迭代,而不是在一个时钟边缘进行所有迭代,if-statement,for-loop,verilog,If Statement,For Loop,Verilog,下面代码中的for循环是在一个posedge时钟中开始执行的。我希望每次迭代都发生在一个时钟边缘,以便在第五个时钟边缘激活我的if begin temp_number3=contact; for(i3=0;i3<10;i3=i3+1) begin //for loop beign count3=i3; if(count3==5) begin //beign for if message=1;

下面代码中的for循环是在一个posedge时钟中开始执行的。我希望每次迭代都发生在一个时钟边缘,以便在第五个时钟边缘激活我的if

begin 
  temp_number3=contact;
    for(i3=0;i3<10;i3=i3+1)
     begin //for loop beign 
     count3=i3;
     if(count3==5)
        begin //beign for if 
        message=1;
         contact_num=temp_number3; 
        end// end for if 
    end // end of for loop 
end
您不需要循环,但需要一个始终在时钟边缘处于活动状态的块,即:

begin
    always@(posedge clk)
    begin
       if(count3 == 5) begin
          message <= 1;
          contact_num <= temp_number3;
          count3 <= count3 + 1;
       end else if(count 3 == 9) begin
          count3 <= 0;
          stopFlag <= 1;
       end else if(~stopFlag)
          count3 <= count3 + 1;
    end
end

我希望这个循环在10个时钟周期后停止?那怎么可能呢happen@rohithveligeti:我已经编辑了一点示例。我希望现在你能看到怎么做。