基于vhdl编程fpga的地铁自动售票机设计说明书_第1页
基于vhdl编程fpga的地铁自动售票机设计说明书_第2页
基于vhdl编程fpga的地铁自动售票机设计说明书_第3页
基于vhdl编程fpga的地铁自动售票机设计说明书_第4页
基于vhdl编程fpga的地铁自动售票机设计说明书_第5页
已阅读5页,还剩33页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、地铁自动售票机一、设计要求1、功能描述用于模仿地铁售票自动售票,完成地铁售票的核心控制功能。2、功能要求 售票机有两个进币孔,一个是输入硬币,识别的范围是一元硬币;一个是纸币,识别的范围是一元、两元、五元、十元、二十元。乘客可以连续多次投入钱币。乘客 一次只能选择一个出站口,购买车票时,乘客先选出站口,有六个出站口可供选择,再选择所需的票数,然后投币,投入的钱币达到或者超过所需金额时,售票机自 动出票,并找零。本次交易结束后,等待下一次交易。在选择出站口、所需票数以及在投币期间,乘客可以按取消键取消操作,钱币自动退出。二、实验分析1、 买票时,乘客按下开始键,售票机进入站台选择程序,乘客选择出

2、站口后,可以按取消键重新选择,否则售票机自动进入票数选择程序,同样这时可以按下取消键重新开始选择出站口以及票数。2、 当选择好出站口以及所需票数时,乘客可以投硬币或者用纸币,当所投的钱币总额大于或者等于票价时,售票机自动出票以及找零。期间,可以按下取消键重新开始选择,并退出所有的钱币。3、 乘客若还没选择出站口或者票数,就投币或者使用纸币,售票机会自动退出所有的钱币。4、 有六个站台可供乘客选择,每个乘客最多可以买3张票,六个站台编号为1到6,票价从2元依次递增到7。三、系统流程图四、程序源代码LIBRARY IEEE;USE IEEE.std_logic_1164.ALL;USE IEEE.

3、std_logic_arith.ALL;USE IEEE.std_logic_unsigned.ALL;ENTITY metrosell IS PORT( clk:in std_logic; -set the clock signal startselect:in std_logic; -start to select the platform sure:in std_logic; -this button is to save your forward step(s) coin1y:in std_logic; -1 yuan coin pmoney1y:in std_logic; -1 yu

4、an paper money pmoney2y:in std_logic; -2 yuan paper money pmoney5y:in std_logic; -5 yuan paper money pmoney10y:in std_logic; -10 yuan paper money pmoney20y:in std_logic; -20 yuan paper money cancel:in std_logic; -cancel the forward step(s) number:in std_logic_vector(3 downto 0); -choose the number o

5、f the tickets platform:in std_logic_vector(3 downto 0); -choose the platform you want to reach moneystorage:out std_logic; -to store the money acceptmo:out std_logic; -accept the money stamp:out std_logic; -stamp outgate charge:out std_logic_vector(3 downto 0); -the mount of charge,up to 15 yuan cha

6、rgegate: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 stateBEGINmain:process(clk,state,startselect,platform,

7、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 selec

8、tnum_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 varia

9、ble 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

10、 of five yuan paper money variable charge_reg:integer range 0 to 15; -the register of charge begin if(rising_edge(clk) then case state is when initial_type = -initialize some variables univalence:=0; selectp_alr:=0; selectnum_alr:=0; stamp_alr:=0; charge_alr:=0; money_reg:=0; total_money:=0; coin1y_

11、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) then state if(selectp_alr=0and cancel=0) then -choose the platform if(platform=0001)then univalence:=2;selectp_alr:=1;

12、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

13、univalence:=0;selectp_alr:=0; else null; end if; elsif(selectp_alr=1and cancel=1)then state=initial_type; elsif(selectp_alr=1and sure=1) then state -you can buy at most 3 tickets if(selectnum_alr=0and cancel=0)then-choose the number of tickets if(number=0001)then if(univalence=2)then total_money:=2;

14、selectnum_alr:=1; elsif(univalence=3)then total_money:=3;selectnum_alr:=1; elsif(univalence=4)then total_money:=4;selectnum_alr:=1; elsif(univalence=5)then total_money:=5;selectnum_alr:=1; elsif(univalence=6)then total_money:=6;selectnum_alr:=1; elsif(univalence=7)then total_money:=7;selectnum_alr:=

15、1; elsif(univalence=0)then total_money:=0;selectnum_alr:=0; else null; end if; end if; if(number=0010)then if(univalence=2)then total_money:=4;selectnum_alr:=1; elsif(univalence=3)then total_money:=6;selectnum_alr:=1; elsif(univalence=4)then total_money:=8;selectnum_alr:=1; elsif(univalence=5)then t

16、otal_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)then if(univalence=2)then total_money:=6;selectnum_a

17、lr:=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; elsi

18、f(univalence=0)then total_money:=0;selectnum_alr:=0; else null; end if; end if; elsif(selectnum_alr=1and cancel=1)then state=initial_type; elsif(selectnum_alr=1and sure=1) then state moneystorage=1; if(money_regtotal_money and cancel=0)then-receive the inserted money if(coin1y=1and coin1y_f=0)then m

19、oney_reg:=money_reg+1;coin1y_f:=1;end if; if(coin1y=0and coin1y_f=1)then coin1y_f:=0;end if; if(pmoney1y=1and pmoney1y_f=0)then money_reg:=money_reg+1;pmoney1y_f:=1;end if; if(pmoney1y=0and pmoney1y_f=1)then pmoney1y_f:=0;end if; if(pmoney2y=1and pmoney2y_f=0)then money_reg:=money_reg+2;pmoney2y_f:=

20、1;end if; if(pmoney2y=0and pmoney2y_f=1)then pmoney2y_f:=0;end if; if(pmoney5y=1and pmoney5y_f=0)then money_reg:=money_reg+5;pmoney5y_f:=1;end if; if(pmoney5y=0and pmoney5y_f=1)then pmoney5y_f:=0;end if; if(pmoney10y=1and pmoney10y_f=0)then money_reg:=money_reg+10;pmoney10y_f:=1; end if; if(pmoney10

21、y=0and pmoney10y_f=1)then pmoney10y_f:=0;end if; if(pmoney20y=1and pmoney20y_f=0)then money_reg:=money_reg+20;pmoney20y_f:=1; end if; if(pmoney20y=0and pmoney20y_f=1)then pmoney20y_f:=0;end if; elsif(money_regtotal_money and cancel=1)then state=total_money) then state -put out the stamp if(stamp_alr

22、=0)then acceptmo=1; stamp=1; stamp_alr:=1; else state -put out the charge charge_reg:=money_reg - total_money; case charge_reg is when 0 = charge charge charge charge charge charge charge charge charge charge charge charge charge charge charge charge charge0 and charge_alr=0) then chargegate=1; char

23、ge_alr:=1; elsif(charge_reg=0 and charge_alr=0)then chargegate=0; charge_alr:=1; else state=initial_type; end if; end case; end if; end process main;END sell;五、波形仿真1、乘客按下开始按钮,进入选站台模式,选择二号站台,按下确定键,再选择票数为2张,按下确定键,售票机钱箱关闭,投入一张两元和五元纸币(对顺序没有要求),此时钱币总额大于票价,出两张票并找零一元。之后系统进入初始化状态。具体仿真如图 1 仿真1图 1 仿真12、测试canc

24、el键,当乘客按正确的操作完成选站台时,按下取消键,再重新选择,如图 2 cancel仿真,仿真波形如下。图 2 cancel仿真3、还是测试cancel键,当乘客选择好票数时,按下cancel键,然后重新选择两张单价为七块钱的六号站台票,投入一张20元和5元,找零六元。仿真波形如图 3 cancel仿真2图 3 cancel仿真24、乘客选择五号站台,两张票,然后先后投入一元纸币,两元纸币,一元纸币,五元纸币,然后按下取消键,售票机自动放出所有的钱币。仿真如图 4 cancel仿真3。图 4 cancel仿真3六、心得体会在我的设计中,有一个moneystorage信号量用于控制储存钱币箱的

25、开与关,这个设计主要考虑到当乘客要求退币时,最好不是从售票机中取出投入的钱数,然后退还,设置了这个开关,就可以在按下取消键时,直接从储存钱币箱中退出钱币。 还有,乘客选择的站台以及票数,在售票机内部会自动将这两个信号传给出票系统,从而自动出票,以上写的程序只是让系统知道怎样收钱以及找零。 这次实验总体上来说比六人抢答器简单,但是因为这个售票机完全是自己写的,所以也不是想象中的那么简单。这也让我看出,要完全自己去做一件东西不是简单的,特别是要考虑很全面,还是要发一些时间的。 大学本科生毕业设计(论文)撰写规范本科生毕业设计(论文)是学生在毕业前提交的一份具有一定研究价值和实用价值的学术资料。它既

26、是本科学生开始从事工程设计、科学实验和科学研究的初步尝试,也是学生在教师的指导下,对所进行研究的适当表述,还是学生毕业及学位资格认定的重要依据。毕业论文撰写是本科生培养过程中的基本训练环节之一,应符合国家及各专业部门制定的有关标准,符合汉语语法规范。指导教师应加强指导,严格把关。1、论文结构及要求论文包括题目、中文摘要、外文摘要、目录、正文、参考文献、致谢和附录等几部分。1.1 题目论文题目应恰当、准确地反映论文的主要研究内容。不应超过25字,原则上不得使用标点符号,不设副标题。1.2 摘要与关键词1.2.1 摘要本科生毕业设计(论文)的摘要均要求用中、英两种文字给出,中文在前。摘要应扼要叙述

27、论文的研究目的、研究方法、研究内容和主要结果或结论,文字要精炼,具有一定的独立性和完整性,摘要一般应在300字左右。摘要中不宜使用公式、图表,不标注引用文献编号,避免将摘要写成目录式的内容介绍。1.2.2 关键词关键词是供检索用的主题词条,应采用能覆盖论文主要内容的通用技术词条(参照相应的技术术语标准),一般列35个,按词条的外延层次从大到小排列,应在摘要中出现。1.3 目录目录应独立成页,包括论文中全部章、节的标题及页码。1.4 论文正文论文正文包括绪论、论文主体及结论等部分。1.4.1 绪论绪论一般作为论文的首篇。绪论应说明选题的背景、目的和意义,国内外文献综述以及论文所要研究的主要内容。

28、文管类论文的绪论是毕业论文的开头部分,一般包括说明论文写作的目的与意义,对所研究问题的认识以及提出问题。绪论只是文章的开头,不必写章号。毕业设计(论文)绪论部分字数不多于全部论文字数的1/4。1.4.2 论文主体论文主体是论文的主要部分,要求结构合理,层次清楚,重点突出,文字简练、通顺。论文主体的内容要求参照大学本科生毕业设计(论文)的规定第五章。论文主体各章后应有一节“本章小结”。1.4.3 结论结论作为单独一章排列,但不加章号。结论是对整个论文主要成果的归纳,要突出设计(论文)的创新点,以简练的文字对论文的主要工作进行评价,一般为4001 000字。1.5 参考文献参考文献是论文不可缺少的

29、组成部分,它反映了论文的取材来源和广博程度。论文中要注重引用近期发表的与论文工作直接有关的学术期刊类文献。对理工类论文,参考文献数量一般应在15篇以上,其中学术期刊类文献不少于8篇,外文文献不少于3篇;对文科类、管理类论文,参考文献数量一般为1020篇,其中学术期刊类文献不少于8篇,外文文献不少于3篇。在论文正文中必须有参考文献的编号,参考文献的序号应按在正文中出现的顺序排列。产品说明书、各类标准、各种报纸上刊登的文章及未公开发表的研究报告(著名的内部报告如PB、AD报告及著名大公司的企业技术报告等除外)不宜做为参考文献引用。但对于工程设计类论文,各种标准、规范和手册可作为参考文献。引用网上参

30、考文献时,应注明该文献的准确网页地址,网上参考文献不包含在上述规定的文献数量之内。1.6 致谢对导师和给予指导或协助完成论文工作的组织和个人表示感谢。内容应简洁明了、实事求是,避免俗套。1.7 附录如开题报告、文献综述、外文译文及外文文献复印件、公式的推导、程序流程图、图纸、数据表格等有些不宜放在正文中,但有参考价值的内容可编入论文的附录中。2、论文书写规定2.1 论文正文字数理工类 论文正文字数不少于20 000字。文管类 论文正文字数12 00020 000字。其中汉语言文学专业不少于7 000字。外语类 论文正文字数8 00010 000个外文单词。艺术类 论文正文字数3 0005 00

31、0字。2.2 论文书写本科生毕业论文用B5纸计算机排版、编辑与双面打印输出。论文版面设置为:毕业论文B5纸、纵向、为横排、不分栏,上下页边距分别为2.5cm和2cm,左右页边距分别为2.4cm和2cm,对称页边距、左侧装订并装订线为0cm、奇偶页不同、无网格。论文正文满页为29行,每行33个字,字号为小四号宋体,每页版面字数为957个,行间距为固定值20磅。页眉。页眉应居中置于页面上部。单数页眉的文字为“章及标题”;双数页眉的文字为“大学本科生毕业设计(论文)”。页眉的文字用五号宋体,页眉文字下面为2条横线(两条横线的长度与版芯尺寸相同,线粗0.5磅)。页眉、页脚边距分别为1.8cm和1.7c

32、m。页码。页码用小五号字,居中标于页面底部。摘要、目录等文前部分的页码用罗马数字单独编排,正文以后的页码用阿拉伯数字编排。2.3 摘要中文摘要一般为300字左右,外文摘要应与中文摘要内容相同,在语法、用词和书写上应正确无误,摘要页勿需写出论文题目。中、外文摘要应各占一页,编排装订时放置正文前,并且中文在前,外文在后。2.4 目录目录应包括论文中全部章节的标题及页码,含中、外文摘要;正文章、节题目;参考文献;致谢;附录。正文章、节题目(理工类要求编写到第3级标题,即.。文科、管理类可视论文需要进行,编写到23级标题。)2.5 论文正文2.5.1 章节及各章标题论文正文分章、节撰写,每章应另起一页。各章标题要突出重点、简明扼要。字数一般在15字以内,不得使用标点符号。标题中

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论