VHDL自动售邮票机的代码.docVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
自动售邮票机代码: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity xrg4 is port(clk,clk1:in bit; coin1,coin5,coin10:in std_logic; --投入1、5、10角硬币 reset,reset1:in std_logic; --清零信号,1有效 six,eight:in std_logic; --6,8角的邮票 light:out std_logic; --购买成功指示灯 retlight:out std_logic_vector(3 downto 0) ); --找回的硬币 end entity xrg4; architecture xxrr of xrg4 is type state is (s0,s1,s2);--状态机 signal n_state:state;--次态 signal c_state:state;--现态 signal touru:std_logic_vector(3 downto 0); --投入硬币面值 signal tincoint:std_logic_vector(4 downto 0);--计算出硬币总值(进程中) signal stamp:std_logic_vector(3 downto 0); --邮票面值 signal ret:std_logic_vector(3 downto 0); --找零值 signal zong:std_logic_vector(4 downto 0); --状态机硬币总值 begin p1:process(clk1) --次态给现态 begin if reset1=1then c_state=s2; elsif clk1event and clk1=1then c_state=n_state; end if; end process p1; p2:process(clk) --投入钱并计算总值 begin if reset1=1then tincoint=00000; elsif clkevent and clk=1 then if coin1=1then touru=0001; elsif coin5=1then touru=0101; elsif coin10=1then touru=1010; elsif coin1=0 and coin5=0 and coin10=0 then touru=0000; end if; tincoint=touru+tincoint; end if; end process p2; p3:process(c_state) --进行购买,找零,退钱 begin zong=tincoint; case c_state is when s0= if six=1 then stamp=0110;n_state=s1; --选通6角或8角邮票 elsif eight=1 then stamp=1000; n_state=s1; else zong=00000;ret=0000;light=0;n_state=s0; end if; when s1= if zongstamp then if reset=1 then ret=zong(3 downto 0); n_state=s2; end if; elsif zong=stamp then light=1;ret=(zong-stamp); end if; when s2= if six=1or eight=1then ret=zong(3 downto 0);light=0;zong=00000; n_state=s0; end if; end case

文档评论(0)

137****6622 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档