📄 counter_24b.v
字号:
module counter_24b(qout,load,reset,clk);
output[23:0] qout;
input load,clk,reset;
reg[23:0] qout=0;
always @(posedge clk or negedge reset) //clk 上升沿时刻计数
begin
if (!reset) qout[23:0]<=24'h0; //异步复位
else if(!load) qout[23:0]<=24'h0; //同步置0
else
begin
if(qout[23:0]==24'h999999)
begin
qout[23:0]<=24'h000000;
end
else if(qout[23:20]<=4'h9&&qout[19:0]==20'h99999)
begin
qout[23:20]<=qout[23:20]+4'h1;
qout[19:0]<=20'h00000;
end
else if(qout[19:16]<=4'h9&&qout[15:0]==16'h9999)
begin
qout[19:16]<=qout[19:16]+4'h1;
qout[15:0]<=16'h0;
end
else if(qout[15:12]<=4'h9&&qout[11:0]==12'h999)
begin
qout[15:12]<=qout[15:12]+4'h1;
qout[11:0]<=12'h000;
end
else if(qout[11:8]<=4'h9&&qout[7:0]==8'h99)
begin
qout[11:8]<=qout[11:8]+4'h1;
qout[7:0]<=8'h00;
end
else if(qout[7:4]<=4'h9&&qout[3:0]==4'h9)
begin
qout[7:4]<=qout[7:4]+4'h1;
qout[3:0]<=4'h0;
end
else if(qout[3:0]<=4'h9)
begin
qout[3:0]<=qout[3:0]+4'h1;
end
else begin qout[23:0]<=24'h0; end
end
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -