EDA课设-基于VHDL的简易出租车计价器设计
2017-12-19 10:26
399 查看
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity taxi is port(clk:in std_logic; start:in std_logic; wait_signal:in std_logic; mile:in std_logic; one_way:in std_logic; rst:in std_logic; cost0,cost1,cost2,cost3:out std_logic_vector(3 downto 0); min0,min1:out std_logic_vector(3 downto 0); km0,km1:out std_logic_vector(3 downto 0)); end; architecture bhv of taxi is signal mile_r1,mile_r2,mile_clk,start_r,clk1hz:std_logic; signal count:integer range 0 to 29; signal sec:integer range 0 to 59; signal c0,c1,c2,c3:std_logic_vector(3 downto 0); signal k0,k1,m0,m1:std_logic_vector(3 downto 0); signal en0,en1:std_logic; signal wait_clk,cost_clk:std_logic; begin U1:process( rst,clk) -- 分频 begin if rst='0' then if clk'event and clk='1' then if count=31 then count<=0;clk1hz<='1'; else count<=count+1;clk1hz<='0'; end if; end if; end if; end process; U2:process(rst,clk1hz,start,wait_signal) --等待时间计数 begin if rst='1' then m0<="0000";m1<="0000"; elsif start='0'then wait_clk<='0'; elsif clk1hz'event and clk1hz='1' then if wait_signal='1'then if sec=59 then sec<=0;wait_clk<='1'; if m0="1001"then m0<="0000"; if m1="0101"then m1<="0000"; else m1<=m1+'1'; end if; else m0<=m0+'1'; end if; else wait_clk<='0'; sec<=sec+1; end if; else wait_clk<='0'; end if; end if; end process; U3:process( rst,clk1hz,mile,start) --检测mile上升沿 begin if rst='0' then if clk1hz'event and clk1hz='1'then mile_r2<=mile_r1;mile_r1<=mile;start_r<=start; end if; end if; end process; mile_clk<=mile_r1 and not(mile_r2); cost_clk<= wait_clk when wait_signal='1'else mile_clk when en0='1' or en1 ='1'else '0'; U4:process(rst,start,mile_clk) --里程计数 begin if rst='1' then k0<="0000"; k1<="0000"; elsif start='0' then k0<="0000"; k1<="0000"; en0<='0';en1<='0'; elsif mile_clk'event and mile_clk='1' then if k1 & k0>="00100000" and one_way='1' then en1<='1';en0<='0'; end if; if k1 & k0="00000011" then en0<='1'; end if; if k0="1001" then k0<="0000"; if k1="1001" then k1<="0000"; else k1<=k1+'1'; end if; else k0<=k0+'1'; end if; end if; end process; U5:process( rst,start,cost_clk,start_r) --计费 begin if rst='1' then c0<="0000";c1<="0000"; c2<="0000";c3<="0000"; elsif start='1' and start_r='0' then c0<="0000";c1<="1000";c2<="0000"; c3<="0000"; elsif cost_clk'event and cost_clk='1'then if en1='0' and en0='1'then if c1="1001"then c1<="0000"; if c2="1001"then c2<="0000"; if c3="1001"then c3<="0000"; else c3<=c3+'1'; end if; else c2<=c2+'1'; end if; else c1<=c1+'1'; c0<="0000"; end if; else if (c0="0101" and c1="1000")or c1="1001"then if c1="1001" and c0="0101" then c0<="0000"; c1<="0001"; elsif c1="1001" and c0="0000" then c0<="0101";c1<="0000"; elsif c1="1000" and c0="0101" then c0<="0000";c1<="0000"; end if; if c2="1001" then c2<="0000"; if c3="1001"then c3<="0000"; else c3<=c3+'1'; end if; else c2<=c2+'1'; end if; elsif c0="0000"then c0<="0101";c1<=c1+'1'; else c0<="0000";c1<=c1+"0010"; end if; end if; end if; end process; min0<=m0; min1<=m1; km0<=k0; km1<=k1; cost0<=c0; cost1<=c1; cost2<=c2; cost3<=c3; end;
相关文章推荐
- EDA课设-基于VHDL的简易出租车计价器设计
- EDA课设-基于VHDL的简易出租车计价器设计
- EDA课设-基于VHDL的简易出租车计价器设计
- EDA课设-基于VHDL的简易出租车计价器设计
- EDA课设-基于VHDL的简易出租车计价器设计
- EDA课设-基于VHDL的简易出租车计价器设计
- EDA课设-基于VHDL的简易出租车计价器设计
- 基于FPGA的VGA简易显存设计&NIOS ii软核接入
- 基于单片机的简易数字电压表设计
- 基于VHDL的层次化设计:异步清零和同步使能4位十六进制加法计数器和七段显示译码器的元件例化实现
- 基于VHDL的四路抢答器设计(程序)+注释
- 基于VHDL设计的交通灯系统
- 基于VHDL的8255可编程并行接口电路设计
- 基于WebServices简易网络聊天工具的设计与实现
- 基于Android 平台简易即时通讯的研究与设计
- 基于VHDL的四路抢答器设计
- 基于线性回归和TivaTM4C123GH6PM 微控制器的简易噪声计的设计
- 基于WebServices简易网络聊天工具的设计与实现
- 基于Android 平台简易即时通讯的研究与设计
- [硬件项目] 1、汽车倒车雷达设计——基于API8108A芯片简易智能语音模块的设计与实现