名称:Quartus出租车自动计价器设计VHDL代码仿真(文末获取)
软件:Quartus
语言:VHDL
代码功能:
出租车自动计价器设计
设计一个杭州市临安区出租车计价器。
■该计价器的计费系统:行程4公里内,且等待累计时间1分钟内,起步费为10元;4公里外以每公里2.5元计费,等待累计时间2分钟外以每分钟以2.5元计费。并能显示行驶公里数、等待累计时间、总费用
主要技术指标
①计价范围:0~999.9元计价分辨率:0.1元
②计程范围:0~99公里计程分辨率:1公里
③计时范围:0~59分 计时分辨率:分
1. 工程文件
2. 程序文件
3. 程序编译
4. RTL图
5. 仿真图
整体仿真图
速度及判断模块
计费控制模块
里程计算模块
时间计算模块
显示模块
部分代码展示:
LIBRARY ieee; USE ieee.std_logic_1164.all; --出租车计价 ENTITY taxi_fee IS PORT ( clk : IN STD_LOGIC;--50MHz基准频率CLOCK0 reset : IN STD_LOGIC;--复位信号,低有效 stop : IN STD_LOGIC;--本次行程结束,停止计费,高有效 start : IN STD_LOGIC;--启动信号,行程开始,高有效 Wheel_pulse : IN STD_LOGIC;--车轮脉冲 --4位数码管显示费用 Kmmoney_L_HEX : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);--合计费用 HML=xxx (BCD码显示) Kmmoney_M_HEX : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); Kmmoney_H_HEX : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); Kmmoney_K_HEX : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); --里程显示 Kmcount_H_HEX : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);--总路程 Kmcount_L_HEX : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); --时间显示 time_H_HEX : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);--总时间 time_L_HEX : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) ); END taxi_fee; ARCHITECTURE trans OF taxi_fee IS --速度计算及判断模块 COMPONENT speed_pulse IS PORT ( clk : IN STD_LOGIC;--标准时钟,10hz reset : IN STD_LOGIC;--复位信号,低有效 Wheel_pulse : IN STD_LOGIC;--车轮脉冲 Speed : OUT STD_LOGIC;--0:暂停等待;1:行驶 kilometre_01 : OUT STD_LOGIC;--1公里产生一次 minute_en : OUT STD_LOGIC--暂停等待,1min产生一次脉冲 ); END COMPONENT; --模块例化 COMPONENT display IS PORT ( clk : IN STD_LOGIC; reset : IN STD_LOGIC; Speed : IN STD_LOGIC;--0:暂停等待;1:行驶 wait_time : IN STD_LOGIC_VECTOR(7 DOWNTO 0); totel_money : IN STD_LOGIC_VECTOR(15 DOWNTO 0); mileage : IN STD_LOGIC_VECTOR(7 DOWNTO 0); --4位数码管显示费用 Kmmoney_L_HEX : OUT STD_LOGIC_VECTOR(6 DOWNTO 0);--合计费用 HML=xxx (BCD码显示) Kmmoney_M_HEX : OUT STD_LOGIC_VECTOR(6 DOWNTO 0); Kmmoney_H_HEX : OUT STD_LOGIC_VECTOR(6 DOWNTO 0); Kmmoney_K_HEX : OUT STD_LOGIC_VECTOR(6 DOWNTO 0); --里程显示6 Kmcount_H_HEX : OUT STD_LOGIC_VECTOR(6 DOWNTO 0);--总路程 Kmcount_L_HEX : OUT STD_LOGIC_VECTOR(6 DOWNTO 0); --时间显示 time_H_HEX : OUT STD_LOGIC_VECTOR(6 DOWNTO 0);--总时间 time_L_HEX : OUT STD_LOGIC_VECTOR(6 DOWNTO 0) ); END COMPONENT; --模块例化 --计费模块 COMPONENT taxi_state IS PORT ( clk : IN STD_LOGIC;--标准时钟,10hz reset : IN STD_LOGIC;--复位信号,低有效 stop : IN STD_LOGIC;--本次行程结束,停止计费,高有效 start : IN STD_LOGIC;--启动信号,行程开始,高有效 Speed : IN STD_LOGIC;--0:暂停等待;1:行驶 kilometre_01 : IN STD_LOGIC;--1公里产生一次脉冲 minute_en : IN STD_LOGIC;--暂停等待,1min产生一次脉冲 state_out : OUT STD_LOGIC_VECTOR(2 DOWNTO 0); wait_time : IN STD_LOGIC_VECTOR(7 DOWNTO 0); mileage : IN STD_LOGIC_VECTOR(7 DOWNTO 0);--里程 totel_money_out : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)--合计费用 ); END COMPONENT; --计费模块 COMPONENT mileage_ctrl IS PORT ( clk : IN STD_LOGIC;--标准时钟,10hz reset : IN STD_LOGIC;--复位信号,低有效 kilometre_01 : IN STD_LOGIC;--1公里产生一次脉冲 state : IN STD_LOGIC_VECTOR(2 DOWNTO 0); mileage_out : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) ); END COMPONENT; --计时模块 COMPONENT time_ctrl IS PORT ( clk : IN STD_LOGIC;--标准时钟,10hz reset : IN STD_LOGIC;--复位信号,低有效 minute_en : IN STD_LOGIC;--暂停等待,1min产生一次脉冲 state : IN STD_LOGIC_VECTOR(2 DOWNTO 0); wait_time_out : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)--计时 ); END COMPONENT; --信号定义 SIGNAL Speed : STD_LOGIC;--0:暂停等待;1:行驶 SIGNAL kilometre_01 : STD_LOGIC; SIGNAL minute_en : STD_LOGIC; SIGNAL totel_money : STD_LOGIC_VECTOR(15 DOWNTO 0); SIGNAL mileage : STD_LOGIC_VECTOR(7 DOWNTO 0); SIGNAL wait_time : STD_LOGIC_VECTOR(7 DOWNTO 0); SIGNAL state : STD_LOGIC_VECTOR(2 DOWNTO 0); BEGIN --3位数码管显示费用 Kmmoney_L_HEX(7)<='1';--合计费用 HML=xxx (BCD码显示) Kmmoney_M_HEX(7)<='0';--显示小数点 Kmmoney_H_HEX(7)<='1'; Kmmoney_K_HEX(7)<='1'; --里程显示 Kmcount_H_HEX(7)<='1'; Kmcount_L_HEX(7)<='1'; --时间显示 time_H_HEX(7)<='1'; time_L_HEX(7)<='1'; --速度计算及判断模块 U_speed_pulse : speed_pulse PORT MAP ( clk => clk,--标准时钟,256hz reset => reset,--复位信号,低有效 Wheel_pulse =>Wheel_pulse, Speed => Speed,----0:暂停等待;1:行驶 kilometre_01 => kilometre_01,--1公里产生一次脉冲 minute_en => minute_en--暂停等待,1min产生一次脉冲 ); --控制模块 U_taxi_state : taxi_state PORT MAP ( clk => clk,--标准时钟,256hz reset => reset,--复位信号,低有效 stop => stop,--本次行程结束,停止计费,高有效 start => start,--启动信号,行程开始,高有效 speed => Speed,----0:暂停等待;1:行驶 kilometre_01 => kilometre_01,----1公里产生一次脉冲 minute_en => minute_en,--暂停等待,1mins产生一次脉冲 state_out=>state, wait_time => wait_time, mileage => mileage, totel_money_out => totel_money--合计费用 ); --计里程模块 U_mileage_ctrl: mileage_ctrl PORT MAP( clk => clk,--标准时钟 reset => reset,--复位信号,低有效 kilometre_01 => kilometre_01,----1公里产生一次脉冲 state =>state, mileage_out => mileage ); --计时模块 U_time_ctrl : time_ctrl PORT MAP( clk => clk,--标准时钟 reset => reset,--复位信号,低有效 minute_en => minute_en,--暂停等待,1min产生一次脉冲 state =>state, wait_time_out =>wait_time ); --显示模块 U_display : display PORT MAP ( clk => clk,--标准时钟 reset => reset,--复位信号,低有效 speed => Speed,----0:暂停等待;1:行驶 totel_money => totel_money,--费用 mileage => mileage,--里程 wait_time => wait_time,--累计等待时间 --4位数码管显示费用 Kmmoney_L_HEX => Kmmoney_L_HEX(6 DOWNTO 0),--合计费用 HML=xxx (BCD码显示) Kmmoney_M_HEX => Kmmoney_M_HEX(6 DOWNTO 0), Kmmoney_H_HEX => Kmmoney_H_HEX(6 DOWNTO 0), Kmmoney_K_HEX => Kmmoney_K_HEX(6 DOWNTO 0), --里程显示 Kmcount_H_HEX => Kmcount_H_HEX(6 DOWNTO 0),--总路程 Kmcount_L_HEX => Kmcount_L_HEX(6 DOWNTO 0), --时间显示 time_H_HEX => time_H_HEX(6 DOWNTO 0),--总时间 time_L_HEX => time_L_HEX(6 DOWNTO 0) ); END trans;
完整代码
扫描文章末尾的公众号二维码