




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 出租车计费器的设计1 绪论1.1 EDA 技术概论 EDA技术就是以计算机为工具,设计者在EDA软件平台上,用硬件描述语言VHDL完成设计文件,然后由计算机自动地完成逻辑编译、化简、分割、综合、优化、布局、布线和仿真,直至对于特定目标芯片的适配编译、逻辑映射和编程下载等工作。EDA技术的出现,极大地提高了电路设计的效率和可操作性,减轻了设计者的劳动强度。在电子技术设计领域,可编程逻辑器件(如CPLD、FPGA)的应用,已得到广泛的普及,这些器件为数字系统的设计带来了极大的灵活性。这些器件可以通过软件编程而对其硬件结构和工作方式进行重构,从而使得硬件的设计可以如同软件设计那样方便快捷。这一切极
2、大地改变了传统的数字系统设计方法、设计过程和设计观念,促进了EDA技术的迅速发展。1.2 硬件描述语言VHDL1.2.1 VHDL简介VHDL全名Very-High-Speed Integrated Circuit HardwareDescription Language,诞生于1982年。VHDL语言是一种用于电路设计的高级语言。它在80年代的后期出现。最初是由美国国防部开发出来供美军用来提高设计的可靠性和缩减开发周期的一种使用范围较小的设计语言 。 VHDL翻译成中文就是超高速集成电路硬件描述语言,主要是应用在数字电路的设计中。目前,它在中国的应用多数是用在FPGA/CPLD/EPLD的设
3、计中。当然在一些实力较为雄厚的单位,它也被用来设计ASIC。 1.2.2 VHDL 的流程设计从系统总体要求出发,自上而下地逐步将设计的内容细化,最后完成系统硬件的整体设计。在设计的过程中,对系统自上而下分成三个层次进行设计:第一层次是行为描述。所谓行为描述,实质上就是对整个系统的数学模型的描述。一般来说,对系统进行行为描述的目的是试图在系统设计的初始阶段,通过对系统行为描述的仿真来发现设计中存在的问题。在行为描述阶段,并不真正考虑其实际的操作和算法用何种方法来实现,而是考虑系统的结构及其工作的过程是否能到达系统设计的要求。第二层次是RTL方式描述。这一层次称为寄存器传输描述(又称数据流描述)
4、。如前所述,用行为方式描述的系统结构的程序,其抽象程度高,是很难直接映射到具体逻辑元件结构的。要想得到硬件的具体实现,必须将行为方式描述的VHDL语言程序改写为RTL方式描述的VHDL语言程序。也就是说,系统采用RTL方式描述,才能导出系统的逻辑表达式,才能进行逻辑综合。第三层次是逻辑综合。即利用逻辑综合工具,将RTL方式描述的程序转换成用基本逻辑元件表示的文件(门级网络表)。此时,如果需要,可将逻辑综合的结果以逻辑原理图的方式输出。此后可对综合的结果在门电路级上进行仿真,并检查其时序关系。应用逻辑综合工具产生的门网络表,将其转换成PLD的编程码,即可利用PLD实现硬件电路的设计。由自上而下的
5、设计过程可知,从总体行为设计开始到最终的逻辑综合,每一步都要进行仿真检查,这样有利于尽早发现设计中存在的问题,从而可以大大缩短系统的设计周期。1.3 Quartus II 软件操作流程双击桌面上Quartus II 9.0,打开Quartus软件。(1) 新建VHDL文件 ,开始编写VHDL程序。(2) 保存VHDL文件,文件取名要与程序实体名要一致。(3) 创建新工程按下“保存”按纽后会出现如下提示。提示是否为此文件建立一个工程,这很重要。然后点击“是”,出现以下窗口,点“Next >”。图1.1 新建工程提示(4)器件的选择继续点“Next >”。然后选择FPGA或CPLD的有
6、关参数,这些参数都是根据目标芯片来选择的,如下图所示。图1.2 芯片选择 (5)编译编译:选择processing菜单中的start compilation命令。编译完成的提示如下,点击确定即可。 (6)仿真 这时可以进行仿真,首先要建立波形文件,点“File选项中New”,出现如下窗口:图1.3 建立波形文件 选择 “Vector waveform File”点“OK”。出现以下窗口。图1.4 建立波形文件后出现窗口 双击左边的空白处,设定输入输出信号。设定好波形后,保存波形。之后点进行仿真。(7)锁定引脚引脚锁定,如下图操作:引脚的锁定是根据不同的电路和不同功能来确定的,不是一层不变的。选
7、择Assignments菜单下的Pins命令,出现以下窗口,图1.5 引脚分配图如果是下载到实验箱上则需连续按“模式选择”按钮选择模式5,再按“系统复位”按钮。进行引脚锁定,查阅附表,分别点“location”选择引脚号。引脚锁定后再编译。如同此前进行过的。编译成功后点确定。(8)下载选择Tools菜单下的Programmer命令,然后在Program/Configure下打上钩选中,点“start”按钮开始下载,“Progress”进度条显示下载进度。成功下载后如图所示:图1.6 下载到实验箱界面下载完后就可以在实验箱查看结果。 通过上面的步骤分别下载到实验箱中和FPGA中,验证了在仿真中的
8、结果是正确的。2 课题设计2.1 出租车计费器设计内容(1)能实现计程与计费功能,计费标准为:按行驶里程收费,分为白天与黑夜。白天收费标准:起步价为6.00元,超过1公里按1元/公里计算,超过3公里多收10块钱的空车返回费用。黑夜收费标准:起步价为8.00元,超过1公里按2元/公里计算,超过3公里多收10块钱的空车返回费用。(2) 能够有对路程清零与对计费停止功能。当无乘客不需要计费时,对路程清零及对价格清零。(3) 实够实现按键控制显示路程、价格及当前车速,当车速超过4Km/h时发出警报。2.2 出租车计费器设计方框图出租车计费器是由输入信号、分频器(供蜂鸣器发生警报提供不同的频率)、路程计
9、数模块、计费模块、控制模块(控制输出显示路程、价格或当前车速)、及译码显示模块(八个七段数码管)。其总体方框图如下所示:输 入 信 号分频器测速模 块车费计数模块车行驶状 态译码显 示计程模块显 示控制蜂鸣器图2.1 总体设计方框图2.3 出租车计费器系统各功能模块及模块程序2.3.1 计程与计费模块计程与计费模块由一个时钟输入端 clk 与使能端en及复位端rst端与位选端SL2.0及显示输出端led6.0构成。其en 端为1时允许计数,rst为1时计数清零。图2.2 计程与计费模块图其仿真图如下所示:图2.3 计程与计费模块仿真图其程序如下:library ieee;use ieee.st
10、d_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity taxi is port( Clk : in std_logic; daytime : in std_logic; Rst : in std_logic; en : in std_logic; Motor : in std_logic; Display : out std_logic_vector(6 downto 0); SEG_SEL: buffer std_logic_vector(2 downto 0) ); end
11、taxi;architecture one of taxi is signal Disp_Temp : integer range 0 to 15; signal Disp_Decode: std_logic_vector(6 downto 0); signal Meter1,Meter10,Meter100,Meter1K : integer range 0 to 9; signal Money1,Money10,Money100 : integer range 0 to 9; signal Old_Money1 : integer range 0 to 9; begin process(M
12、otor) begin if(Rst='0') then Meter1<=0; Meter10<=0; Meter100<=0; Meter1K<=0; elsif(Motor'event and Motor='1') then if(Meter1=9) then Meter1<=0; if(Meter10=9) then Meter10<=0; if(Meter100=9) then Meter100<=0; if(Meter1K=9) then Meter1K<=0; else Meter1K<=
13、Meter1K+1; end if; else Meter100<=Meter100+1; end if; else Meter10<=Meter10+1; end if; else Meter1<=Meter1+1; end if; end if; end process; process(Clk) begin if en='0' then null; elsif(Rst='0') then Money1<=0; Money10<=0; Money100<=0; elsif(Clk'event and Clk=
14、9;1') then if daytime ='0' then -bai tian if(Meter1K<1) then Money100<=0; Money10<=6; Money1<=0; Old_Money1<=0; else Money1<=Meter100; Old_Money1<=Money1; if(Old_Money1=9 and Money1=0) then if(Money10=9) then Money10<=0; if(Money100=9) then Money100<=0; else Mo
15、ney100<=Money100+1; end if; else Money10<=Money10+1; end if; end if; if (Meter1K=3) then Money100<=1; Money10<=8; Money1<=0; Old_Money1<=0; if (Meter1K >2 )then Money1<=Meter100; Old_Money1<=Money1; if(Old_Money1=9 and Money1=0) then if(Money10=9) then Money10<=0; if(Mo
16、ney100=9) then Money100<=0; else Money100<=Money100+1; end if; else Money10<=Money10+1; end if; end if; end if ; end if; end if; else -hei ye if(Meter1K<1) then Money100<=0; Money10<=8; Money1<=0; Old_Money1<=0; else Money1<=Meter100; Old_Money1<=Money1; if(Old_Money1=9
17、 and Money1=0) then if(Money10=9) then Money10<=0; if(Money100=9) then Money100<=0; else Money100<=Money100+1; end if; else Money10<=Money10+1; end if; end if; end if; if (Meter1K=3) then Money100<=2; Money10<=2; Money1<=0; Old_Money1<=0; if (Meter1K>2) then Money1<=Met
18、er100; Old_Money1<=Money1; if(Old_Money1=9 and Money1=0) then if(Money10=9) then Money10<=0; if(Money100=9) then Money100<=0; else Money100<=Money100+1; end if; else Money10<=Money10+1; end if; end if; end if; end if ; end if ; end if ; end process; process(SEG_SEL) begin case (SEG_SE
19、L+1) is when "000"=>Disp_Temp<=Meter1K; when "001"=>Disp_Temp<=Meter100; when "010"=>Disp_Temp<=Meter10; when "011"=>Disp_Temp<=Meter1; when "100"=>Disp_Temp<=10; when "101"=>Disp_Temp<=Money100; when &qu
20、ot;110"=>Disp_Temp<=Money10; when "111"=>Disp_Temp<=Money1; end case; end process; process(Clk) begin if(Clk'event and Clk='1') then SEG_SEL<=SEG_SEL+1; if (SEG_SEL=9) then SEG_SEL<="000" else Display<=Disp_Decode; end if; end if; end process
21、; process(Disp_Temp) begin case Disp_Temp is when 0=>Disp_Decode<="0111111" when 1=>Disp_Decode<="0000110" when 2=>Disp_Decode<="1011011" when 3=>Disp_Decode<="1001111" when 4=>Disp_Decode<="1100110" when 5=>Disp_Deco
22、de<="1101101" when 6=>Disp_Decode<="1111101" when 7=>Disp_Decode<="0000111" when 8=>Disp_Decode<="1111111" when 9=>Disp_Decode<="1101111" when 10=>Disp_Decode<="1000000" when others=>Disp_Decode<="
23、;0000000" end case; end process; end one;2.3.2测速模块测速模块输入端由Clk及Motor端组成,Clk提供计数脉冲,通过计Motor 6秒转的圈数然后乘以10作为一分种出租车的车速,其输出端变由SEL2.0及lout76.0组成,前者用于扫描数码管的驱动,后者用于显示转速。图2.4 测速模块其仿真图如下所示:图2.5 测速模块仿真图其程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.a
24、ll;entity teltcl is port( Clk : in std_logic; Motor : in std_logic;SEL:OUT STD_LOGIC_VECTOR(2 DOWNTO 0);lout7:out std_logic_vector(6 downto 0);end teltcl;architecture one of teltcl is signal clk1hz :std_logic;-1HZ时钟信号; signal count : std_logic_vector(2 downto 0); signal clr1 :std_logic ; signal ena1
25、 :std_logic; signal load1 :std_logic; signal CQ1,CQ2,CQ3,CQ4 : std_logic_vector(3 downto 0); SIGNAL CQA :std_logic_vector(15 DOWNTO 0); SIGNAL DOUT : STD_LOGIC_VECTOR(15 DOWNTO 0); signal s:std_logic_vector(2 downto 0); signal lout4:std_logic_vector(3 downto 0); SIGNAL in3,in2,in1,in0:std_logic_vect
26、or(3 downto 0); begin process(clk) variable cnttemp : INTEGER RANGE 0 TO 999999; begin IF clk='1' AND clk'event THEN IF cnttemp=999999 THEN cnttemp:=0; ELSE IF cnttemp<500000 THEN clk1hz<='1' ELSE clk1hz<='0' END IF; cnttemp:=cnttemp+1; END IF; end if; end proces
27、s; process(Clk1hz) begin if(Clk1hz'event and Clk1hz='1') then count<=count+1; if count<6 then ena1<='1'load1<='0'clr1<='0' elsif count=6 then load1<='1'ena1<='0'clr1<='0' elsif count=7 then ena1<='0'load1&
28、lt;='0'clr1<='1' end if; end if; end process;PROCESS(CLK,ENA1) ISBEGIN IF CLR1= '1' THEN CQ1<= "0000" elsif(Motor'event and Motor='1') then IF ENA1= '1' THEN if(CQ1="1001") then CQ1<="0000" if(CQ2=9) then CQ2<=&quo
29、t;0000" if(CQ3="1001") then CQ3<="0000" if(CQ4="1001") then CQ4<="0000" else CQ4<=CQ4+1; end if; else CQ3<=CQ3+1; end if; else CQ2<=CQ2+1; end if; else CQ1<=CQ1+1; end if; end if; END IF ; CQA<=(CQ4&CQ3&CQ2&CQ1); end proce
30、ss;PROCESS ( LOAD1,CQA) ISBEGIN IF LOAD1 'EVENT AND LOAD1= '1' THEN DOUT<=CQA; END IF;END PROCESS;process (clk)beginIN3<=DOUT(15 DOWNTO 12);IN2<=DOUT(11 DOWNTO 8);IN1<=DOUT(7 DOWNTO 4);IN0<=DOUT(3 DOWNTO 0);if (clk'event and clk='1')thenif (s="111") t
31、hens<="000"else s<=s+1;end if;end if;sel<=s;end process;process (s)begincase s iswhen "000"=>lout4<="1111"when "001"=>lout4<="1111"when "010"=>lout4<=in2;when "011"=>lout4<=in1;when "100"
32、=>lout4<=in0;when "101"=>lout4<="0000"when "110"=>lout4<="1111"when "111"=>lout4<="1111"when others=>lout4<="XXXX"end case;case lout4 iswhen "0000"=>lout7<="0111111"when &quo
33、t;0001"=>lout7<="0000110"when "0010"=>lout7<="1011011"when "0011"=>lout7<="1001111"when "0100"=>lout7<="1100110"when "0101"=>lout7<="1101101"when "0110"=>lout7<
34、;="1111101"when "0111"=>lout7<="0000111"when "1000"=>lout7<="1111111"when "1001"=>lout7<="1100111"when "1010"=>lout7<="0111111"when "1111"=>lout7<="1000000"when
35、 others=>lout7<="XXXXXXX"end case;end process;end one;2.3.3报警模块报警模块输入端由Clk构成,其主要用途在于为蜂呜器提供不同频率,其输出端由spk端构成,其是一个蜂鸣器用于报警。图2.6 蜂鸣器模块其仿真图如下:图2.7 蜂鸣器模块仿真图其程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity teltcl is port( Clk
36、: in std_logic; spk : buffer std_logic);end teltcl;architecture one of teltcl is signal tone : std_logic_vector(10 downto 0); signal tone_count : std_logic_vector(10 downto 0); signal tone_index : integer range 0 to 15; signal clk10_count : std_logic_vector(17 downto 0); signal time : integer range
37、0 to 150; signal clk10 : std_logic;begin process(clk) -generate 10hz clock signal begin if(clk'event and clk='1') then clk10_count<=clk10_count+1; if(clk10_count=16#3fff#) then clk10<=not clk10; end if; END IF ; end process; process(clk10) begin if(clk10'event and clk10='1&
38、#39;) then if(time=150) then time<=0; else time<=time+1; end if; end if; end process; process(clk10) begin if(clk10'event and clk10='1') then case time is when 0=>tone_index<=3; when 1=>tone_index<=3; when 2=>tone_index<=3; when 3=>tone_index<=3; when 4=>
39、tone_index<=5; when 5=>tone_index<=5; when 6=>tone_index<=5; when 7=>tone_index<=6; when 8=>tone_index<=8; when 9=>tone_index<=8; when 10=>tone_index<=8; when 11=>tone_index<=9; when 12=>tone_index<=6; when 13=>tone_index<=8; when 14=>tone_
40、index<=5; when 15=>tone_index<=5; when 16=>tone_index<=12; when 17=>tone_index<=12; when 18=>tone_index<=12; when 19=>tone_index<=15; when 20=>tone_index<=13; when 21=>tone_index<=12; when 22=>tone_index<=10; when 23=>tone_index<=12; when 24=&
41、gt;tone_index<=9; when 25=>tone_index<=9; when 26=>tone_index<=9; when 27=>tone_index<=9; when 28=>tone_index<=9; when 29=>tone_index<=9; when 30=>tone_index<=0; when 31=>tone_index<=0; when 32=>tone_index<=9; when 33=>tone_index<=9; when 34=&
42、gt;tone_index<=9; when 35=>tone_index<=10; when 36=>tone_index<=7; when 37=>tone_index<=7; when 38=>tone_index<=6; when 39=>tone_index<=6; when 40=>tone_index<=5; when 41=>tone_index<=5; when 42=>tone_index<=5; when 43=>tone_index<=6; when 44=
43、>tone_index<=8; when 45=>tone_index<=8; when 46=>tone_index<=9; when 47=>tone_index<=9; when 48=>tone_index<=3; when 49=>tone_index<=3; when 50=>tone_index<=8; when 51=>tone_index<=8; when 52=>tone_index<=6; when 53=>tone_index<=5; when 54=
44、>tone_index<=6; when 55=>tone_index<=8; when 56=>tone_index<=5; when 57=>tone_index<=5; when 58=>tone_index<=5; when 59=>tone_index<=5; when 60=>tone_index<=5; when 61=>tone_index<=5; when 62=>tone_index<=0; when 63=>tone_index<=0; when 64=
45、>tone_index<=10; when 65=>tone_index<=10; when 66=>tone_index<=10; when 67=>tone_index<=12; when 68=>tone_index<=7; when 69=>tone_index<=7; when 70=>tone_index<=9; when 71=>tone_index<=9; when 72=>tone_index<=6; when 73=>tone_index<=8; when
46、 74=>tone_index<=5; when 75=>tone_index<=5; when 76=>tone_index<=5; when 77=>tone_index<=5; when 78=>tone_index<=5; when 79=>tone_index<=5; when 80=>tone_index<=5; when 81=>tone_index<=0; when 82=>tone_index<=0; when 83=>tone_index<=3; when
47、 84=>tone_index<=5; when 85=>tone_index<=3; when 86=>tone_index<=5; when 87=>tone_index<=5; when 88=>tone_index<=6; when 89=>tone_index<=7; when 90=>tone_index<=9; when 91=>tone_index<=6; when 92=>tone_index<=6; when 93=>tone_index<=6; when
48、 94=>tone_index<=6; when 95=>tone_index<=6; when 96=>tone_index<=6; when 97=>tone_index<=5; when 98=>tone_index<=6; when 99=>tone_index<=8; when 100=>tone_index<=8; when 101=>tone_index<=8; when 102=>tone_index<=9; when 103=>tone_index<=12;
49、 when 104=>tone_index<=12; when 105=>tone_index<=12; when 106=>tone_index<=10; when 107=>tone_index<=9; when 108=>tone_index<=9; when 109=>tone_index<=10; when 110=>tone_index<=9; when 111=>tone_index<=8; when 112=>tone_index<=8; when 113=>tone_index<=6; when 114=>tone_index<=5; when 115=>tone_index<=3; when 116=>tone_index<=3; when 117=>tone_index<=3; when 118=>tone_index<=3; when 119=>tone_index<=8; when 120
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 水墨插画风儿童故事绘本双管齐下
- 典型行政法学试题与答案汇编
- 执业医师考试各科目重难点分析试题及答案
- 中国文化自信的时代意义试题及答案
- 护理临床研究设计试题及答案分析
- 常见错误与解决方案执业医师考试试题及答案
- 护理技能提升策略执业护士考试试题及答案
- 网络文化对青少年心理的影响试题及答案
- 护理学实践能力考核试题及答案
- 护理统计学基本知识试题及答案
- 2024年广东大亚湾开发区招聘公办学校教师笔试真题
- 江苏交控笔试试题及答案
- JJF1033-2023计量标准考核规范
- 三对三篮球赛记录表
- 被执行人财产线索提供书(模板)
- HP系列培训手册
- 毕业论文-原油电脱水方法与机理的研究
- 陕西省2022年普通高中学业水平考试(真题)
- 事故池管理的有关规定
- 2021-2022学年甘肃省天水市第一中学高一下学期第二阶段考物理试题(原卷版)
- GE全球供应链的管理与实践
评论
0/150
提交评论