📄 taxi.vhd
字号:
library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity taxi isport ( f_1,clk_50,f_in,clk:in std_logic; start :in std_logic; waiting:in std_logic; cha3,cha2,cha1,cha0:out std_logic_vector(3 downto 0); km2, km1,km0:out std_logic_vector(3 downto 0); min1,min0: out std_logic_vector(3 downto 0)); end taxi;architecture behav of taxi issignal f_15,f_100m: std_logic:='0'; signal q_15:integer range 0 to 15;signal temp:integer range 0 to 31; signal w:integer range 0 to 59; signal k2,k1,k0:std_logic_vector(3 downto 0):="0000"; signal m1:std_logic_vector(3 downto 0):="0000"; signal m0:std_logic_vector(3 downto 0):="0000"; signal change,temp1,cha ,ch_min: integer range 0 to 10000;signal c0,c1,c2,c3:std_logic_vector(3 downto 0):="0000";signal a:std_logic:='0'; beginp0:process(f_in)begin if f_in'event and f_in='1'then if q_15=15 then q_15<=0; f_15<='1'; else q_15<=q_15+1; f_15<='0'; end if; end if;end process;p1:process(f_15)begin if f_15'event and f_15='1' then if temp=31 then temp<=0; f_100m<='1'; else temp<=temp+1; f_100m<='0'; end if; end if;end process;p2:process(f_100m,f_1,start,waiting)begin if f_100m'event and f_100m='1' then if start='0' then k0<="0000";k1<="0000";k2<="0000";a<='0'; change<=0; elsif start='1' and waiting ='0' then if k0="1001" then k0<="0000"; if k1="1001" then k1<="0000"; if k2="1001" then k2<="0000"; else k2<=k2+1; end if; else k1<=k1+1; end if; else k0<=k0+1; end if; if k2&k1&k0>"00100000" and k2&k1<="1010" then if k0="0000" or k0="0101" then change<=change+10; end if; elsif k2&k1&k0>"10100000" then if k0="0000" or k0="0101" then change<=change+10; end if; end if; end if; end if;end process;p3:process(f_1)begin if f_1'event and f_1='1' then if start='0' then w<=0;m1<="0000";m0<="0000";ch_min<=0; elsif waiting='1' then if w=59 then w<=0; if m0="1001" then m0<="0000"; if m1<="0101" then m1<="0000"; else m1<=m1+1; ch_min<=ch_min+10; end if; else m0<=m0+1; ch_min<=ch_min+10; end if; else w<=w+1; end if; end if; end if;end process;p4:process(clk_50,clk)begin if clk_50'event and clk_50='1' then if ch_min>20 then cha<=change+100+ch_min-30; else cha<=change+100; end if;end if;if clk'event and clk='1' then if start='0' then temp1<=0;c0<="0000";c1<="0000"; c2<="0000";c3<="0000"; elsif temp1<cha then if c0="1001" then c0<="0000"; if c1="1001" then c1<="0000"; if c2="1001" then c2<="0000"; if c3="1001" then c3<="0000"; else c3<=c3+1;temp1<=temp1+1; end if; else c2<=c2+1;temp1<=temp1+1; end if; else c1<=c1+1;temp1<=temp1+1; end if; else c0<=c0+1; temp1<=temp1+1; end if; end if; cha3<=c3; cha2<=c2; cha1<=c1; cha0<=c0; km2<=k2; km1<=k1; km0<=k0; min1<=m1; min0<=m0; end if;end process;end behav;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -