利用for循环实现D触发器链(可综合)
module DFF_link( input clk , input rst_n , input input_data , output output_data ); reg dff[3:0]; integer loop; assign output_data=dff[3]; always@(posedge clk&nbs***bsp;negedge rst_n ) begin if(!rst_n) begin for(loop=0;loop<=3;loop=loop+1)begin dff[loop]<=1'b0; end end else begin dff[0]<=input_data; for(loop=1;loop<=3;loop=loop+1)begin dff[loop]<=dff[loop-1]; end end end endmodule
喜欢本文的同学欢迎收藏点赞多多留言,本文原发于【FPGA hdl】