• 方案介绍
  • 附件下载
  • 相关推荐
申请入驻 产业图谱

可调万年历(识别闰年)设计Verilog代码Quartus仿真

09/29 08:49
494
加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论

2-2410311K15G31.doc

共1个文件

名称:可调万年历(识别闰年)设计Verilog代码Quartus仿真

软件:Quartus

语言:Verilog

代码功能:

可调万年历(识别闰年)设计

1、设计万年历,可以按键调节年、月、日

2、输出年月日

3、自动识别闰年

FPGA代码Verilog/VHDL代码资源下载:www.hdlcode.com

演示视频:

设计文档:

1.工程文件

2.程序文件

3.程序编译

4.RTL图

5.仿真图

部分代码展示:

//万年历
`timescale  1ns/100ps
module calendar
(
input  CLK,
input  RST,
input day_add,//天加
input day_sub,//天减
input month_add,//月加
input month_sub,//月减
input year_add,//年加
input year_sub,//年减
output reg [7:0]   year_h,//年高位
output reg [7:0]   year_l,//年低位
output reg [3:0]   month,//月
output reg [4:0]   day//天
);
reg month_add_cin=0;
reg month_sub_cin=0;
reg year_add_cin=0;
reg year_sub_cin=0;
reg [4:0]   day_max  =  5'd30;//定义月最大天数
always@(posedge CLK or posedge RST)
begin
  if (RST)
day_max <= 5'd30;
  else
if(!(year_l[1:0] == 0 & year_l !=0 | year_h[1:0] ==0 & year_l ==0)&(month == 2))
day_max <= 5'd28;//非闰年2月
else if((year_l[1:0] == 0 & year_l !=0 | year_h[1:0] ==0 & year_l ==0)&(month == 2))
day_max <= 5'd29;//闰年2月
else if((month == 4)|(month == 6)|(month == 9)|(month == 11))
day_max <= 5'd30;//小月
else if((month == 1)|(month == 3)|(month == 5)|(month == 7)|(month == 8)|(month == 10)|(month == 12))
day_max <= 5'd31;//大月
else
day_max <= 5'd30;
end

点击链接获取代码文件:http://www.hdlcode.com/index.php?m=home&c=View&a=index&aid=1298

  • 2-2410311K15G31.doc
    下载

相关推荐