?? t_flip_flop.vhd
字號:
--** T 觸 發(fā) 器
--文件名:T_flip_flop.vhd
--功 能: T觸發(fā)器
--說 名:“q”采用發(fā)光二極管來表示;
-- “enable”、“reset”分別用按鍵S3,S6來表示;
--**注意:按鍵是'0'有效,默認(rèn)是'1'電平; 片選信號(cs)為高電平選通;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity T_flip_flop is
Port (clk : in std_logic; --50MHz時鐘頻率;
enable : in std_logic; --使能信號;
cs : out std_logic_vector(1 downto 0); --發(fā)光二極管、數(shù)碼管片選信號;
reset : in std_logic; --異步復(fù)位信號;
q : out std_logic_vector(7 downto 0) ); --信號輸出端;
end T_flip_flop;
architecture Behavioral of T_flip_flop is
signal clk1Hz : std_logic;
begin
cs<="01";
process(clk) --分頻器——產(chǎn)生1Hz的時鐘脈沖;
variable cnt : integer range 0 to 50000000;
begin
if clk'event and clk='1' then cnt:=cnt+1;
if cnt<25000000 then clk1Hz<='1';
elsif cnt<50000000 then clk1Hz<='0';
else cnt:=0;clk1Hz<='0';
end if;
end if;
end process;
process(clk1Hz,reset,enable)
variable q_temp : std_logic;
begin
if enable='0' or reset='0' then q_temp:='0';
elsif clk1Hz'event and clk1Hz='1' then
q_temp:=not(q_temp);
end if;
q(0)<=q_temp;
q(7 downto 1)<="1111111"; --為了便于觀察,將不必要的發(fā)光二極管熄滅;
end process;
end Behavioral;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -