1、时间输出计费输出里程输出秒脉冲输入里程脉冲输入计价开始控制图1.总体设计图时间模块2.2.2 判断模块判断模块主要通过对秒脉冲和里程脉冲进行计数,判断出租车是否停下,然后输出片选信号,选择时间计费还是里程计费。判断模块的模块图如图2所示:判断模块stasclklclkdge图2.判断模块2.2.3 时间模块时间模块是当出租车停下时,对秒脉冲进行计数,从而计算出出租车停下的累积时间,并输出累积时间和计费脉冲。时间模块的模块图如图3所示:时间t_count图3.时间模块2.2.4 里程模块里程模块是当出租车行驶的时候,对里程脉冲进行计数,从而算出出租车所行驶的里程,通过对单双程的控制进行不同的计费
2、标准,最后输出行驶里程和计费脉冲。里程模块的模块图如图4所示:里程d_count图4.里程模块doub2.2.5 计费模块计费图5.计费模块计费模块通过对里程计费脉冲和时间计费脉冲分别进行计数,将其换算成价钱并对进行价钱输出。计费模块的模块图如图5所示:3. 仿真结果分析3.1 判断模块的仿真判断模块的仿真结果如图6所示:图6 判断模块的仿真结果3.2 时间模块的仿真时间模块的仿真结果如图7所示:图7 时间模块的仿真结果3.3 里程模块的仿真里程模块的仿真结果如图8所示:图8 里程模块的仿真结果3.4 计费模块的仿真计费模块的仿真结果如图9所示:图9 计费模块的仿真结果 3.5元件例化后的仿真
3、元件例化后的仿真结果如图10所示:图10 元件例化后的仿真结果6.模块的引脚锁定图11 模块的引脚锁定引脚锁定图如图11所示:4. 设计总结在这次对出租车计价器的课程设计实习中,我们充分的应用了所学的知识,通过去图书馆查阅相关资料和上网搜索相关知识,我们颇有收获。由于这次设计比往常设计要复杂,如果将所有功能设计到一个模块中,对于设计和编程都有不小的困难,所以最后我们采用模块化设计,将某些功能设计成一个模块,最后用元件例化将各个模块连接起来,形成一个完整的系统,这种设计方法不仅降低了编程难度,而且使我们的设计更有条理。通过这次设计,我们对模块化设计有了更深的了解。在这次设计中,我们也遇到了许多困
4、难。有些设计虽然在逻辑上成立,但FPGA的硬件结构不能实现这种设计,比如多值驱动问题,上升下降沿问题,像我在设计计费模块的时候,预想的是时间计费脉冲和里程计费脉冲共同来驱动计费计数器,实现计费功能,这种设计很简单,但这种设计会报错。最后只能时间、里程分别计费,然后将费用分别相加,这种设计虽然有点复杂,但并没有报错,而且仿真结果正确。通过这次设计我们更加了解了FPGA的硬件结构,以后设计的时候要注意使用能实现的设计方式。这次设计让我们更加了解了EDA的设计方法,熟悉了模块化的设计思路,对于以后的设计很有帮助。总之,这次设计很有意义。参考文献1 潘松,黄继业. EDA技术使用教程. 科学出版社,2
5、010.62 刘江海. EDA技术课程设计. 华中科技大学出版社,2009.5附录参考程序:1.判断模块library ieee;use ieee.std_logic_1164.all;-entity judge isport(sclk,sta,lclk: in std_logic; dge: out std_logic);end;architecture beh of judge isbeginprocess(sta,lclk,sclk)variable a: integer range 0 to 64;if sta=1 then if lclkevent and lclk= a:=a+1;
6、 end if; if sclkevent and sclk= if a=0 then dge=0;-shijian process else -licheng process end if; if sclk= a:=0;else dgeZend if;end process;2.时间模块entity time_count isport(sta,sclk,dge: t_count: out std_logic; minge: out integer range 0 to 10; minshi: out integer range 0 to 10);architecture beh of tim
7、e_count isprocess(sta,sclk,dge)variable count: integer range 0 to 60;variable ge: integer range 0 to 10;variable shi:variable t_c: std_logic;if dge= count:=count+1; if count=1 then t_c: if count=60 then count: ge:=ge+1; if ge=10 then ge: shi:=shi+1; if shi=10 then shi: end if; end if; ge: shi: t_c:m
8、inge=ge;minshi=shi;t_count per150-+1-1.50yuan/km- per100-entity distance_count isport( sta,lclk,doub,dge: kmfen,kmge,kmshi: d_count:architecture beh of distance_count isprocess(sta,lclk,doub,dge)variable fen,ge,shi: integer range 0 to 150;variable ct:variable d_c: ct:=ct+1; if doub= and shi=2 then -
9、single and licheng=20km if ct=1 then d_c: if ct=100 then ct: elsif ge=3 or shi/=0 then -double or licheng3 if ct=150 then else ct: if count=150 then fen:=fen+1; if fen=10 then fen: if ge=10 then ge: if shi=10 then shi: end if; fen: d_c:kmfen=fen;kmgekmshid_count=d_c;4.计费模块entity price_count isport(s
10、ta,t_count,d_count: mjiao,mge,mshi,mbai:architecture beh of price_count issignal t_ge,t_shi,t_bai: integer range 0 to 10;signal d_ge,d_shi,d_bai:process(sta,t_count)variable tshi,tbai:variable tge: integer range 0 to 10:=8; if t_countevent and t_count= tge:=tge+1; if tge=10 then tge: tshi:=tshi+1; i
11、f tshi=10 then tshi: tbai:=tbai+1; if tbai=10 then tbai: tge: tshi: tbai:t_ge=tge;t_shi=tshi;t_bai=tbai;process(sta,d_count)variable djiao:variable dge,dshi,dbai: if d_countevent and d_count= djiao:=djiao+1; if djiao=10 then djiao: dge:=dge+1; if dge=10 then dge: dshi:=dshi+1; if dshi=10 then dshi:
12、dbai:=dbai+1; if dbai=10 then dbai: djiao: dge: dshi: dbai:mjiao=djiao;d_ge=dge;d_shi=dshi;d_bai=10 then ge:=ge-10; cge:=1; else=d_shi+t_shi+cge; if shi shi:=shi-10; cshi: else bai:=d_bai+t_bai+cshi; if bai bai:=bai-10; cbai:mgemshimbaista,sclk=sclk,lclk=lclk,dge=w); U2: time_count port map(sta=sclk,dge=w,t_count=x,minge=time_ge,minshi=time_shi); U3:distance_count port map(sta=sta,doub=doub,lclk=d_count=y,kmfen=dis_fen,kmge=dis_ge,kmshi=dis_shi); U4: price_count port map(sta=sta,t_count=x,d_count=y,mjiao=pri_jiao,mge=pri_ge,mshi=pri_shi,mbai=pri_bai);- 18 -
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2