📄 t_flip_flop.vhd
字号:
--** T 触 发 器
--文件名:T_flip_flop.vhd
--功 能: T触发器
--说 名:“q”采用发光二极管来表示;
-- “enable”、“reset”分别用按键S3,S6来表示;
--**注意:按键是'0'有效,默认是'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); --发光二极管、数码管片选信号;
reset : in std_logic; --异步复位信号;
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) --分频器——产生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"; --为了便于观察,将不必要的发光二极管熄灭;
end process;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -