基于VHDL语言的出租车计价器的设计Word文件下载.doc
《基于VHDL语言的出租车计价器的设计Word文件下载.doc》由会员分享,可在线阅读,更多相关《基于VHDL语言的出租车计价器的设计Word文件下载.doc(18页珍藏版)》请在冰点文库上搜索。
![基于VHDL语言的出租车计价器的设计Word文件下载.doc](https://file1.bingdoc.com/fileroot1/2023-5/3/9d913d55-d209-4f06-bcf3-ab2832713cda/9d913d55-d209-4f06-bcf3-ab2832713cda1.gif)
时间输出
计费输出
里程输出
秒脉冲输入
里程脉冲输入
计价开始控制
图1.总体设计图
时间模块
2.2.2判断模块
判断模块主要通过对秒脉冲和里程脉冲进行计数,判断出租车是否停下,然后输出片选信号,选择时间计费还是里程计费。
判断模块的模块图如图2所示:
判断
模块
sta
sclk
lclk
dge
图2.判断模块
2.2.3时间模块
时间模块是当出租车停下时,对秒脉冲进行计数,从而计算出出租车停下的累积时间,并输出累积时间和计费脉冲。
时间模块的模块图如图3所示:
时间
t_count
图3.时间模块
2.2.4里程模块
里程模块是当出租车行驶的时候,对里程脉冲进行计数,从而算出出租车所行驶的里程,通过对单双程的控制进行不同的计费标准,最后输出行驶里程和计费脉冲。
里程模块的模块图如图4所示:
里程
d_count
图4.里程模块
doub
2.2.5计费模块
计费
图5.计费模块
计费模块通过对里程计费脉冲和时间计费脉冲分别进行计数,将其换算成价钱并对进行价钱输出。
计费模块的模块图如图5所示:
3.仿真结果分析
3.1判断模块的仿真
判断模块的仿真结果如图6所示:
图6判断模块的仿真结果
3.2时间模块的仿真
时间模块的仿真结果如图7所示:
图7时间模块的仿真结果
3.3里程模块的仿真
里程模块的仿真结果如图8所示:
图8里程模块的仿真结果
3.4计费模块的仿真
计费模块的仿真结果如图9所示:
图9计费模块的仿真结果
3.5元件例化后的仿真
元件例化后的仿真结果如图10所示:
图10元件例化后的仿真结果
6.模块的引脚锁定
图11模块的引脚锁定
引脚锁定图如图11所示:
4.设计总结
在这次对出租车计价器的课程设计实习中,我们充分的应用了所学的知识,通过去图书馆查阅相关资料和上网搜索相关知识,我们颇有收获。
由于这次设计比往常设计要复杂,如果将所有功能设计到一个模块中,对于设计和编程都有不小的困难,所以最后我们采用模块化设计,将某些功能设计成一个模块,最后用元件例化将各个模块连接起来,形成一个完整的系统,这种设计方法不仅降低了编程难度,而且使我们的设计更有条理。
通过这次设计,我们对模块化设计有了更深的了解。
在这次设计中,我们也遇到了许多困难。
有些设计虽然在逻辑上成立,但FPGA的硬件结构不能实现这种设计,比如多值驱动问题,上升下降沿问题,像我在设计计费模块的时候,预想的是时间计费脉冲和里程计费脉冲共同来驱动计费计数器,实现计费功能,这种设计很简单,但这种设计会报错。
最后只能时间、里程分别计费,然后将费用分别相加,这种设计虽然有点复杂,但并没有报错,而且仿真结果正确。
通过这次设计我们更加了解了FPGA的硬件结构,以后设计的时候要注意使用能实现的设计方式。
这次设计让我们更加了解了EDA的设计方法,熟悉了模块化的设计思路,对于以后的设计很有帮助。
总之,这次设计很有意义。
参考文献
[1]潘松,黄继业.《EDA技术使用教程》.科学出版社,2010.6
[2]刘江海.《EDA技术课程设计》.华中科技大学出版社,2009.5
附录
参考程序:
1.判断模块
libraryieee;
useieee.std_logic_1164.all;
--
entityjudgeis
port(sclk,sta,lclk:
instd_logic;
dge:
outstd_logic);
end;
architecturebehofjudgeis
begin
process(sta,lclk,sclk)
variablea:
integerrange0to64;
ifsta='
1'
then
iflclk'
eventandlclk='
a:
=a+1;
endif;
ifsclk'
eventandsclk='
ifa=0then
dge<
='
0'
;
--shijianprocess
else
--lichengprocess
endif;
ifsclk='
a:
=0;
else
dge<
Z'
endif;
endprocess;
2.时间模块
entitytime_countis
port(sta,sclk,dge:
t_count:
outstd_logic;
minge:
outintegerrange0to10;
minshi:
outintegerrange0to10);
architecturebehoftime_countis
process(sta,sclk,dge)
variablecount:
integerrange0to60;
variablege:
integerrange0to10;
variableshi:
variablet_c:
std_logic;
ifdge='
count:
=count+1;
ifcount=1then
t_c:
ifcount=60then
count:
ge:
=ge+1;
ifge=10then
ge:
shi:
=shi+1;
ifshi=10then
shi:
endif;
endif;
ge:
shi:
t_c:
minge<
=ge;
minshi<
=shi;
t_count<
=t_c;
3.里程模块
--1500round/km
--1.00yuan/km->
per150->
+1
--1.50yuan/km->
per100->
entitydistance_countis
port(sta,lclk,doub,dge:
kmfen,kmge,kmshi:
d_count:
architecturebehofdistance_countis
process(sta,lclk,doub,dge)
variablefen,ge,shi:
integerrange0to150;
variablect:
variabled_c:
ct:
=ct+1;
ifdoub='
andshi>
=2then--singleandlicheng>
=20km
ifct=1then
d_c:
ifct=100then
ct:
elsifge>
=3orshi/=0then--doubleorlicheng<
=20kmandkm>
3
ifct=150then
else
ct:
ifcount=150then
fen:
=fen+1;
iffen=10then
fen:
ifge=10then
ge:
ifshi=10then
shi:
endif;
fen:
d_c:
kmfen<
=fen;
kmge<
kmshi<
d_count<
=d_c;
4.计费模块
entityprice_countis
port(sta,t_count,d_count:
mjiao,mge,mshi,mbai:
architecturebehofprice_countis
signalt_ge,t_shi,t_bai:
integerrange0to10;
signald_ge,d_shi,d_bai:
process(sta,t_count)
variabletshi,tbai:
variabletge:
integerrange0to10:
=8;
ift_count'
eventandt_count='
tge:
=tge+1;
iftge=10then
tge:
tshi:
=tshi+1;
iftshi=10then
tshi:
tbai:
=tbai+1;
iftbai=10then
tbai:
tge:
tshi:
tbai:
t_ge<
=tge;
t_shi<
=tshi;
t_bai<
=tbai;
process(sta,d_count)
variabledjiao:
variabledge,dshi,dbai:
ifd_count'
eventandd_count='
djiao:
=djiao+1;
ifdjiao=10then
djiao:
dge:
=dge+1;
ifdge=10then
dge:
dshi:
=dshi+1;
ifdshi=10then
dshi:
dbai:
=dbai+1;
ifdbai=10then
dbai:
djiao:
dge:
dshi:
dbai:
mjiao<
=djiao;
d_ge<
=dge;
d_shi<
=dshi;
d_bai<
=dbai;
process(d_ge,d_shi,d_bai,t_ge,t_shi,t_bai)
variablecge,cshi,cbai:
integerrange0to1;
variablege,shi,bai:
integerrange0to20;
=d_ge+t_ge;
ifge>
=10then
ge:
=ge-10;
cge:
=1;
else
=d_shi+t_shi+cge;
ifshi>
shi:
=shi-10;
cshi:
else
bai:
=d_bai+t_bai+cshi;
ifbai>
bai:
=bai-10;
cbai:
mge<
mshi<
mbai<
=bai;
5.元件例化
entitycompis
port(sclk,lclk,sta,doub:
time_ge,time_shi:
pri_jiao,pri_ge,pri_shi,pri_bai:
dis_fen,dis_ge,dis_shi:
architecturebehofcompis
componentjudgeis
endcomponent;
componenttime_countis
componentdistance_countis
componentprice_countis
signalw,x,y:
U1:
judgeportmap(sta=>
sta,sclk=>
sclk,lclk=>
lclk,dge=>
w);
U2:
time_countportmap(sta=>
sclk,dge=>
w,
t_count=>
x,minge=>
time_ge,minshi=>
time_shi);
U3:
distance_countportmap(sta=>
sta,doub=>
doub,lclk=>
d_count=>
y,kmfen=>
dis_fen,kmge=>
dis_ge,kmshi=>
dis_shi);
U4:
price_countportmap(sta=>
sta,t_count=>
x,d_count=>
y,
mjiao=>
pri_jiao,mge=>
pri_ge,mshi=>
pri_shi,mbai=>
pri_bai);
-18-