EDA课程设计简易出租车计价器设计_第1页
EDA课程设计简易出租车计价器设计_第2页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

1、封面作者:PanHongliangEDA课程设计RTX于2012/2/22简易出租车计价器设计要求:计价器按1.2元/公里计费,超过10公里后,则按1.8元/公里收费。 起步价6元(3公里),超过3公里后,计价累加0.6元,10公里内以后每过0.5公里累加0.6元。过10公里后,计价累加0.9元,以后每过0.5公里累加0.9元。公里数4位数字显示,精确到0.1公里。 出租车计价4位数字显示,精确到0.1元。 即:二 硬件部分:仅供个人学习(1)硬件环境:东 南 大 学 SE-5 型 EDA 实 验 箱, 其 中 核 心 元 件 是Altera公 司 的EPF10K10LC84-4 ):三软件部

2、分:(1)软件环境: Altera公司的MAX+plusII(2)程序源代码:1.顶层设计 :2.各元件源代码:元件kms2money-kms2money.vhdlibrary ieee。use ieee.std_logic_1164.alluse ieee.std_logic_unsigned.a。-0.1 公里表示为 1,0.1 元表示为 1entity kms2money isport( rst,clk,enf,dispclk :in std_logic。data4:out std_logic_vector(3 downto 0)。ctl8 :out std_logic_vector(7

3、 downto 0)。-data4 :按 dispclk 的上升沿周期性的依次输出 kms3,kms2,kms1,kms0,mon3,mon2,mon1,mon0-Ctl8:分别为控制动态扫描显示的8 个 LED 的使能端,高电平使能end kms2money。architecture art_kms2money of kms2money issignal kms3,kms2,kms1,kms0:std_logic_vector(3 downto 0)。-公里百位 ,十位,个位,十分位signal mon3,mon2,mon1,mon0:std_logic_vector(3 downto 0)

4、。-金额百位 ,十位,个位,十分位begindynctl:process(dispclk,kms3,kms2,kms1,kms0,mon3,mon2,mon1,mon0) -动态显示-dispclk 上升沿依次来临时 data4 依次为 kms3,kms2,kms1,kms0,mon3,mon2,mon1,mon0,周而复始variabletimes:std_logic_vector(2 downto 0)。-3 位可表征 8 种状态,非 0且非1除外beginif dispclkevent and dispclk=1 then times:=times+1。case times iswhen

5、 000= data4=kms3。ctl8data4v=kms2。ctl8v=01000000。-使左起第2 位 LEDwhen 010=data4v=kms1。ctl8v=00100000。-使能左起第3 位 LEDwhen 011=data4v=kms0。ctl8v=00010000。-使能左起第4 位 LEDwhen 100=data4v=mon3。ctl8v=00001000。-使能左起第5 位 LEDwhen 101=data4v=mon2。ctl8v=00000100。-使能左起第6 位 LEDwhen 110=data4v=mon1。ctl8v=00000010。-使能左起第7

6、位 LEDwhen 111=data4v=mon0。ctl8v=00000001。-使能左起第8 位 LEDwhen others=data4v=ZZZZ。ctl8v=00000000。-无效为高阻都不选中end case。end if。end process。kmsdisp:process(rst,clk)-clk 每来一次上升沿认为公里数加 0.1 公里,即加 1beginif rst=1 then kms3v=0000。kms2v=0000。kmslv=OOOO。kmsOv=OOOO。-初始数据elsif clkevent and clk=1 thenif enf=1 thenif km

7、s0=1001 then-按十进制相加规律加 1kms0v=0000。if kms1=1001 thenkms1v=0000。if kms2=1001 thenkms2v=0000。ifkms3=1001thenkms3v=0000。else kms3v=kms3+1。end if。elsekms2v=kms2+1。end if。else kms1v=kms1+1。end if。else kms0v=kms0+1。end if。end if。end if。end process。mondisp:process(rst,clk)variable kms: std_logic_vector(15

8、downto 0)。-公里数的十六进制值或二进制值variable times:std_logic_vector(2 downto 0)。-记录 clk 上升沿的次数,即有几 个 0.1公里beginif rst=1themnon3=0000 。 mon2=0000 。 mon1=0110 。 mon00) 。times:=000 。elsif clkevent and clk=1 thenif enf=1 then times:=times+1。if times=1 thenkms:=kms+5。-kms 可能为 0,5,10,.,6,65,(5 的倍数)-kms+1(0.1 公里)与 km

9、s+5 在价格的角度上看是等价的-XXX.1-XXX.5 公里均按 XXX.5 公里看待, XXX.6-XXX.9 公里均按 (XXX.9+0.1) 看待Ifkms=30 then mon3=0000。mon2=0000。mon1=0110。mon0=0000。-不超过 3 公里,收起步价 6.0 元elsif kms3 then-按十进制相加规律加6XXX9 加 6 后为 YZW0-YZW5then mon3=0000。mon3=mon3+1。mon0=mon0-4。-XXX4-if mon1=1001 thenmon1=0000。if mon2=1001 thenmon2=0000。if

10、mon3=1001elseend if。else mon2=mon2+1。endif。else mon1=mon1+1。end if。else mon00 then-按十进制相加规律加mon0=mon0-1。-XXX1-if mon1=1001 then mon1=0000。if mon2=1001 thenmon2=0000。if mon3=1001 elseend if。else mon2=mon2+1。endif。else mon1=mon1+1。end if。else mon0=mon0+9。-XXX0 加 9 后 为end if。end if。elsif times=5 then t

11、imes:=000。-每计数 5 次 elk 就重新计数以便下次”循环使用-times=0,2,3,4 时参数不变 ,而只在 times=1 时一笔带过,被包含了 .times=0 与 times=5 是等效的end if。end if。end if。end process。end art_kms2money。3.元件seg7bcd-seg7bcd.vhd library ieee。use ieee.std_logic_1164.allentity seg7BCD isport( turn_on:in std_logic。x:in std_logic_vector(3 downto 0)。y:

12、out std_logic_vector(6 downto 0)。-声明:共阴极 7 段显示加 0.9 元9XXX9 加 9 后为 YZW0-YZW8then mon3=0000。mon3yyyyyyyyyyy=ZZZZZZZ。-end case。else y=0000000。-熄灭end if。end process。end art_seg7BCD。3.仿真结果4.管脚绑定PortNumName +LedEN7.0LedEN780LedEN681LedEN583LedEN43LedEN372LedEN273无效LedEN178LedENO79+g2a6.Og2a66gg2a57fg2a48e

13、g2a39dg2a210cg2a111bg2a016a+i nputCLK1CP1dispCLK43CP2RST28K1nPause29K25.下载程序本程序十分简勿,仅供交流与学习.3RTX创建于2012-2-22,- The end提示:EPF10K10LC84-4不属于Fastest Speed Grades版权申明本文部分内容,包括文字、图片、以及设计等在网上搜集整理。版权为潘宏亮个人所有This article includes some parts, including text,pictures, and desig n. Copyright is Pan Hon glia ng

14、s pers onalown ership.用户可将本文的内容或服务用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯本网站及相关权利人的合法权利。除此以外,将本文任何内容或服务用于其他用途时,须征得本人及相关权 利人的书面许可,并支付报酬。Users may use the contents or services of this article for personal study, research or appreciati on, and other non-commercial ornon-profit purposes,

15、but at the same time, they shall abide by theprovisions of copyright law and other releva nt laws, and shall notinfringe upon the legitimate rights of this website and its releva ntobligees. In addition, when any content or service of this article is usedfor other purposes, written permission and remun erati on shall be obtained from the pers on concerned and the releva nt obligee.转载或引用本文内容必须是以新闻性或资料性公共免费信息为 使用目的的合理、善意引用,不得对本文内容原意进行曲解、修 改,并自负版权等法律责任。Reproducti on or quotatio n of the content of thisarticle mus

温馨提示

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

评论

0/150

提交评论