lfsr6a.vhd
--
-- 6-bit LFSR(Linear Feedback Shift Register)
--
library ieee;
use ieee.std_logic_1164.all;
entity lfsr6a is
port( c : in std_logic;
nr : in std_logic;
q : out std_logic_vector(5 downto 0));
end lfsr6a;
architecture rtl of lfsr6a is
signal feedback : std_logic;
signal bufQ : std_logic_vector(5 downto 0);
begin
process(nr,c)
begin
if (nr = '0') then
bufQ <= (others => '1');
elsif (c'event and c = '1') then
bufQ <= bufQ(4 downto 0) & feedback;
end if;
end process;
-- feedback tap = (5,4,2,1)
feedback <= bufQ(5) xor bufQ(4) xor bufQ(2) xor bufQ(1);
q <= bufQ;
end rtl;