?? taxi.txt
字號:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity taxi is
port ( clk_256 :in std_logic;
start :in std_logic;
stop:in std_logic;
fin:in std_logic;
cha3,cha2,cha1,cha0:out std_logic_vector(3 downto 0);
km1,km0:out std_logic_vector(3 downto 0);
min1,min0: out std_logic_vector(3 downto 0));
end taxi;
architecture behav of taxi is
signal f_15,f_13,f_1:std_logic;
signal q_13:integer range 0 to 12;
signal q_15:integer range 0 to 14;
signal q_1:integer range 0 to 255;
signal w:integer range 0 to 59;
signal c3,c2,c1,c0:std_logic_vector(3 downto 0);
signal k1,k0:std_logic_vector(3 downto 0);
signal m1:std_logic_vector (3 downto 0);
signal m0:std_logic_vector (3 downto 0);
signal en1,en0,f:std_logic;
begin
feipin:process(clk_256,start)
begin
if clk_256'event and clk_256='1' then
if start='0' then q_15<=0;q_13<=0;f_15<='0';f_13<='0';f_1<='0';f<='0';
else
if q_15=14 then q_15<=0;f_15<='1';
else q_15<=q_15+1;f_15<='0';
end if;
if q_13=12then q_13<=0;f_13<='1';
else q_13<=q_13+1;f_13<='0';
end if;
if q_1=194 then q_1<=0;f_1<='1';
else q_1<=q_1+1;f_1<='0';
end if;
if en1='1' then f<=f_13;
elsif en0='1' then f<=f_15;
else f<='0';
end if;
end if;
end if;
end process;
process(f_1)
begin
if f_1'event and f_1='1' then
if start='0' then
w<=0;en1<='0';en0<='0';m1<="0000";m0<="0000";k1<="0000";k0<="0000";
elsif stop='1' then
if w=59 then w<=0;
if m0="1001" then m0<="0000";
if m1="0101" then m1<="0000";
else m1<=m1+1;
end if;
else m0<=m0+1;
end if;
if m1&m0>"0000001"then en1<='1';
else en1<='0';
end if;
else w<=w+1;en1<='0';
end if;
elsif fin='1' then
if k0="1001" then k0<="0000";
if k1="1001" then k1<="0000";
else k1<=k1+1;
end if;
else k0<=k0+1;
end if;
if k1&k0>"00000010" then en0<='1';
else en0<='0';
end if;
else en1<='0';en0<='0';
end if;
cha3<=c3;cha2<=c2;cha1<=c1;cha0<=c0;
km1<=k1;km0<=k0;min1<=m1;min0<=m0;
end if;
end process;
process(f,start)
begin
if start='0' then c3<="0000";c2<="0000";c1<="0101";c0<="0000";
elsif f'event and f='1' 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;
end if;
else c2<=c2+1;
end if;
else c1<=c1+1;
end if;
else c0<=c0+1;
end if;
end if;
end process;
end behav;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -