VHDL自动售邮票机的代码.doc_第1页
VHDL自动售邮票机的代码.doc_第2页
VHDL自动售邮票机的代码.doc_第3页
VHDL自动售邮票机的代码.doc_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

自动售邮票机代码: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 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 if zongstamp then if reset=1 then ret=zong(3 downto 0); n_state=stamp then light=1;ret if six=1or eight=1thenret=zong(3 downto 0);light=0;zong=00000; n_state retlight retlight retlight retlight retlight retlight

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论