logo资料库

出租车计费器T实验报告.doc

第1页 / 共12页
第2页 / 共12页
第3页 / 共12页
第4页 / 共12页
第5页 / 共12页
第6页 / 共12页
第7页 / 共12页
第8页 / 共12页
资料共12页,剩余部分请下载后查看
出租车计费器 一、实验任务及要求 1.能实现计费功能,计费标准为: 2.按行驶里程收费,起步费为5.00元,并在车行3公里后再按1.8 元/公里,当计费器计费 达到或超过一定收费 (如20元)时,每公里加收50%的车费,车停止不计费。 3.实现预置功能: 能预置起步费、每公里收费、车行加费里程。 4.实现模拟功能: 能模拟汽车启动、停止、暂停、车速等状态。 4.设计动态扫描电路: 将车费显示出来,有两位小数。 5.用VHDL语言设计符合上述功能要求的出租车计费器,并用层次化设计方法设计该电路。 6.各计数器的计数状态用功能仿真的方法验证,并通过有关波形确认电路设计是否正确。 7.完成电路全部设计后,通过系统实验箱下载验证设计课题的正确性。 二.实验仪器及器件 (1)VHDL 开发软件 (2)微机 (3)实验开发系统 (4)打印机 (5)其他器件与材料 一套 一台 一台 一台 若干 三、实验原理及实验说明: 计费器按里程收费,每100米开始一次计费。各模块功能如下: 1 1.车速控制模块(speed): 当起停键为启动状态时(高电平),模块根据车速选择和基本车速发出响应频率的脉冲驱动 计费器和里程显示模块进行计数;当处于停止状态时暂停发出脉冲,此时计费器和里程显示模 块相应的停止计数。 2.里程动态显示模块(cou99): 其包括计数车速控制模块发出的脉冲以及将计数显示动态显示出来,每来一个脉冲里程值 加0.1(控制器每发一个脉冲代表运行了0.1公里)。 3.计费动态显示模块(count99): 其初值为7当里程超过3公里后才接受计数车速控制模块发出的脉冲的驱动,并且计数显示 动态显示出来,每来一个脉冲(代表运行了0.1公里)其数值加0。18,当收费超过20时数值加0。 27。 4.程序设计说明:
程序设计时将里程显示和计费显示模块的动态扫描功能独立出来,单独设计一个共用的扫 描模块,因此将里程显示和计费显示模块各自都分为计数模块和扫描两个模块: (实验总图) 2 四.各模块程序代码 (1)车速控制模块: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; ENTITY speed IS PORT( clk,reset,start : INSTD_LOGIC;――clk基本车速,reset复位,start起停开关 k : INSTD_LOGIC_VECTOR(4 downto 0);――车速选择 clkout : OUT STD_LOGIC); ――脉冲输出 END speed; ARCHITECTURE a OF speed IS
SIGNAL count1 : STD_LOGIC_VECTOR(1 downto 0); SIGNAL tempclk,clks : STD_LOGIC; SIGNAL kinside : STD_LOGIC_VECTOR(4 downto 0); BEGIN kinside<="00000"-k;――车速越大,脉冲输出频率约高,因此计数周期越小 clks_label: PROCESS (reset,clk) variable count2 : STD_LOGIC_VECTOR(4 downto 0); BEGIN IF reset='1' THEN count2:="00000"; ELSIF clk'event and clk='1' THEN if start='1'then 3 if count2=kinside then count2:="00000"; end if;――计数周期 if not (k="00000") then count2:=count2+1; end if;――车速不为0 if count2="00001" then tempclk<=not tempclk; end if;――每个计数周期发出一个脉 冲 END IF; end if; END PROCESS clks_label; clkout<=tempclk; END a; (2)里程计数模块: library ieee; use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity cdu99 is port ( clk,reset:in std_logic; count1 :out std_logic_vector (3 downto 0);――里程数值的十分位 count2 :out std_logic_vector (3 downto 0); ――里程数值的个位 count3 :out std_logic_vector (3 downto 0)); ――里程数值的十位 end cdu99 ; architecture aa of cdu99 is begin process(clk,reset) variable mm : std_logic_vector (11 downto 0); begin if reset='1' then mm:="000000000000"; 4 elsif clk'event and clk='1' then if mm(3 downto 0)="1001" then――十六进制转换成十进制 mm:=mm+7;else mm:=mm+1; end if; if mm(7 downto 4)="1010" then mm:=mm+"01100000"; end if; end if; count1<=mm(3 downto 0); count2<=mm(7 downto 4); count3<=mm(11 downto 8); end process;
end aa; (3)计费计数模块: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity count99 is port ( clk,reset:in std_logic; judge2 :in std_logic_vector (3 downto 0);――里程个位 judge3 :in std_logic_vector (3 downto 0);――里程十位 count1 :out std_logic_vector (3 downto 0); ――计费百分位 count2 :out std_logic_vector (3 downto 0); ――计费十分位 count3 :out std_logic_vector (3 downto 0); ――计费个位 5 count4 :out std_logic_vector (3 downto 0)); ――计费十位 end count99 ; architecture aa of count99 is signal en : std_logic; signal money : std_logic_vector(7 downto 0); signal mcount : std_logic_vector (15 downto 0); begin money<="0000001" when ((mcount(15)='1') or (mcount(14)='1') or (mcount(13)='1')) else "00100000"; ――计费模式:2.00和1.00元 en<='0' when judge3="0000" and judge2(3 downto 2)="00" and ((judge2(1)='0') or (judge2(1)='1' and judge2(0)='0')) else '1';
――计费使能:公里>=3 process(clk,reset) variable mm : std_logic_vector (15 downto 0); begin if reset='1' then mm:="0000100000000000"; ——起步价格为8元 elsif clk'event and clk='1' then if en='1' then mm:=mm+money; end if; if mm(3)='1' and (not(mm(2 downto 1)="00")) then—十六进制转换成十进制 mm:=mm+6; end if; if mm(7)='1' and (not(mm(6 downto 5)="00")) then mm:=mm+"01100000"; end if; if mm(11)='1' and (not(mm(10 downto 9)="00")) then 6 mm:=mm+"011000000000"; end if; end if; count1<=mm(3 downto 0); count2<=mm(7 downto 4); count3<=mm(11 downto 8); count4<=mm(15 downto 12); mcount<=mm; end process; end aa; (4)动态扫描模块:
(动态显示内部结构) a:baijinzhiu(八进制) LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_unsigned.ALL; ENTITY bajinzhi is port (clk :in std_logic; q :out std_logic_vector(2 downto 0)); end; architecture one of bajinzhi is signal begin q1:std_logic_vector(2 downto 0); process(clk) begin if clk'event and clk='1' 7 then q1<=q1+1; end if; q<=q1; end process; end ; b:mux48_1(4*8 选一) library use ieee.std_logic_1164.all; ieee; entity mux48_1 is port(a,b,c :in std_logic; en :in std_logic; y0,y1,y2,y3,y4,y5,y6,y7:in std_logic_vector(3 downto 0); z:out std_logic_vector(3 downto 0)); end mux48_1; architecture rtl of mux48_1 is signal ind :std_logic_vector(2 downto 0); begin
ind <=c&b&a; process (ind,en ) begin if (en='1')then case ind is when "000"=>z<=y0; when "001"=>z<=y1; when "010"=>z<=y2; when "011"=>z<=y3; when "100"=>z<=y4; when "101"=>z<=y5; when "110"=>z<=y6; when "111"=>z<=y7; when others =>z<="XXXX"; end case; end if ; end process; end rtl; c :decode4_7(译码器) library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity decode4_7 is 8 port (din :in std_logic_vector(3 downto 0); dout:out std_logic_vector(6 downto 0)); end decode4_7; architecture rtl of decode4_7 is begin process (din) begin case din is when "0000"=>dout<="1111110"; when "0001"=>dout<="0110000"; when "0010"=>dout<="1101101"; when "0011"=>dout<="1111001"; when "0100"=>dout<="0110011"; when "0101"=>dout<="1011011"; when "0110"=>dout<="1011111"; when "0111"=>dout<="1110000"; when "1000"=>dout<="1111111"; when "1001"=>dout<="1111011"; when others=>dout<="1111111"; end case; end process; end rtl;
分享到:
收藏