首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >制作用VHDL语言显示月数和月日的日历?

制作用VHDL语言显示月数和月日的日历?
EN

Stack Overflow用户
提问于 2013-09-21 17:44:52
回答 1查看 2.1K关注 0票数 0

问:制作显示月号和月日的日历?用组合式和顺序式VHDL结构写?

我是这方面的新手,星期一有个测验。有人知道从哪里开始用VHDL编写程序吗?任何帮助都将不胜感激。

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-27 18:14:53

这是一些东西让你开始你的任务。它接受月份( 1-12 )的二进制值,如果它是闰年或非闰年,并输出该月份的天数。这是不需要时钟(组合/异步逻辑)的。

我认为您可以根据任务要求确定使用顺序语句创建替代实现的最佳方法。

代码语言:javascript
复制
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity Days_In_Month is
   port (
      I_MONTH         : in  unsigned(3 downto 0);
      I_LEAP_YEAR     : in  std_logic;
      O_DAYS_IN_MONTH : out unsigned(4 downto 0)
      );
end entity Days_In_Month;

architecture Days_In_Month_combinatorial of Days_In_Month is

   signal month_30d : std_logic;
   signal month_28d : std_logic;
   signal month_31d : std_logic;
   signal month_29d : std_logic;

begin

   month_30d <= '1' when I_MONTH = 9 or
                         I_MONTH = 4 or
                         I_MONTH = 6 or
                         I_MONTH = 11
                    else '0';

   month_28d <= '1' when I_MONTH = 2 and
                         I_LEAP_YEAR = '0'
                    else '0';
   month_29d <= '1' when I_MONTH = 2 and
                         I_LEAP_YEAR = '1'
                    else '0';
   month_31d <= '1' when month_30d = '0' and
                         month_28d = '0' and
                         month_29d = '0'
                    else '0';

   O_DAYS_IN_MONTH <= to_unsigned(30,O_DAYS_IN_MONTH'length) when month_30d = '1' else
                      to_unsigned(28,O_DAYS_IN_MONTH'length) when month_28d = '1' else
                      to_unsigned(29,O_DAYS_IN_MONTH'length) when month_29d = '1' else
                      to_unsigned(31,O_DAYS_IN_MONTH'length) when month_31d = '1'
                      else to_unsigned(0,O_DAYS_IN_MONTH'length);                   

end architecture Days_In_Month_combinatorial;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18935639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档