~ruther/vhdl-spi

ref: be420a443e64cc222882d795f7535e34626cd1de vhdl-spi/src/sipo_shift_register.vhd -rw-r--r-- 872 bytes
be420a44 — František Boháček feat: add shift registers 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
library ieee;
use ieee.std_logic_1164.all;

entity sipo_shift_register is

  generic (
    WIDTH : integer := 8);              -- The width of the register,  in bits

  port (
    clk_i : in std_logic;
    data_i : in std_logic;
    q_o : out std_logic_vector(WIDTH - 1 downto 0));

end entity sipo_shift_register;

architecture a1 of sipo_shift_register is
    signal q_reg : std_logic_vector(WIDTH - 1 downto 0);
    signal q_next : std_logic_vector(WIDTH - 1 downto 0);
begin  -- architecture a1
  q_next <= q_reg(WIDTH - 2 downto 0) & data_i;
  q_o <= q_reg;

  -- purpose: Set the q_reg
  -- type   : sequential
  -- inputs : clock_i, reset_in
  -- outputs: q_reg
  set_q_reg: process (clk_i) is
  begin  -- process set_q_reg
    if rising_edge(clk_i) then        -- rising clock edge
      q_reg <= q_next;
    end if;
  end process set_q_reg;

end architecture a1;
Do not follow this link