




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
自动售货机设计FPGA 模块模拟自动售货机的工作过程,要求如下(1)售货机有两个进币孔,可以输入硬币和纸币,售货机有两个进币孔,一个是输入硬币,一个是输入纸币,硬币的识别范围是1 元的硬币,纸币的识别范围是5 元,10 元,20,50 元,100元。乘客可以连续多次投入钱币。(2)顾客可以选择的商品种类有16 种,价格分别为1-16 元,顾客可以通过输入商品的编号来实现商品的选择。即有一个小键盘(0-9 按键)来完成,比如输入15 时要先输入1,再输入5。(3)顾客选择完商品后,可以选择需要的数量。然后可以继续选择商品及其数量,每次可以选择最多三个商品,且最多能选三种商品。然后显示出所需金额。顾客此时可以投币,并且显示已经投币的总币值。当投币值达到或超过所需币值后,售货机出货,并扣除所需金额,并找出多余金额。在投币期间,顾客可以按取消键取消本次操作,钱币自动退出。library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY vendor ISPORT( clk : in std_logic; key_in:in std_logic_vector(3 downto 0); -商品种类 、数量 coin1,coin5,coin10,coin20,coin50,coin100:in std_logic;-各个币值 reset: in std_logic; quit : in std_logic;-取消 get : in std_logic; quantity_set,varity_set: in std_logic; select_finished:in std_logic; continue_select:in std_logic; varity1_out,varity2_out,varity3_out : out std_logic_vector(15 downto 0); quantity1_out,quantity2_out,quantity3_out : out std_logic_vector(3 downto 0); act1_qua,act20_qua:out std_logic_vector(2 downto 0); act1,act5,act10,act20,act50,act100:out std_logic);END vendor;ARCHITECTURE behav of vendor ISsignal var_a1,var_a2,var_a3: std_logic_vector( 3 downto 0):=0000;signal qua_a1,qua_a2,qua_a3: std_logic_vector( 3 downto 0):=0000;signal count :std_logic_vector(7 downto 0):=00000000;-总额signal toubizhi :std_logic_vector(7 downto 0):=00000000;-投币值 signal pri_a1,pri_a2,pri_a3: std_logic_vector( 3 downto 0):=0000;-选中的三件商品的价格 个 BEGINprocess(reset,clk)variable i : std_logic_vector(1 downto 0) ;variable zhaobizhi : std_logic_vector(7 downto 0) ;beginif (reset=1) then varity1_out=0000000000000000; varity2_out=0000000000000000; varity3_out=0000000000000000; quantity1_out=0000; quantity2_out=0000; quantity3_out=0000; count=00000000; toubizhi=00000000; var_a1=0000;var_a2=0000;var_a3=0000; qua_a1=0000;qua_a2=0000;qua_a3=0000; act1=0;act5=0; act10=0;act20=0; act50=0;act100=0;i:=00; elsif ( clkevent and clk=1) then varity1_out=0000000000000000; varity2_out=0000000000000000; varity3_out=0000000000000000; quantity1_out=0000; quantity2_out=0000; quantity3_out=0000; act1=0;act5=0;act10=0; act20=0;act50=0;act100=0; act1_qua=000;act20_qua=000; if coin1=1 then toubizhi=toubizhi+1; elsif coin5=1 then toubizhi=toubizhi+5; elsif coin10=1 then toubizhi=toubizhi+10; elsif coin20=1 then toubizhi=toubizhi+20; elsif coin50=1 then toubizhi=toubizhi+50; elsif coin100=1 then toubizhi var_a1=key_in;pri_a1 var_a2=key_in;pri_a2 var_a3=key_in;pri_a3 i:=11; end case; elsif quantity_set=1 then case i is when 00 = qua_a1=key_in;count qua_a2=key_in;count qua_a3=key_in;counti:=11; end case; elsif continue_select=1 then if i11 then i:=i+1; else i:=11; end if; elsif select_finished=1 then count=count then zhaobizhi:=toubizhi-count; toubizhi0000 then quantity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out varity1_out=1000000000000000; end case; qua_a1=0000;var_a10000 then quantity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out varity2_out=1000000000000000; end case; qua_a2=0000;var_a20000 then quantity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out varity3_out=1000000000000000; end case; qua_a3=0000;var_a3=0000; end if; count00000000 then if zhaobizhi=01100100 then act100=00110010 then act50=00010100 ) then act20=1;zhaobizhi:=zhaobizhi-20;act20_qua=00010100 ) then act20=1;zhaobizhi:=zhaobizhi-20;act20_qua=00001010 and zhaobizhi00010100) then act10=00000101 and zhaobizhi00001010) then act5=00000001 and zhaobizhi00000101)then act1=1;zhaobizhi:=zhaobizhi-1;act1_qua=00000001 and zhaobizhi00000101)then act1=1;zhaobizhi:=zhaobizhi-1;act1_qua=00000001 and zhaobizhi00000101)then act1=1;zhaobizhi:=zhaobizhi-1;act1_qua=00000001 and zhaobizhi00000101)then act1=1;zhaobizhi:=zhaobizhi-1;act1_qua=100; end if; end if; end if; elsif quit=1 then -退币 zhaobizhi:=toubizhi; toubizhi00000000 then if zhaobizhi=01100100 then act100=00110010 then act50=00010100 ) then act20=1;zhaobizhi:=zhaobizhi-20;act20_qua=00010100 ) then act20=1;zhaobizhi:=zhaobizhi-20;act20_qua=00001010 and zhaobizhi00010100) then act10=00000101 and zhaobizhi00001010) then act5=00000001 and zhaobizhi00000101)then act1=1;zhaobizhi:=zhaobizhi-1;act1_qua=00000001 and zhaobizhi00000101)then act1=1;zhaobizhi:=zhaobizhi-1;act1_qua=00000001 and zhaobizhi00000101)then act1=1;zhaobizhi:=z
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 药品计划采购管理制度
- 药品食品仓库管理制度
- 药店医保统筹管理制度
- 药店消防培训管理制度
- 菌类种植基地管理制度
- 设备事故考核管理制度
- 设备售后出差管理制度
- 设备工具领取管理制度
- 设备检修费用管理制度
- 设备维护成本管理制度
- 2025春季学期国开电大本科《管理英语3》一平台机考真题及答案(第十套)
- 2025年社区工作者考试题目及答案
- 定额〔2025〕1号文-关于发布2018版电力建设工程概预算定额2024年度价格水平调整的通知
- 《云南省建筑工程资料管理规程应用指南)(上下册)
- 数列求和中常见放缩方法和技巧(含答案)
- 宝兴县中药材生产现状及发展思路
- 胸外科围手术期的气道管理.ppt
- 小儿雾化吸入课件.ppt
- 国际经济法案例分析(汇总)
- 锁骨骨折幻灯片
- 高填方、深挖路堑边坡和软基监测方案
评论
0/150
提交评论