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

千里清秋 分享 2020-06-17 下载文档

地铁自动售票机

一、设计要求

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;


基于VHDL编程FPGA的地铁自动售票机 .doc 将本文的Word文档下载到电脑

下一篇:九年级上学期班主任工作计划10篇

相关推荐
相关阅读
本类排行
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 7 元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xxxxxx QQ:xxxxxx