reg.vhd
来自「FPGA基础性试验交通灯设计」· VHDL 代码 · 共 44 行
VHD
44 行
--** 通用寄存器 **--
--文件名:reg.vhd
--功 能:通用寄存器
--说 明:“data”采用八位拨盘开关来置入数据;
-- “q”采用发光二极管来表示;
-- “enable”作为发光二极管的片选信号输入端,用按键来实现控制;
--**注意:按键是'0'有效,默认是'1'电平; 片选信号(cs)为高电平选通;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity reg is
Port (clk : in std_logic; --时钟信号;
enable : in std_logic; --使能信号;
cs : out std_logic_vector(1 downto 0); --发光二极管的片选输出;
datain : in std_logic_vector(7 downto 0); --八位数据输入;
q : out std_logic_vector(7 downto 0)); --八位数据输出;
end reg;
architecture Behavioral of reg is
begin
cs<='0'&(not(enable));
process(clk)
begin
if clk'event and clk='1' then
if enable='0' then
q<=datain;
end if;
end if;
end process;
end Behavioral;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?