1、长 沙 学 院课程设计说明书题目模拟停车场管理系统的设计系(部)电子与通信工程系 专业(班级) 电气1班 姓名 姚锦盛 学号 2010042120 指导教师 瞿曌、谢明华 起止日期2012-12-172012-12-28EDA技术课程设计任务书系(部):电子与通信工程系 专业:电气工程及其自动化 指导教师:谢明华课题名称模拟停车场管理系统的设计设计内容及要求实现一个模拟停车场管理系统,使用8位拨码开关表示车号,按键A按下一次表示该车进入停车场,同时数码管显示该车车号信息(3个数码管显示拨码开关对应的十进制数)及收费费率(为方便模拟,按1 元/分钟);按键B按下一次表示该车从停车场出来,该车出来
2、时用数码管显示的信息包括:3位车号、停车时间(2位小时数、2位分钟数)、3位停车费用。(数码管位数不够可采用滚动显示方式)系统提供50MHZ频率的时钟源。完成该系统的硬件和软件的设计,并制作出实物装置,调试好后并能实际运用(指导教师提供制作所需的器件),最后就课程设计本身提交一篇课程设计说明书。设计工作量1、VHDL语言程序设计;2、波形仿真;3、在实验装置上进行硬件测试,并进行演示;4、提交一份完整的课程设计说明书,包括设计原理、程序设计、程序分析、仿真分析、硬件测试、调试过程,参考文献、设计总结等。进度安排起止日期(或时间量)设计内容(或预期目标)备注第1天课题介绍,答疑,收集材料第2天设
3、计方案论证第3天进一步讨论方案, 对设计方案进行必要的修正,方案确定后开始进行VHDL语言程序设计第4天设计VHDL语言程序第59天在实验装置上进行硬件测试,对VHDL语言程序进行必要的修正,并进行演示第10天编写设计说明书教研室意见年 月 日系(部)主管领导意见年 月 日长沙学院课程设计鉴定表姓名姚锦盛学号2010042120专业电气工程及其自动化班级1设计题目模拟停车场管理系统的设计指导教师谢明华指导教师意见:评定等级: 教师签名: 日期: 答辩小组意见:评定等级:答辩小组长签名:日期:教研室意见:教研室主任签名: 日期: 系(部)意见:系主任签名:日期:说明课程设计成绩分“优秀”、“良好
4、”、“及格”、“不及格”四类;目 录1.设计思路分析51.1题目要求51.2设计思路52.系统结构设计及分析62.1分频模块72.2消抖模块92.3车牌显示模块102.4计时模块132.5费率器模块142.6滚动模块152.7译码模块183.使用说明194.心得与体会20参考文献211.设计思路分析1.1题目要求实现一个模拟停车场管理系统,使用8位拨码开关表示车号,按键A按下一次表示该车进入停车场,同时数码管显示该车车号信息(3个数码管显示拨码开关对应的十进制数)及收费费率(位方便模拟,按1元分钟);按键B按下一次表示该车从停车场出来,该车出来时用数码管显示的信息包括:3位车号、停车时间(2位
5、小时数、两位分钟数)、3位停车费用。(数码管位数不够可采用滚动显示的方式)1.2设计思路分析题目要求,宜采用“模块法”的设计方法。(模块法先用VHDL语言设计各个模块,将这些模块生成图形文件,在顶层文件中再调用这些图形。最后由原理图来实现课题要求)具体思路:当一辆车进入停车场,按键A被按下:计时器开始计时,同时把该车的车牌号和费率送入数码管显示(3个数码管显示拨码开关对应的十进制数:采用BCD码转换的方法;费率显示采用输入设置,可以通过按键+1的方式设置从199的费率)。当车驶出停车场时,按键被按下,此时计时器停止计时,并把计时时间送入数码管显示(2位小时数、两位分钟数),同时显示车牌号信息及
6、停车费用(三位显示:停车费用停车时间费率)。由于数码管位数不够采用滚动显示的方式。2.系统结构设计及分析本系统主要包括以下七个模块:分频模块fpq,车牌BCD转换模块chepai,消抖模块xiaodou,计时模块jishi,费率模块feilvqi,滚动模块gundong,译码器模块ymq。先通过VHDL文本生成这些模块,再在顶层文件中调用这些模块。系统的主程序流程图如图1所示。LIBRARY ieee;USE ieee.std_logic_1164.ALL;USE ieee.std_logic_arith.All;USE ieee.STD_LOGIC_UNSIGNED.ALL;-*实体定义*E
7、NTITY chepai ISPORT(-clk: INSTD_LOGIC;-时钟输入 key : in std_logic_vector(7 downto 0);-键入 - l: outSTD_LOGIC_VECTOR(7 downto 0);-输出数码管位选 chep : outSTD_LOGIC_VECTOR(11 downto 0)-数码管段码);END chepai ;-*构造体定义*ARCHITECTURE an OF chepai ISsignal clock : std_logic;-分频后时钟signal p : integer range 0 to 255;-显示数据寄存器
8、signal b0,b1,b2 : integer range 0 to 9;-显示数位寄存器,b0表示个位,b1表示十位,b2表p smg4:=0000;-0 -gfedcba 共阳WHEN 1 = smg4:=0001;-1 图1 系统的主程序流程图系统的顶层文件,即为本系统的总原理图,如图2所示。图2 系统总原理图 2.1分频模块该模块对实验箱上的50MHz时钟进行分频,分成所需要的几种不同频率的时钟。分频的原理为:对50MHz时钟每来一个上升沿计一次数,当计数到一定值的时候,计数值清零并且让输出电平取反,根据计数值的不同可以得到不同的输出频率。在本设计中分频出0.1HZ,1HZ,100
9、Hz,200Hz,500Hz的频率,以供不同的需要。 图3 分频模块分频模块源程序: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fpq isport(clk:in std_logic; FP500HZout,FP200HZout,FP100HZout,FP1HZout,FP01HZout:out std_logic);end entity;architecture one of fpq issignal clkjs1:std_logic;signal clkjs2:std_lo
10、gic;signal clkjs3:std_logic;signal clkjs4:std_logic;signal clkjs5:std_logic;signal cnq1:integer range 5000000 downto 0;signal cnq2:integer range 5000000 downto 0;signal cnq3:integer range 5000000 downto 0;signal cnq4:integer range 5000000 downto 0;signal cnq5:integer range 50000000 downto 0;beginmk1
11、: process(clk) beginif clkevent and clk=1 thenif cnq5=2500000 thencnq5=cnq5+1;elsecnq5=0;clkjs5=not(clkjs5); end if;end if;FP01HZout=clkjs5;end process;mk2:process(clk)beginif clkevent and clk=1 thenif cnq1=500 then cnq1=cnq1+1; else cnq1=0;clkjs1=not(clkjs1);end if;end if;FP500HZout=clkjs1;end proc
12、ess;mk3:process(clk)beginif clkevent and clk=1 thenif cnq2=12500000 then cnq2=cnq2+1;cnq2=cnq2+1;elsecnq2=0;clkjs2=not(clkjs2);end if;end if;FP200Hzout=clkjs2;end process;mk4:process(clk)beginif clkevent and clk=1 thenif cnq32500 thencnq3=cnq3+1;elsecnq3=0;clkjs3=not(clkjs3);end if;end if;FP100HZout
13、=clkjs3;end process;mk5:process(clk)beginif clkevent and clk=1thenif cnq4250000000 then cnq4=cnq4+1;elsecnq4=0;clkjs4=not(clkjs4);end if;end if;FP1HZout15 then dout=1; else dout=0; end if; temp:=temp+1; end if; end process; end arc; 2.3车牌显示模块用8位拨码开关表示车号,拨码开关对应的8位二进制通过BCD转换为12位BCD码。 图5.拨码开关BCD转换模块 LI
14、BRARY ieee;USE ieee.std_logic_1164.ALL;USE ieee.std_logic_arith.All;USE ieee.STD_LOGIC_UNSIGNED.ALL;-*实体定义*ENTITY chepai ISPORT(-clk: INSTD_LOGIC;-时钟输入 key : in std_logic_vector(7 downto 0);-键入 - l: outSTD_LOGIC_VECTOR(7 downto 0);-输出数码管位选 chep : outSTD_LOGIC_VECTOR(11 downto 0)-数码管段码);END chepai ;-
15、*构造体定义*ARCHITECTURE an OF chepai ISsignal clock : std_logic;-分频后时钟signal p : integer range 0 to 255;-显示数据寄存器signal b0,b1,b2 : integer range 0 to 9;-显示数位寄存器,b0表示个位,b1表示十位,b2表示百位signal cnt : integer range 0 to 3:=0;-数码管位选扫描程序beginp smg4:=0000;-0 -gfedcba 共阳WHEN 1 = smg4:=0001;-1WHEN 2 = smg4:=0010;-2W
16、HEN 3 = smg4:=0011;-3WHEN 4 = smg4:=0100;-4WHEN 5 = smg4:=0101;-5WHEN 6 = smg4:=0110;-6WHEN 7 = smg4:=0111;-7WHEN 8 = smg4:=1000;-8WHEN 9 = smg4:=1001;-9when others=null; END CASE; RETURN smg4; END b_to_s4;begincase p is when 0|10|20|30|40|50|60|70|80|90|100|110|120|130|140|150|160|170|180|190|200|2
17、10|220|230|240|250=b0b0b0b0b0b0b0b0b0b0end case;case p iswhen 0|1|2|3|4|5|6|7|8|9|100|101|102|103|104|105|106|107|108|109|200|201|202|203|204|205|206|207|208|209=b1b1b1b1b1b1b1b1b1b1-b0=10;end case;if p100 then b2=100 and p200 thenb2=200 thenb2=2;end if;chep(3 downto 0)=b_to_s4(b0);chep(7 downto 4)=
18、b_to_s4(b1);chep(11 downto 8)=b_to_s4(b2);end process;end an;2.4计时模块当A键按下时,计时器开始计时,B键按下时,计时器停止计时,clk为计时脉冲,来一个上升沿,计数器加1,reset为总复位信号。计时模块程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity jishi isport(A,B,reset:in std_logic; clk_minhz:in std_logic; data:out std_logic_ve
19、ctor(15 downto 0);end;architecture one of jishi issignal data1:std_logic_vector(15 downto 0);signal c:std_logic;beginprocess(clk_minhz,reset,A,B)beginif reset=1 thendata1(15 downto 0)=0000000000000000;elseif(Aevent and A=1)then c=1;end if;if B=1 thenc=0;end if;if c=1 thenif clk_minhzevent and clk_mi
20、nhz=1 thenif data1(3 downto 0)=1001 then data1(3 downto 0)=0000;if data1(7 downto 4)=0101then data1(15 downto 8)=data1(15 downto 8)+1; data1(7 downto 4)=0000; else data1(7 downto 4)=data1(7 downto 4)+1;end if;else data1(3 downto 0)=data1(3 downto 0)+1;end if;end if;elsif c=0 thendata(15 downto 0)=da
21、ta1(15 downto 0);end if;end if;end process;end;2.5费率器模块初值为0,当费率在0-99范围内时,费率按键每按一次,费率加1。 图7.费率器波形仿真图 8.费率器模块图形文件费率器模块源程序: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity feilvqi is port(reset:in std_logic; clk_minhz:in std_logic; feilv:out std_logic_vector(7 downto 0)
22、);end feilvqi;architecture one of feilvqi issignal feilv1:std_logic_vector(7 downto 0);-signal c:std_logic;beginprocess(reset,clk_minhz)beginif reset=1then feilv1=00000000;elsif clk_minhzevent and clk_minhz=1thenif feilv1(3 downto 0)=1001then feilv1(3 downto 0)=0000;if feilv1(7 downto 4)=1001thenfei
23、lv1(7 downto 4)=0000;else feilv1(7 downto 4)=feilv1(7 downto 4)+1;end if;else feilv1 (3 downto 0)=feilv1(3 downto 0)+1;end if;end if;feilv=feilv1;end process;end;2.6滚动模块滚动显示模块,当C=1时不滚动,但当C=0时滚动显示车牌、停车时间、及停车中费用。y3.0输出到译码器,sel为位选信号。 图9 滚动模块图形文件library ieee;use ieee.std_logic_1164.all;use ieee.std_logi
24、c_unsigned.all;use ieee.std_logic_arith.all;entity gundong isport (A,B:in std_logic; data:in std_logic_vector(15 downto 0); chep:in std_logic_vector(11 downto 0); feilv:in std_logic_vector(7 downto 0); clk_200HZ,clk_1HZ: in std_logic; sel:out std_logic_vector(7 downto 0); y:out std_logic_vector(3 do
25、wnto 0); end;architecture body_chooser of gundong is signal c:std_logic;signal count:std_logic_vector(2 downto 0);signal cnt: std_logic_vector(3 downto 0);begin-process(clk_200hz)-begin process (A,B)beginif (Aevent and A=1) then c=1;end if;if b=1 then c=0;end if;end process;process(clk_200HZ)beginif
26、(clk_200Hzevent and clk_200HZ=1)thenif count111 thencount=count+1; else count=000;end if;end if;end process;process(clk_1HZ)beginif clk_1HZevent and clk_1HZ=1 THENIF cnt1100 then cnt=cnt+1; else cnty=0001;sely=data(11 downto 8);sely=data(7 downto 4);sely=data(3 downto 0);sely=1010;sely=chep(3 downto
27、 0);sely=chep(7 downto 4);sely=chep(11 downto 8);selnull;end case;elsif cnt=0000 thencase count iswhen 000=y=chep(11 downto 8);sely=chep(7 downto 4);sely=chep(3 downto 0);sely=data(15 downto 12);sely=data(11 downto 8);sely=data(7 downto 4);sely=data(3 downto 0);sely=0000;selnull;end case;elsif cnt=0
28、001 thencase count iswhen000=y=feilv(3 downto 0);sely=feilv(7 downto 4);selnull;end case;elsif cnt=0010 thenelsif cnt=0011 then elsif cnt=0100 then elsif cnt=0101 then elsif cnt=0110 then elsif cnt=0111 then elsif cnt=1000 then elsif cnt=1001 then elsif cnt=1010 then elsif cnt=1011 then elsif cnt=1100 thencase count is when000=y=1010;sely=chep(11 downto 8);sely=chep(7 downto 4);sely=chep(3 downto 0);sely=1010;sely=data(15 downto 12);sel=00000100