|
|
发表于 2021-12-23 21:59:58
|
显示全部楼层
可以做成带load信号的计数器或状态机。mrst一般是异步复位不能与load(e)并||。
module counter(input clk,input mrst,input ld,output reg [3:0] count);
always@(posedge clk or negedge mrst)
begin
if(!mrst)//异步复位低有效
counter <= 4'b0000;
else if( load || count==4'b0101)
count <= 4'b0000;
else count <= counter + 4'b0001;
end
endmodule//
count可以作为状态机。
仅供参考
|
|