自动售货机控制模块 VHDL 程序设计及 FPGA 实现

合集下载

基于VHDL语言自动售货机设计实验报告-绝对原创

基于VHDL语言自动售货机设计实验报告-绝对原创

自动售货机设计实验报告一设计题目:g) 自动售货机设计FPGA模块模拟自动售货机的工作过程,要求如下(1)售货机有两个进币孔,可以输入硬币和纸币,售货机有两个进币孔,一个是输入硬币,一个是输入纸币,硬币的识别范围是5角和1 元的硬币,纸币的识别范围是1 元、5 元,10 元,20元,50元,100元。

乘客可以连续多次投入钱币。

(2)顾客可以选择的商品种类有16种,价格分别为1-16元,顾客可以通过输入商品的编号来实现商品的选择。

即有一个小键盘(0-9按键)来完成,比如输入15时要先输入1,再输入5。

(3)顾客选择完商品后,可以选择需要的数量。

然后可以继续选择商品及其数量,每次可以选择最多三个商品。

然后显示出所需金额。

顾客此时可以投币,并且显示已经投币的总币值。

当投币值达到或超过所需币值后,售货机出货,并扣除所需金额,并找出多余金额。

在投币期间,顾客可以按取消键取消本次操作,钱币自动退出。

二程序代码:三程序实现功能:FPGA模块模拟自动售货机:(1)售货机有两个进币孔,分别输入硬币和纸币,硬币的识别范围是5角和1 元的硬币,纸币的识别范围是1 元、5 元,10 元,20元,50元,100元。

乘客可以连续多次投入钱币。

(2)顾客可以选择的商品种类有16种,价格分别为1-16元,顾客可以通过输入商品的编号来实现商品的选择。

(3)顾客选择完商品后,可以选择需要的数量。

然后可以继续选择商品及其数量,每次最多选择最种商品,每种商品最多购买三个。

然后显示出所需金额。

顾客此时可以投币,并且显示已经投币的总币值。

当投币值达到或超过所需币值后,售货机出货,并扣除所需金额,并找出多余金额。

在投币期间,顾客可以按取消键取消本次操作,钱币自动退出。

四程序功能模块分析:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;实体说明:entity sellor isport ( clk:in std_logic; --系统时钟sel,cancel,reset: in std_logic; --选择、取消、开始(用于进入初始状态)变量定义:coin: in std_logic_vector(1 downto 0); --5角硬币、1元硬币crash:in std_logic_vector(5 downto 0); --100元、50元、20元、10元、5元、一元纸币item: in std_logic_vector(3 downto 0); --16种商品quantity:in std_logic_vector(1 downto 0); --商品数量(一次最多购买3件)change_out :out std_logic_vector(10 downto 0); --找零item_out :out std_logic_vector(3 downto 0); --是否购买了商品(1表示有商品出来、0表示没有商品出来)change :out std_logic ); --是否有找零end sellor;结构体说明:architecture behave of sellor issignal price:std_logic_vector(7 downto 0);signal counter: std_logic_vector(10 downto 0); --币数计数器signal total_price:std_logic_vector(10 downto 0); --控制系统的时钟信号type state_type is (initial_state,item1_state,quantity_state,money_state,sell_state,change_state);signal state:state_type;signal temp:std_logic_vector(1 downto 0);signal quan:std_logic_vector(3 downto 0);begincom:process(reset,sel,clk)beginif (clk'event and clk='1')thenif reset='1' then state<=initial_state;temp<="00";quan<="0000";end if;case state iswhen initial_state=>item_out<="0000"; --出票口关闭change_out<="00000000000"; --找零口关闭total_price<="00000000000"; --票价总额记录清零counter<="00000000000";--投入钱币总额记录清零change<='0';state<=item1_state; 设定initial_state选择物品程序:when item1_state=>if temp<"11" thenelse state<=money_state;end if;when quantity_state=>if(cancel='1')then --按下“取消”按钮state<=initial_state;else 取消操作程序if quantity="00" thenitem_out<="0000";change<='0';change_out<="00000000000";state<=initial_state;else 当选择0个商品total_price<=total_price+price*quantity;temp<=temp+1;quan<=quan+quantity;if (sel='1') then state<=item1_state;elsestate<=money_state;end if;end if;end if;货币识别:when money_state=>if(cancel='1')then --按下“取消”按钮state<=initial_state;end if;case crash is --纸币识别end case;case coin is --硬币识别end case;if counter>=total_price thenstate<=sell_state;--系统进入出票状态end if;购物操作程序:when sell_state =>if(cancel='1')thenitem_out<="0000";change<='1';change_out<=counter; --按下“取消”按钮state<=initial_state;elseif counter>=total_price thenitem_out<=quan; --判断是否还有找零state<=change_state; --系统进入找零状态elseitem_out<="0000";state<=initial_state;end if;end if;when change_state=>if(cancel='1')thenitem_out<="0000";change<='1';change_out<=counter; --按下“取消”按钮state<=initial_state;elseif counter>total_price thenchange<='1';change_out<=counter-total_price;item_out<=quan;elsechange<='0';change_out<="00000000000";state<=initial_state;end if;end if;end case;end if;end process;end behave;五、仿真波形六、个人总结与感想:良好的沟通与分工是十分重要的,这对程序的实现和质量具有至关重要的作用。

基于FPGA的自动售货机的课设说明书

基于FPGA的自动售货机的课设说明书

目录1 引言 (1)2 VHDL介绍 (2)2.1 硬件描述语言VHDL (2)2.2 VHDL语言的特点 (3)3 QuartusII软件简介 (4)3.1软件介绍 (4)3.2界面介绍 (4)3.2.1代码输入界面 (4)3.2.2功能仿真界面 (5)3.2.3波形仿真界面 (6)4 自动售货机控制器设计与仿真 (7)4.1硬件电路设计 (7)4.2状态转换图 (7)4.3时序仿真结果 (10)5引脚锁定及下载 (12)5.1引脚锁定 (12)5.2下载 (12)5.3结果分析 (12)6设计总结 (14)参考文献 (15)附录 (16)1 引言VHDL的英文全名是VHSIC(Very High Speed Integrated Circuit)Hardware Descriptiong Language,诞生于1982年。

1987年底,VHDL被美国国防部确认为标准硬件描述语言。

自IEEE公布了VHDL的标准版本,IEEE-1076之后,各EDA公司相继推出了自己的VHDL设计环境,或宣布自己的设计工具可以和VHDL接口。

1993年,IEEE对VHDL进行了修订,从更高的抽象层次和系统描述能力上扩展VHDL的内容,公布了新版本的VHDL,即IEEE标准的1076-1993版本。

现在,VHDL和Verilog作为IEEE的工业标准硬件描述语言,又得到众多EDA公司的支持,在电子工程领域,已成为事实上的通用硬件描述语言。

有专家认为,在新的世纪中,VHDL于Verilog语言将承担起大部分的数字系统设计任务。

VHDL的英文全写(Very-High-Speed Integrated Circuit HardwareDescription Language)翻译成中文就是超高速集成电路硬件描述语言。

因此它的应用主要是应用在数字电路的设计中。

目前,它在中国的应用多数是用在FPGA/CPLD/EPLD的设计中。

基于FPGA的自动售货机控制系统的设计

基于FPGA的自动售货机控制系统的设计

基于FPGA的自动售货机控制系统的设计摘要本文旨在设计一种基于FPGA(现场可编程门阵列)的自动售货机控制系统。

该系统利用FPGA芯片的可编程特性和高性能,能够实现灵活、可靠的自动售货机操作。

本文将详细介绍系统的设计原理、硬件架构和关键功能,并提供实施建议和性能评估。

引言自动售货机已经成为现代社会的常见设备,用于快速、方便地购买商品。

然而,传统的自动售货机控制系统常常受限于固定的硬件结构和有限的功能。

为了提升自动售货机的灵活性和性能,本文提出基于FPGA的控制系统设计。

设计原理基于FPGA的自动售货机控制系统利用FPGA芯片的可编程特性,通过组合逻辑和时序逻辑实现自动售货机的各项功能。

系统将通过外部接口与售货机的硬件部分进行通信,并处理用户输入、商品库存、货币交易等关键操作。

通过FPGA的灵活配置和高速性能,该控制系统能够实现实时响应、精确计算和可靠交互。

硬件架构系统的硬件架构主要包括FPGA芯片、外部接口电路、按钮和显示屏。

FPGA芯片作为核心处理单元,负责运行控制程序和管理系统资源。

外部接口电路用于与售货机硬件部分进行数据传输和控制信号的交互。

按钮和显示屏提供用户与自动售货机进行交互的接口。

关键功能基于FPGA的自动售货机控制系统具备以下关键功能:1. 商品选择和购买:用户可以通过按钮选择所需商品,并进行购买操作。

系统将根据用户选择,实时更新商品库存和计算金额。

2. 货币交易:系统支持不同货币单位的识别和计算。

用户可以通过投币或刷卡等方式完成支付,系统将验证货币的合法性并进行交易处理。

3. 商品库存管理:系统能够实时监测商品库存,并在库存不足时提醒用户或停止销售。

管理员可以通过特定操作进行库存的添加和更新。

4. 故障监测和报警:系统能够监测售货机硬件部分的运行状态,并在故障发生时及时报警或进行相应处理。

实施建议实施基于FPGA的自动售货机控制系统时,可以考虑以下建议:1. 确定系统需求,并合理规划FPGA芯片和外部接口电路的选型和布局。

基于FPGA的自动售货机-课程设计

基于FPGA的自动售货机-课程设计

武汉理工大学《电子线路EDA》课程设计说明书绪论自动售货机(Vending Machine,VEM)是能根据投入的钱币自动付货的机器。

自动售货机是商业自动化的常用设备,它不受时间、地点的限制,能节省人力、方便交易。

是一种全新的商业零售形式,又被称为24小时营业的微型超市。

能分为三种:饮料自动售货机、食品自动售货机、综合自动售货机。

它能够在无人操作的情况下根据程序自动地销售商品。

自动售货机不受工作时间及地点限制的特点,使其实现了一种提高营业额的同时又降低了成本的销售模式。

进入21世纪之后,自动售货机的发展进一步加快,智能化的自动售货机正在逐步进入普通民众的生活之中,在未来,自动售货机的发展将会更加迅速,更加智能的自动售货机会让人们的生活更加便利。

VHDL主要用于描述数字系统的结构,行为,功能和接口。

除了含有许多具有硬件特征的语句外,VHDL的语言形式和描述风格与句法是十分类似于一般的计算机高级语言。

VHDL的程序结构特点是将一项工程设计,或称设计实体(可以是一个元件,一个电路模块或一个系统)分成外部(或称可视部分,及端口)和内部(或称不可视部分),既涉及实体的内部功能和算法完成部分。

在对一个设计实体定义了外部界面后,一旦其内部开发完成后,其他的设计就可以直接调用这个实体。

这种将设计实体分成内外部分的概念是VHDL系统设计的基本点。

因此,此次运用VHDL语言来实现一个简易的自动售货机是一个很有意义并且非常有乐趣的课题!关键词:自动售货机 VHDL1 课程设计实验要求1.1 初始条件设计一个自动售货机控制器,具有投币和选择商品等功能。

可出售四种商品,分别为纯净水(2元)、可乐(4.5元)、牛奶(5元)、果汁(5.5元)。

在购买过程中,采取投币方式,只能投入5元、10元或20元三种规格的纸币,且一次只能投入一张纸币。

1.2 要求完成的主要任务1.顾客通过按键选择某种商品后,由数码管显示该商品价格。

顾客投币过程中,数码管显示投币额。

基于FPGA的自动售货机控制单元设计

基于FPGA的自动售货机控制单元设计

图书分类号:密级:毕业设计(论文) 基于FPGA的自动售货机控制单元设计学生学号学生姓名学院名称专业名称指导教师年月日摘要近年来在随着我国各种大小商品市场快速发展以及城市化不同程度的不断提高,自动售货机已经越来越受到大中城市的青睐,自动售货机在这些大中城市中已经获得了越来越广泛的应用,因此自动售货机的快速发展已经得到了不断的提高和认可,同时自动售货机也极大地丰富了我国的商业产业的结构,是商业结构有了更加丰富的拓展,这样在商业结构中开辟了一种全新的自动自主销售和自动自主服务的时代。

本文将结合大学期间所学的EDA技术实现自动售货机控制系统的设计,应用这种技术实现设计的自动售货机控制系统,将会有效的减小系统的开发周期,同时降低了很多开发成本,因此是一种可行的设计方案和趋势。

该设计在整体设计架构中主要包含两个部分:主要有硬件系统设计部分和FPGA内部电路的编程设计部分。

在FPGA内部电路的编程设计部分主要采用硬件描述语言(Vhdl)对自动售货机的控制系统进行功能描述以及各状态之间的设计。

该设计FPGA硬件部分主要是目前最通用的FPGA之一即ALTERA公司的FPGA芯片为设计目标器件。

该设计中硬件系统设计是围绕系统设计所选合适的FPGA器件的硬件电路进行设计。

本文中将详细介绍了基于FPGA的自动售货机的整体设计方案流程与工作原理及工作状态,在功能叙述中详细阐述了投币选择模块,物品选择模块,主控模块等模块的软件系统设计与实现,在前期设计完成之后对所设计的FPGA内部功能进行功能仿真验证,在确定设计正确无误之后进行下板子测试验证。

关键词FPGA ;EDA;自动售货机;VHDLAbstractWith the continuously prosperity of china’s commodity market and with the rapid develepment of modernization level , vending machines has enterd into large and medium-sized cities quietly ,it enriches china’s commercial industrial structure and creates a new era of automatic selling and self-service.This subject will accomplish the control system of vending machine with EDA technology.Since it has the advantages of shortening product development cycle,reducing product develepment cost , increasing the possibility of first-time success and so on,it can enhence the exploitability of aotomatic machinea and lower the costs.The issue consists of two parts:hardware system design and fpga internal circuit design. Fpga internal circuit design uses hardware describe language (vhdl )to describe the fuction of vending machine;and fpga chip of ALTERA Corporation is choosen for the target device. Hardware system design is a hardware circuit design that center on the selected appropriate fpga device. and the design of the internal functions of FPGA is simulated.Keywords FPGA EDA Vending Machine VHDL目录第1章绪论 (1)1.1 自动售货机的历史 (1)1.2 自动售货机的研究现状 (1)1.3 未来发展和研究方向 (2)1.4 本文的章节安排 (2)第2章关键技术介绍 (4)2.1 EDA技术............................................................................................. 错误!未定义书签。

基于VHDL的自动售货机的设计和实现论文

基于VHDL的自动售货机的设计和实现论文

《计算机组成原理》课程设计报告基于VHDL的自动售货机设计与实现课程设计任务书计算机与通信工程学院网络工程专业指导教师对学生在课程设计中的评价指导教师对课程设计的评定意见基于VHDL的自动售货机设计与实现摘要:本设计运用VHDL语言编写一个自动售货机的控制系统,该系统具有货物信息存储,进程控制,硬币处理,余额计算,显示等功能。

商品的种类、单价和数量在初始化时输入,然后存储。

可以识别的币种为硬币,五毛和一元的面额。

用户投入硬币,系统累计数量,然后对比物品的单价和数量,扣除价格,最后计算余额,可以找零。

设计没有考虑硬件的实现,只进行功能的相应仿真,性质为实验性质的课程设计。

关键词:VHDL、自动售货机、课程设计、MXAPLUSⅡ、系统仿真Abstract: This design use of VHDL language design a vending machine control system, the system have the functions to storagethe goods information, process control, coin handling, balance calculation, display and other functions. The type of goods, unit price and quantity in the initialization to be input, and then stored. Currency for the coins can be identified, fifty cents and one dollar denomination. User input coins, the system account sum, and then comparing the unit price and quantity of goods, net price, the final calculation of the balance, you can give change.Design did not consider the hardware implementation, only the corresponding functional simulation, experimental nature of the curriculum design.Keywords: VHDL, vending machines, curriculum design, MXAPLUS Ⅱ, system simulation目录1.引言 (7)1.1自动售货机系统概述 (7)1.2设计任务和主要容 (8)2.系统设计过程 (9)2.1自动售货机系统总体框图 (9)2.2系统功能模块 (9)2.3程序源代码 (11)3.系统仿真 (15)3.1系统仿真全图 (15)3.2系统分步仿真图 (16)4.总结 (20)参考文献 (21)1 引言随着现在生活节奏越来越快,自动售货机的出现大大方便了人们的日常生活。

自动售货机电路设计VHDL

自动售货机电路设计VHDL

郑州轻工业学院课程设计任务书题目自动售货机电路设计专业、班级电信2班学号 541101030217 姓名李磊主要内容、基本要求、主要参考资料等:查阅资料完成自动售货机的设计思路,利用硬件编程语言VHDL 或者Verilog-HDL来实现,要求能够识别100元、50元、10元、5元及其钢崩1元五种面值的设计,能够找零,设计中假设找零货贝充裕,货物的价格不允许出现0.5元的情况。

给出完成控制电路所需要的设计模块;给出硬件编程语言的实现,并进行仿真;给出下载电路的设计,设计为2种下载方法,其中一种必须为JTAG;同时设计者报告不允许雷同。

参考资料:1、潘松、黄继业《EDA技术及其应用》(第四版)科学出版社 20092、数字信号处理的教材完成期限:指导教师签名:课程负责人签名:摘要随着电子技术的发展,当今数字系统的设计正朝着速度快,容量大,体积小,重量轻的方向发展,推动该潮流迅猛发展的引擎就是日趋进步和完善的ASIC设计技术,AISC芯片具有价格低,体积小,可靠性高等优点,目前在电子产品中已有广泛的应用,VHDL是一种用来描述数字逻辑系统的“编程语言”,它通过对硬件行为的直接描述来实现对硬件的物理实现,代表了当今硬件设计的发展方向。

本文是在VHDL的基础上对自动售货机进行设计来实现其基本功能的,采用了Altera的开发软件Quarts II。

通过在该软件平台上进行数字电路设计和仿真的方法,阐述了VHDL(Very High Speed Integrated Circuit Hardware Description Language)超高速集成电路硬件描述语言的一些特点及语法结构,介绍了自动售货机的基本原理、系统组成和主要功能,并分析讨论了用VHDL语言开发自动售货机系统的设计流程。

本设计采用VHDL硬件描述语言编程的设计方法设计系统核心电路的硬件程序,在Quartus II软件平台上进行编译和仿真。

文章首先简述了自动售货机系统的意义和发展现状以及VHDL语言的特点,然后介绍了自动售货机的设计要求、设计思路,并给出了总体设计框图,通过分析设计写出VHDL程序源代码,将代码在Quartus II软件平台上进行编译仿真,波形基本符合设计要求。

基于VHDL编程FPGA的地铁自动售票机

基于VHDL编程FPGA的地铁自动售票机

地铁自动售票机一、设计要求1、功能描述用于模仿地铁售票自动售票,完成地铁售票的核心控制功能。

2、功能要求售票机有两个进币孔,一个是输入硬币,识别的范围是一元硬币;一个是纸币,识别的范围是一元、两元、五元、十元、二十元。

乘客可以连续多次投入钱币。

乘客一次只能选择一个出站口,购买车票时,乘客先选出站口,有六个出站口可供选择,再选择所需的票数,然后投币,投入的钱币达到或者超过所需金额时,售票机自动出票,并找零。

本次交易结束后,等待下一次交易。

在选择出站口、所需票数以及在投币期间,乘客可以按取消键取消操作,钱币自动退出。

二、实验分析1、买票时,乘客按下开始键,售票机进入站台选择程序,乘客选择出站口后,可以按取消键重新选择,否则售票机自动进入票数选择程序,同样这时可以按下取消键重新开始选择出站口以及票数。

2、当选择好出站口以及所需票数时,乘客可以投硬币或者用纸币,当所投的钱币总额大于或者等于票价时,售票机自动出票以及找零。

期间,可以按下取消键重新开始选择,并退出所有的钱币。

3、乘客若还没选择出站口或者票数,就投币或者使用纸币,售票机会自动退出所有的钱币。

4、有六个站台可供乘客选择,每个乘客最多可以买3张票,六个站台编号为1到6,票价从2元依次递增到7。

三、系统流程图四、程序源代码LIBRARY IEEE;USE IEEE.std_logic_1164.ALL;USE IEEE.std_logic_arith.ALL;USE IEEE.std_logic_unsigned.ALL;ENTITY metrosell ISPORT(clk:in std_logic; --set the clock signalstartselect:in std_logic; --start to select the platformsure:in std_logic; --this button is to save your forward step(s)coin1y:in std_logic; --1 yuan coinpmoney1y:in std_logic; --1 yuan paper moneypmoney2y:in std_logic; --2 yuan paper moneypmoney5y:in std_logic; --5 yuan paper moneypmoney10y:in std_logic; --10 yuan paper moneypmoney20y:in std_logic; --20 yuan paper moneycancel:in std_logic; --cancel the forward step(s)number:in std_logic_vector(3 downto 0); --choose the number of the ticketsplatform:in std_logic_vector(3 downto 0); --choose the platform you want to reachmoneystorage:out std_logic; --to store the moneyacceptmo:out std_logic; --accept the moneystamp:out std_logic; --stamp outgatecharge:out std_logic_vector(3 downto 0); --the mount of charge,up to 15 yuanchargegate:out std_logic --charge outgate);END metrosell;ARCHITECTURE sell OF metrosell IStype state_type is(initial_type,selectp_type,selectnum_type,insert_type,stamp_type,charge_type);--define six typessignal state:state_type; --define a shared state BEGINmain:process(clk,state,startselect,platform,number,coin1y,pmoney1y,pmoney2y,pmon ey5y,pmoney10y,pmoney20y,cancel,sure)variable univalence :integer range 0 to 7; --the univalence of the ticket variable total_money :integer range 0 to 21; --the price of the ticket(s)variable selectp_alr:std_logic; --the flag of select platform typevariable selectnum_alr:std_logic; --the flag of select number typevariable stamp_alr:std_logic; --the flag of the stamp gate variable charge_alr:std_logic; --the flag of the charge gatevariable money_reg:integer range 0 to 21; --the mount of money put in variable coin1y_f:std_logic; --the flag of one yuan coin variable pmoney1y_f:std_logic; --the flag of one yuan paper moneyvariable pmoney2y_f:std_logic; --the flag of two yuan paper moneyvariable pmoney10y_f:std_logic; --the flag of ten yuan paper moneyvariable pmoney20y_f:std_logic; --the flag of twelve yuan paper moneyvariable pmoney5y_f:std_logic; --the flag of five yuan paper moneyvariable charge_reg:integer range 0 to 15; --the register of chargebeginif(rising_edge(clk)) thencase state iswhen initial_type => --initialize some variablesunivalence:=0;selectp_alr:='0';selectnum_alr:='0';stamp_alr:='0';charge_alr:='0';money_reg:=0;total_money:=0;coin1y_f:='0';pmoney1y_f:='0';pmoney2y_f:='0';pmoney5y_f:='0';pmoney10y_f:='0';pmoney20y_f:='0';moneystorage<='0';stamp<='0';charge_reg:=0;charge<="0000";acceptmo<='0';chargegate<='0';if (startselect='1') thenstate<=selectp_type;end if;when selectp_type =>if(selectp_alr='0'and cancel='0') then --choose the platform if(platform="0001")then univalence:=2;selectp_alr:='1';elsif(platform="0010")then univalence:=3;selectp_alr:='1';elsif(platform="0011")then univalence:=4;selectp_alr:='1';elsif(platform="0100")then univalence:=5;selectp_alr:='1';elsif(platform="0101")then univalence:=6;selectp_alr:='1';elsif(platform="0110")then univalence:=7;selectp_alr:='1';elsif(platform="0000")then univalence:=0;selectp_alr:='0';else null;end if;elsif(selectp_alr='1'and cancel='1')then state<=initial_type;elsif(selectp_alr='1'and sure='1') then state<=selectnum_type;end if;when selectnum_type => --you can buy at most 3 ticketsif(selectnum_alr='0'and cancel='0')then--choose the number of ticketsif(number="0001")thenif(univalence=2)thentotal_money:=2;selectnum_alr:='1';elsif(univalence=3)thentotal_money:=3;selectnum_alr:='1';elsif(univalence=4)thentotal_money:=4;selectnum_alr:='1';elsif(univalence=5)thentotal_money:=5;selectnum_alr:='1';elsif(univalence=6)thentotal_money:=6;selectnum_alr:='1';elsif(univalence=7)thentotal_money:=7;selectnum_alr:='1';elsif(univalence=0)thentotal_money:=0;selectnum_alr:='0';else null;end if;end if;if(number="0010")thenif(univalence=2)thentotal_money:=4;selectnum_alr:='1';elsif(univalence=3)thentotal_money:=6;selectnum_alr:='1';elsif(univalence=4)then total_money:=8;selectnum_alr:='1';elsif(univalence=5)then total_money:=10;selectnum_alr:='1';elsif(univalence=6)then total_money:=12;selectnum_alr:='1';elsif(univalence=7)then total_money:=14;selectnum_alr:='1';elsif(univalence=0)then total_money:=0;selectnum_alr:='0';else null;end if;end if;if(number="0011")thenif(univalence=2)then total_money:=6;selectnum_alr:='1';elsif(univalence=3)then total_money:=9;selectnum_alr:='1';elsif(univalence=4)then total_money:=12;selectnum_alr:='1';elsif(univalence=5)then total_money:=15;selectnum_alr:='1';elsif(univalence=6)then total_money:=18;selectnum_alr:='1';elsif(univalence=7)then total_money:=21;selectnum_alr:='1';elsif(univalence=0)then total_money:=0;selectnum_alr:='0';else null;end if;end if;elsif(selectnum_alr='1'and cancel='1')then state<=initial_type;elsif(selectnum_alr='1'and sure='1') then state<=insert_type;end if;when insert_type =>moneystorage<='1';if(money_reg<total_money and cancel='0')then--receive the inserted moneyif(coin1y='1'andcoin1y_f='0')then money_reg:=money_reg+1;coin1y_f:='1';end if;if(coin1y='0'and coin1y_f='1')then coin1y_f:='0';end if;if(pmoney1y='1'and pmoney1y_f='0')thenmoney_reg:=money_reg+1;pmoney1y_f:='1';end if;if(pmoney1y='0'and pmoney1y_f='1')thenpmoney1y_f:='0';end if;if(pmoney2y='1'and pmoney2y_f='0')thenmoney_reg:=money_reg+2;pmoney2y_f:='1';end if;if(pmoney2y='0'and pmoney2y_f='1')thenpmoney2y_f:='0';end if;if(pmoney5y='1'and pmoney5y_f='0')thenmoney_reg:=money_reg+5;pmoney5y_f:='1';end if;if(pmoney5y='0'and pmoney5y_f='1')thenpmoney5y_f:='0';end if;if(pmoney10y='1'and pmoney10y_f='0')thenmoney_reg:=money_reg+10;pmoney10y_f:='1';end if;if(pmoney10y='0'and pmoney10y_f='1')then pmoney10y_f:='0';end if;if(pmoney20y='1'and pmoney20y_f='0')then money_reg:=money_reg+20;pmoney20y_f:='1';end if;if(pmoney20y='0'and pmoney20y_f='1')then pmoney20y_f:='0';end if;elsif(money_reg<total_money and cancel='1')thenstate<=initial_type;elsif(money_reg>=total_money) then state<=stamp_type;end if;when stamp_type => --put out the stampif(stamp_alr='0')thenacceptmo<='1';stamp<='1';stamp_alr:='1';else state<=charge_type;end if;when charge_type => --put out the chargecharge_reg:=money_reg - total_money;case charge_reg iswhen 0 => charge<="0000";when 1 => charge<="0001";when 2 => charge<="0010";when 3 => charge<="0011";when 4 => charge<="0100";when 5 => charge<="0101";when 6 => charge<="0110";when 7 => charge<="0111";when 8 => charge<="1000";when 9 => charge<="1001";when 10 => charge<="1010";when 11 => charge<="1011";when 12 => charge<="1100";when 13 => charge<="1101";when 14 => charge<="1110";when 15 => charge<="1111";when others => charge<="0000";end case;if(charge_reg>0 and charge_alr='0') thenchargegate<='1';charge_alr:='1';elsif(charge_reg=0 and charge_alr='0')thenchargegate<='0';charge_alr:='1';else state<=initial_type;end if;end case;end if;end process main;END sell;五、波形仿真1、乘客按下开始按钮,进入选站台模式,选择二号站台,按下确定键,再选择票数为2张,按下确定键,售票机钱箱关闭,投入一张两元和五元纸币(对顺序没有要求),此时钱币总额大于票价,出两张票并找零一元。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

自动售货机控制模块VHDL 程序设计及FPGA 实现
近年来,随着集成电路技术的迅猛发展,特别是可编程逻辑器件的高速发展, EDA(Electronic Design Automation,电子设计自动化)技术成为电子设计工程师的新宠。

EDA技术以计算机为工具完成数字系统的逻辑综合、布局布线和设计仿真等工作。

电路设计者只需要完成对系统功能的描述,就可以由计算机软件进行系统处理,最后得到设计结果,并且修改设计方案如同修改软件一样方便。

利用EDA工具可以极大地提高设计效率。

 利用硬件描述语言编程来表示逻辑器件及系统硬件的功能和行为,是EDA
设计方法的一个重要特征。

VHDL(Very High Speed Integrated Circuit Hardware Description Language,超高速集成电路硬件描述语言)是硬件描述语言的一种,对系统硬件的描述功能很强而语法又比较简单。

VHDL具有强大的行为描述能力,设计者可以不懂硬件的结构,只需集中精力进行电子系统的设计和性能优化;具有方便的逻辑仿真与调试功能,在设计早期就能查验系统的功能,方便地比较各种方案的可行性及其优劣。

目前,VHDL作为IEEE的工业标准硬件描述语言,得到众多EDA公司的支持,在电子工程领域已经成为事实上通用硬件描述语言。

 本文采用VHDL作为工具描述了自动售货机控制模块的逻辑控制电路,并在FPGA上实现。

该自动售货机能够根据投入硬币额度,按预定的要求在投入硬币大于规定值时送出饮料并找零。

 设计方案本文所设计的简易自动售货机可销售矿泉水,假设每瓶1.5元。

设两个投币孔,分别接收1元和5角两种硬币,两个输出口,分别输出购买的商品和找零。

假设每次只能投入一枚1元或5角硬币,投入1元5角硬币后机器自动给出一瓶矿泉水;投入2元硬币后,在给出一瓶矿泉水的同时找回一枚5。

相关文档
最新文档