📄 month_c.v.bak
字号:
//BCD计数器,从0计到0x99(BCD)
module month_c(reset,clk,monthnum,yearstyle,q,cout);
input reset,clk,yearstyle;
input [7:0] monthnum;
output cout;
output [7:0] q;
reg cout;
reg [7:0] q,length;
always @(posedge clk or negedge reset)
begin
if(!reset)
q<=8'd1;
cout<=0;
else begin
begin
if(monthnum==8'b1||monthnum==8'b11||monthnum==8'b101||monthnum==8'b111||monthnum==8'b1000||monthnum==8'b10000||monthnum==8'b10010)
length=8'd49;
else if(monthnum==8'b100||monthnum==8'b110||monthnum==8'b1001||monthnum==8'b10001)
length=8'd48;
else
begin
if(yearstyle)
length=8'd40;
else length=8'd41;
end
end
begin
if(((monthnum==8'b100||monthnum==8'b110||monthnum==8'b1001||monthnum==8'b10001)&&q==8'd49))
begin
cout<=0;
q<=8'd48;
end
else if(monthnum==8'b10&&yearstyle&&q>8'd40)
begin
cout<=0;
q<=8'd40;
end
else if(monthnum==8'b10&&(!yearstyle)&&q>8'd41)
begin
cout<=0;
q<=8'd41;
end
else if(q==length)
begin
q<=8'd1 ;
cout<=1;
end
else
begin
cout<=0;
if(q[3:0]==4'd9)
begin //bcd formt
q[3:0]<=4'd0;
q[7:4]<=q[7:4]+1;
end
else
q<=q+1;
end
end
end
end
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -