-- KK11-36 N-Bit Shift Register			E235   11 1111

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
--|||||||||||||||||||||||||||||||||||||||||
entity shift_reg is 
	generic (N: integer := 4);
	port 
	(
		clk		:	in		std_logic;
		clr		:	in		std_logic;
		data_in	:	in		std_logic;
		q			:	out	std_logic_vector(N-1 downto 0)
	); 
end shift_reg;

--|||||||||||||||||||||||||||||||||||||||||
architecture behavioral of shift_reg is 

signal qs	:	std_logic_vector(N-1 downto 0);
signal i		:  integer;

--=========================================
begin
	process (clk, clr) is
	begin
		if clr = '1' then
			for i in 0 to N-1 loop
				qs(i) <= '0';
			end loop;		
		elsif clk'event and clk = '1' then
			qs(N-1) <= data_in;
			qs(N-2 downto 0) <= qs(N-1 downto 1);
		end if;		
	end process;
	q <= qs;
end behavioral;