LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; -- last modified / 12 jun 2006 / J.Steckert -- fixed bug with shifted sdout when register longer than data -- Shift register with serial/parallel load and parallel output entity shreg is generic(N : Integer := 39; Sout2dist : Integer := 7); port( rst_n : in std_logic; SCLK : in std_logic; SDIN : in std_logic; SSTR : in std_logic; SDOUT7s : out std_logic; SDOUT : out std_logic; PAROUTd : out std_logic_vector(N downto 1); -- direct output PAROUT : out std_logic_vector(N downto 1) -- registered output ); end shreg; architecture RTL of shreg is signal sreg, qreg : std_logic_vector(N downto 1); begin process(sclk, rst_n) begin if rst_n = '0' then sreg <= (others => '0'); qreg <= (others => '0'); elsif sclk'event and sclk='1' then sreg <= sreg(N-1 downto 1) & SDIN; if SSTR='1' then qreg <= sreg; end if; end if; end process; PAROUTd <= sreg; PAROUT <= qreg; SDOUT <= sreg(N); SDOUT7s <= sreg(N-Sout2dist); end RTL;