⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shifter.vhd

📁 多个Verilog和vhdl程序例子
💻 VHD
字号:
-- 8 bit shift register with shift right, shift left, load and
-- synchronous reset.

library ieee;
use ieee.std_logic_1164.all;

entity shifter is
    port (data : in std_logic_vector (7 downto 0);
             shift_left, shift_right, clk, reset : in std_logic;
             mode : in std_logic_vector (1 downto 0);
             qout : buffer std_logic_vector (7 downto 0) );
end shifter;

architecture behave of shifter is
    signal enable: std_logic;
begin

    process
    begin
        wait until (rising_edge(clk) );
        if (reset = '1') then
            qout <= "00000000";
        else
            case mode is
                when "01"   =>
                    qout <= shift_right & qout(7 downto 1); -- shift right
                when "10"   =>
                    qout <= qout(6 downto 0) & shift_left; -- shift left
                when "11"   =>
                    qout <= data; -- parallel load
                when others => null; -- null means do nothing
          end case;
        end if;
    end process;

end behave;

⌨️ 快捷键说明

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