第一范文网 - 专业文章范例文档资料分享平台

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

来源:用户分享 时间:2020-06-17 本文由千里清秋 分享 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

地铁自动售票机

一、设计要求

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 IS PORT(

clk:in std_logic; startselect:in std_logic; sure:in std_logic; save your forward step(s)

coin1y:in std_logic; pmoney1y:in std_logic; pmoney2y:in std_logic; pmoney5y:in std_logic; pmoney10y:in std_logic; money

pmoney20y:in std_logic; money

cancel:in std_logic; number:in std_logic_vector(3 downto 0); the tickets

platform:in std_logic_vector(3 downto 0); want to reach

moneystorage:out std_logic; acceptmo:out std_logic; stamp:out std_logic; --set the clock signal --start to select the platform --this button is to --1 yuan coin

--1 yuan paper money --2 yuan paper money --5 yuan paper money --10 yuan paper --20 yuan paper --cancel the forward step(s) --choose the number of --choose the platform you --to store the money --accept the money --stamp outgate

charge:out std_logic_vector(3 downto 0); --the mount of charge,up to 15 yuan

chargegate:out std_logic --charge outgate ); END metrosell;

ARCHITECTURE sell OF metrosell IS

type state_type is

(initial_type,selectp_type,selectnum_type,insert_type,stamp_type,charge_type); --define six types

signal state:state_type; --define a shared state BEGIN

main:process(clk,state,startselect,platform,number,coin1y,pmoney1y,pmoney2y,pmoney5y,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 type

variable selectnum_alr:std_logic; --the flag of select number type

variable stamp_alr:std_logic; --the flag of the stamp gate variable charge_alr:std_logic; --the flag of the charge gate

variable 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 money

variable pmoney2y_f:std_logic; --the flag of two yuan paper money

variable pmoney10y_f:std_logic; --the flag of ten yuan paper money

variable pmoney20y_f:std_logic; --the flag of twelve yuan paper money

variable pmoney5y_f:std_logic; --the flag of five yuan paper money

variable charge_reg:integer range 0 to 15; begin

if(rising_edge(clk)) then case state is

when initial_type => variables

univalence:=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';

--the register of charge --initialize some pmoney10y_f:='0'; pmoney20y_f:='0'; moneystorage<='0'; stamp<='0'; charge_reg:=0; charge<=\ acceptmo<='0'; chargegate<='0'; if (startselect='1') then state<=selectp_type; end if; when selectp_type =>

if(selectp_alr='0'and cancel='0') then --choose the platform if(platform=\ elsif(platform=\ elsif(platform=\ elsif(platform=\ elsif(platform=\ elsif(platform=\ elsif(platform=\ 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;

搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新经管营销基于VHDL编程FPGA的地铁自动售票机 全文阅读和word下载服务。

基于VHDL编程FPGA的地铁自动售票机 .doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/wenku/1082185.html(转载请注明文章来源)
热门推荐
Copyright © 2018-2022 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top