用verilog语言编写一个20进制的定时器~~~(急)!
发布网友
发布时间:2024-04-08 10:52
我来回答
共2个回答
热心网友
时间:2024-05-17 07:26
mole counter(rstn,clk,reach);
input rstn;
input clk;
input reach;//到达20后reach从0跳到1
reg [4:0] var; //计时变量
assign reach = var==5'd19;
always@(posedge clk or negedge rstn)
begin
if(~rstn)
var <= 5'h0;
else if (var == 5'd19)
var <= 5'h0;
else
var <= var + 1;
end
endmoudle
热心网友
时间:2024-05-17 07:26
....
....
always@(posedge clk)
if(count=19)
begin
count<=0;
happen<= ( ..;
end
else
count<=count+1;