已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
8.21 自动售货机VHDL程序与仿真(1)自动售货机VHDL程序如下:-文件名:pl_auto1.vhd。-功能:货物信息存储,进程控制,硬币处理,余额计算,显示等功能。-说明:显示的钱数coin的 以5角为单位。-最后修改日期:2004.3.23。library ieee;use ieee.std_logic_arith.all;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity PL_auto1 isport ( clk:in std_logic; -系统时钟set,get,sel,finish: in std_logic; -设定、买、选择、完成信号coin0,coin1: in std_logic; -5角硬币、1元硬币price,quantity :in std_logic_vector(3 downto 0); -价格、数量数据item0 , act:out std_logic_vector(3 downto 0); -显示、开关信号y0,y1 :out std_logic_vector(6 downto 0); -钱数、商品数量显示数据act10,act5 :out std_logic); -1元硬币、5角硬币end PL_auto1;architecture behav of PL_auto1 istype ram_type is array(3 downto 0)of std_logic_vector(7 downto 0); signal ram :ram_type; -定义RAMsignal item: std_logic_vector(1 downto 0); -商品种类signal coin: std_logic_vector(3 downto 0); -币数计数器signal pri,qua:std_logic_vector(3 downto 0); -商品单价、数量signal clk1: std_logic; -控制系统的时钟信号begincom:process(set,clk1)variable quan:std_logic_vector(3 downto 0);begin if set=1 then ram(conv_integer(item)=price & quantity;act=0000;-把商品的单价、数量置入到RAM elsif clk1event and clk1=1 then act5=0; act10=0; if coin0=1 then if coin1001then coin=coin+1; -投入5角硬币,coin自加1 else coin=0000; end if; elsif coin1=1 then if coin1001then coin=coin+2; -投入1元硬币,coin自加2 else coin=0000; end if; elsif sel=1 then item0000 and coin=pri then coin=coin-pri;quan:=quan-1;ram(conv_integer(item)=pri & quan; if item=00 then act=1000; -购买时,自动售货机对4种商品的操作elsif item=01 then act=0100; elsif item=10 then act=0010; elsif item=11 then act0001 then act10=1;coin0000 then act5=1; coin=coin-1; else act5=0; act10=0; end if; elsif get=0 then act=0000; for i in 4 to 7 loop pri(i-4)=ram (conv_integer(item)(i); -商品单价的读取 end loop; for i in 0 to 3 loop quan(i):=ram(conv_integer(item)(i); -商品数量的读取 end loop; end if; end if;qua=quan;end process com;m32:process(clk) -此进程完成对32Mhz的脉冲分频variable q: std_logic_vector( 24 downto 0);begin if clkevent and clk=1 then q:=q+1; end if; if q=111111111111111111111111 then clk1=1; else clk1item0item0item0item0y0y0y0y0y0y0y0y0y0y0y0y1y1y1y1y1y1y1y1y1y1y1=1111111; end case;end process;end behav;(2)程序仿真注:仿真图里没有对clk信号进行分频处理。图
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 工地三级教育试卷及答案
- 国考行测真题及答案(省级)
- 养老护理员(三级)资格理论考试题库(附答案)
- 会计信息系统习题集及答案
- 2025年康复医学临床医师资格考试真题解析卷
- 临床医技感染防控模拟考试题
- 动物防疫法试题及答案
- 2025年二级建造师考试试题1套附答案详解
- 兰州市西固区教育系统招聘教师考试真题
- 大厦写字楼保安员考核试题
- 2025年山东颐养健康产业发展集团有限公司权属企业社会招聘考试笔试模拟试题及答案解析
- 试验员安全生产责任制内容
- 用电安全教育主题班会课件
- 2025年广东公务员笔试考试《行测》试题及参考答案
- 2025年植物生理学考研真题解析与策略卷及答案
- 医保费用结算管理制度
- 债务处理委托协议书
- 鱼骨图分析方法培训
- 2025初一历史时间轴记忆手册
- 2025年初中七年级科学上学期测试试卷(含答案)
- 风机基础环防水施工方案
评论
0/150
提交评论