shift_register1.vhd

来自「很多仪器都输出同步时钟」· VHDL 代码 · 共 48 行

VHD
48
字号
-- 库声明
library IEEE;
use IEEE.STD_LOGIC_1164.all;
-- 实体声明
entity shift_register1 is
	-- 类属参数
	generic (
	TOTAL_BIT : integer := 69 );
	-- 端口
	port (
	clk : in std_logic;
	reset_n : in std_logic;
	din : in std_logic;                                 --输入信号
	regs : out std_logic_vector(TOTAL_BIT-1 downto 0)  --内部寄存器输出
	--dout : out std_logic 
	);                             --输出信号
	
end shift_register1;

--}} End of automatically maintained section
-- 结构体
architecture shift_register1 of shift_register1 is

-- 内部寄存器序列
signal shift_regs : std_logic_vector(TOTAL_BIT-1 downto 0) := (others => '1');

begin
	-- 寄存器输出
	regs <= shift_regs;
	
	-- 主过程
	main : process(reset_n, clk)
	begin
		-- 检查复位信号
		if reset_n = '0' then
			shift_regs <= (others => '1');
		-- 在时钟上升沿动作
		elsif rising_edge(clk) then
			
			-- 高位到最低位都向次高位移一位
			shift_regs(TOTAL_BIT-2 downto 0) <= shift_regs(TOTAL_BIT-1 downto 1);
			-- 读取输入端口信号并且保存到寄存器序列的最高位
			shift_regs(TOTAL_BIT-1) <= din;
		end if;
	end process;

end shift_register1;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?