1个回答
展开全部
20进制计数器:
module 20_counter(in,out,clk,rst,en);
input [4:0]in;
output [4:0]out;
input clk,rst,en;
always@(posedge clk or negedge rst)
begin
if(!rst)
out<=5'b0;
else if(!en)
out<=out;
else if(out==5'b10011) //20进制计数器,0-19
out<=5'b0;
else
out<=out+1;
end
endmodule
module 20_counter(in,out,clk,rst,en);
input [4:0]in;
output [4:0]out;
input clk,rst,en;
always@(posedge clk or negedge rst)
begin
if(!rst)
out<=5'b0;
else if(!en)
out<=out;
else if(out==5'b10011) //20进制计数器,0-19
out<=5'b0;
else
out<=out+1;
end
endmodule
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询