多功能出租车运营控制器Word格式.docx
《多功能出租车运营控制器Word格式.docx》由会员分享,可在线阅读,更多相关《多功能出租车运营控制器Word格式.docx(44页珍藏版)》请在冰豆网上搜索。
FPGA设计顶层文件采用图形化设计,状态机及相关数据处理单元,附加模块部分采用VHDL语言设计,部分采用图形化设计。
由于显示部分也是比较复杂的,所以也引进状态的概念对显示内容进行控制。
存储器采用数组的形式存储二进制信息,数组元素即为逻辑值向量。
5、系统结构:
⏹系统框图:
⏹模块功能描述:
输入接口用于译码产生相关的控制信号,状态机用于控制不同时刻的相关操作,数据处理单元用来处理相关信号,包括计时模块,相关寄存模块,计费,收费,计程模块,存储器模块等,输出驱动模块用于控制不同时候的输出。
⏹模块接口标注:
输入模块接口有4位键盘码keyvalue输出,握手信号pressed,以及一些经消抖同步的外部输入,如复位reset,闹钟开关控制alarm_on,收费脉冲输入f10,f5,f1,状态机产生控制信号,修改时间,日期使能timeload,dateload,修改密码使能,存储记录使能store,运营控制信号showXX,阅读记录信号readXX,找零信号等。
数据处理模块产生时间time,日期date,密码code,里程kilo,收费charge,存储器记录输出record等。
输出模块输入包括显示状态控制信号ss,各数据处理单元的显示输出内容,输出为6个8段数码管的信号,和一个闹钟到信号alarmsignal。
6、状态流程图:
⏹系统工作状态流程
由于系统比较庞大,操作过程比较多,所以涉及的状态控制也比较多,为了更加清楚地表示各状态间的控制转移,以及不同状态对应的控制输出信号,现采用多状态机的描述方法。
包括主流程图,各子流程图,其中一些具有类似功能的流程就省略了,比如校准日期,设置闹钟,设置参数的流程就和校准时间的流程类似。
1.总流程图:
2.出租车运营流程图
3.校准时间流程图:
4.管理员登录流程:
5.管理员修改密码流程
6.管理员阅读运营记录流程图:
7、程序清单
由于本系统的复杂性,所以程序比较多,这里仅列出主要的程序,同一个程序中类似的代码则省略,具有类似功能的代码仅举其一。
--键盘译码,按键动作标志生成模块--
libraryieee;
useieee.std_logic_1164.all;
entitykey_decoderis
port(col3,col2,col1,col0:
instd_logic;
row3,row2,row1,row0:
clk,scan_clk:
keyvalue:
outstd_logic_vector(3downto0);
pressed,stop:
outstd_logic);
endkey_decoder;
architecturertlofkey_decoderis
signaltemp:
std_logic_vector(7downto0);
signaltemp_pressed:
std_logic;
signalq1,q2,q3,q4,q5,q6:
signalkeypressed_asy:
begin
temp<
=row3&
row2&
row1&
row0&
col3&
col2&
col1&
col0;
process(temp)--键盘译码
casetempis
when"
11101110"
=>
keyvalue<
="
0000"
;
temp_pressed<
='
1'
11101101"
0001"
省略部分
01111101"
1101"
01111011"
1110"
01110111"
1111"
whenothers=>
temp_pressed<
0'
endcase;
endprocess;
process(scan_clk)--按键动作标志消抖
if(scan_clk'
eventandscan_clk='
)then
q1<
=temp_pressed;
q2<
=q1;
q3<
=q2;
q4<
=q3;
endif;
keypressed_asy<
=q1orq2orq3orq4;
process(clk)--按键动作标志与全局时钟同步化
if(clk'
eventandclk='
q5<
=keypressed_asy;
q6<
=q5;
pressed<
=q5andnot(q6);
stop<
=col3andcol2andcol1andcol0;
endrtl;
--里程计数模块--
useieee.std_logic_arith.all;
entitykilocounteris
port(start,mile,pause:
--开始计数,里程脉冲输入,暂停使能输入端
kilo:
outstd_logic_vector(11downto0);
--公里数输出端
high_3,high_15:
--大于三公里,大于15公里的使能输出端
endkilocounter;
architecturertlofkilocounteris
signalk1,k0,k00:
std_logic_vector(3downto0);
process(start,pause,mile)
ifstart='
then--未进入里程计数时里程数始终保持为零
k1<
k0<
k00<
high_3<
high_15<
else
ifpause='
then--等待状态下保持里程数
=k1;
=k0;
=k00;
elsifrising_edge(mile)then--在里程脉冲下正常计数
ifk00="
1001"
then
k00<
ifk0="
k0<
ifk1="
then
=k1+1;
else
=k0+1;
=k00+1;
ifk0>
0011"
then--达到里程要求时标志信号有效
endif;
ifk1>
0010"
or(k1="
andk0>
0101"
high_15<
kilo(11downto8)<
kilo(7downto4)<
kilo(3downto0)<
--计时模块--
useieee.std_logic_unsigned.all;
entitytime_counteris
port(clk,reset,timeload:
--全局时钟输入,开机复位端,修改时间置数端
buffertime:
instd_logic_vector(23downto0);
--时间并行输入端
time:
outstd_logic_vector(23downto0);
--时间输出端
ci:
--时间进位进日月模块
endtime_counter;
architecturertloftime_counteris
signalclk1s:
signaltemp_time5,temp_time4,temp_time3,temp_time2,temp_time1,temp_time0:
componentdivider_1s--500分频器说明
port(clk:
clk1s:
endcomponent;
divider1s:
divider_1s--500分频器实例化
portmap(clk=>
clk,
clk1s=>
clk1s);
process(clk1s,clk,reset,timeload)
ifreset='
then--复位清零
temp_time5<
temp_time4<
temp_time3<
temp_time2<
temp_time1<
temp_time0<
elsifrising_edge(clk)then
iftimeload='
then--修改时间时置数
=buffertime(23downto20);
temp_time4<
=buffertime(19downto16);
temp_time3<
=buffertime(15downto12);
temp_time2<
=buffertime(11downto8);
temp_time1<
=buffertime(7downto4);
temp_time0<
=buffertime(3downto0);
else--正常计时
ifclk1s='
iftemp_time0="
iftemp_time1="
iftemp_time2="
iftemp_time3="
iftemp_time4="
andtemp_time5="
temp_time5<
elsiftemp_time4="
=temp_time4+1;
=temp_time3+1;
=temp_time2+1;
=temp_time1+1;
=temp_time0+1;
--当计到23:
59:
59出现进位信号至日月模块--
iftemp_time5&
temp_time4&
temp_time3&
temp_time2&
temp_time1&
temp_time0="
001000110101100101011001"
ci<
time(23downto20)<
=temp_time5;
time(19downto16)<
=temp_time4;
time(15downto12)<
=temp_time3;
time(11downto8)<
=temp_time2;
time(7downto4)<
=temp_time1;
time(3downto0)<
=temp_time0;
--计费模块--
entitytotal_chargeis
port(start,pause,mile,f_wait:
--未运营状态,等待暂停状态,里程脉冲,等待时间脉冲
--里程标志输入
--时间输入
charge:
outstd_logic_vector(19downto0));
--计费总价输出,分别为百,十,个,十分,百分位
endtotal_charge;
architecturertloftotal_chargeis
signalc4,c3,c2,c1,c0:
process(time,pause,start,mile,f_wait,high_3,high_15)
variablehour_h,hour_l:
hour_h:
=time(23downto20);
hour_l:
=time(19downto16);
then--未运营时价格总为零
c4<
c3<
c2<
c1<
c0<
if(hour_h="
andhour_l>
0110"
)orhour_h="
or(hour_h="
andhour_l<
)then--白天运营
then--等待下的计费
ifrising_edge(f_wait)then--即pause='
进入等待状态
ifc2="
orc2="
1000"
c2<
ifc3="
c3<
ifc4="
=c4+1;
=c3+1;
=c2+2;
ifrising_edge(mile)then--正常运营
ifhigh_3='
elsifhigh_15='
ifc1="
c1<
elsec4<
elsec3<
elsec2<
=c2+1;
elsec1<
=c1+1;
elsifhigh_3='
andhigh_15='
if(c0="
andc1="
)orc1="
andc0="
c0<
elsifc1="
elsifc0="
=c1+"
else--夜间运营模式
ifrising_edge(f_wait)then
charge(19downto16)<
=c4;
charge(15downto12)<
=c3;
charge(11downto8)<
=c2;
charge(7downto4)<
=c1;
charge(3downto0)<
=c0;
--铃声产生模块--
entitybell_prois
port(alarm_on,clk,alarm_load,pressed:
--闹钟开关,时钟,修改置数,键盘响应
instd_logic_vector(15downto0);
--修改时间并行输入端
--当前时间并行输入
instd_logic_vector(3downto0);
--键盘值输入端
alarm_signal:
--闹铃信号输出端
endbell_pro;
architecturertlofbell_prois
signalalarm:
typestateis(s0,s1,s2,s3);
signalpre_state:
state:
=s0;
signalnext_state:
signaliner_ala_time:
std_logic_vector(15downto0);
process(clk)--修改置数进程
ifrising_edge(clk)then
ifalarm_load='
iner_ala_time<
=buffertime;
process(clk,alarm_on)--状态转移进程
ifalarm_on='
pre_state<
=next_state;
process(pre_state,time,iner_ala_time,pr