OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.communication/] [hibi/] [3.0/] [vhd/] [lfsr.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
---------------------------------------------------------------------
2
-- Design unit: lfsr(rtl) (Entity and Architecture)
3
--            :
4
-- File name  : lfsr.vhd
5
--            :
6
-- Description: RTL model of LFSR
7
--            :
8
-- Limitations: None
9
--            : 
10
-- System     : VHDL'93, STD_LOGIC_1164
11
--            :
12
-- Author     : Mark Zwolinski
13
--            : Department of Electronics and Computer Science
14
--            : University of Southampton
15
--            : Southampton SO17 1BJ, UK
16
--            : mz@ecs.soton.ac.uk
17
--
18
-- Revision   : Version 1.0 08/03/00
19
-- 09.05.2007 AK mod: uses 0.5x registers compared to the orig.
20
---------------------------------------------------------------------
21
 
22
library ieee;
23
use ieee.std_logic_1164.all;
24
entity lfsr is
25
  generic(
26
    width_g : integer range 1 to 36 := 8
27
    );
28
  port(
29
    rst_n     : in  std_logic;
30
    enable_in : in  std_logic;
31
    q_out     : out std_logic_vector(width_g-1 downto 0);
32
    clk       : in  std_logic
33
    );
34
end entity lfsr;
35
 
36
architecture rtl of lfsr is
37
  type tap_table is array (1 to 36, 1 to 4) of
38
    integer range -1 to 36;
39
  constant taps : tap_table := (
40
    (0, -1, -1, -1),                    -- 1
41
    (1, 0, -1, -1),                     -- 2
42
    (1, 0, -1, -1),                     -- 3
43
    (1, 0, -1, -1),                     -- 4
44
    (2, 0, -1, -1),                     -- 5
45
    (1, 0, -1, -1),                     -- 6
46
    (1, 0, -1, -1),                     -- 7
47
    (6, 5, 1, 0),                       -- 8
48
    (4, 0, -1, -1),                     -- 9
49
    (3, 0, -1, -1),                     --10
50
    (2, 0, -1, -1),                     --11
51
    (7, 4, 3, 0),                       --12
52
    (4, 3, 1, 0),                       --13
53
    (12, 11, 1, 0),                     --14
54
    (1, 0, -1, -1),                     --15
55
    (5, 3, 2, 0),                       --16
56
    (3, 0, -1, -1),                     --17
57
    (7, 0, -1, -1),                     --18
58
    (6, 5, 1, 0),                       --19
59
    (3, 0, -1, -1),                     --20
60
    (2, 0, -1, -1),                     --21
61
    (1, 0, -1, -1),                     --22
62
    (5, 0, -1, -1),                     --23
63
    (4, 3, 1, 0),                       --24
64
    (3, 0, -1, -1),                     --25
65
    (8, 7, 1, 0),                       --26
66
    (8, 7, 1, 0),                       --27
67
    (3, 0, -1, -1),                     --28
68
    (2, 0, -1, -1),                     --29
69
    (16, 15, 1, 0),                     --30
70
    (3, 0, -1, -1),                     --31
71
    (28, 27, 1, 0),                     --32
72
    (13, 0, -1, -1),                    --33
73
    (15, 14, 1, 0),                     --34
74
    (2, 0, -1, -1),                     --35
75
    (11, 0, -1, -1));                   --36
76
  signal ak_test : std_logic_vector(width_g-1 downto 0);
77
begin
78
  p0 : process (clk, rst_n) is
79
    variable reg      : std_logic_vector(width_g-1 downto 0);
80
    variable feedback : std_logic;
81
  begin
82
    if rst_n = '0' then
83
      reg     := (others => '1');
84
--      q_out   <= (others => '0');
85
      ak_test <= (others => '1');
86
    elsif  clk'event and clk = '1' then
87
      if enable_in = '1' then
88
        feedback := ak_test(taps(width_g, 1));
89
        for i in 2 to 4 loop
90
          if taps(width_g, i) >= 0 then
91
            feedback := feedback xor ak_test(taps(width_g, i));
92
          end if;
93
        end loop;
94
        reg     := feedback & reg(width_g-1 downto 1);
95
        ak_test <= reg;
96
      else
97
        ak_test <= ak_test;
98
      end if;
99
    end if;
100
  end process p0;
101
    q_out <= ak_test;
102
 
103
end architecture rtl;
104
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.