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/] [2.0/] [vhd/] [lfsr.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Funbase IP library Copyright (C) 2011 TUT Department of Computer Systems
3
--
4
-- This source file may be used and distributed without
5
-- restriction provided that this copyright statement is not
6
-- removed from the file and that any derivative work contains
7
-- the original copyright notice and the associated disclaimer.
8
--
9
-- This source file is free software; you can redistribute it
10
-- and/or modify it under the terms of the GNU Lesser General
11
-- Public License as published by the Free Software Foundation;
12
-- either version 2.1 of the License, or (at your option) any
13
-- later version.
14
--
15
-- This source is distributed in the hope that it will be
16
-- useful, but WITHOUT ANY WARRANTY; without even the implied
17
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18
-- PURPOSE.  See the GNU Lesser General Public License for more
19
-- details.
20
--
21
-- You should have received a copy of the GNU Lesser General
22
-- Public License along with this source; if not, download it
23
-- from http://www.opencores.org/lgpl.shtml
24
-------------------------------------------------------------------------------
25
---------------------------------------------------------------------
26
-- Design unit: lfsr(rtl) (Entity and Architecture)
27
--            :
28
-- File name  : lfsr.vhd
29
--            :
30
-- Description: RTL model of LFSR
31
--            :
32
-- Limitations: None
33
--            : 
34
-- System     : VHDL'93, STD_LOGIC_1164
35
--            :
36
-- Author     : Mark Zwolinski
37
--            : Department of Electronics and Computer Science
38
--            : University of Southampton
39
--            : Southampton SO17 1BJ, UK
40
--            : mz@ecs.soton.ac.uk
41
--
42
-- Revision   : Version 1.0 08/03/00
43
-- 09.05.2007 AK Corrected this handless-implementation... uses 0.5x register
44
-- compared to original.
45
---------------------------------------------------------------------
46
 
47
library ieee;
48
use ieee.std_logic_1164.all;
49
entity lfsr is
50
  generic(
51
    width_g : integer range 1 to 36 := 8
52
    );
53
  port(
54
    rst_n     : in  std_logic;
55
    enable_in : in  std_logic;
56
    q_out     : out std_logic_vector(width_g-1 downto 0);
57
    clk       : in  std_logic
58
    );
59
end entity lfsr;
60
 
61
architecture rtl of lfsr is
62
  type tap_table is array (1 to 36, 1 to 4) of
63
    integer range -1 to 36;
64
  constant taps : tap_table := (
65
    (0, -1, -1, -1),                    -- 1
66
    (1, 0, -1, -1),                     -- 2
67
    (1, 0, -1, -1),                     -- 3
68
    (1, 0, -1, -1),                     -- 4
69
    (2, 0, -1, -1),                     -- 5
70
    (1, 0, -1, -1),                     -- 6
71
    (1, 0, -1, -1),                     -- 7
72
    (6, 5, 1, 0),                       -- 8
73
    (4, 0, -1, -1),                     -- 9
74
    (3, 0, -1, -1),                     --10
75
    (2, 0, -1, -1),                     --11
76
    (7, 4, 3, 0),                       --12
77
    (4, 3, 1, 0),                       --13
78
    (12, 11, 1, 0),                     --14
79
    (1, 0, -1, -1),                     --15
80
    (5, 3, 2, 0),                       --16
81
    (3, 0, -1, -1),                     --17
82
    (7, 0, -1, -1),                     --18
83
    (6, 5, 1, 0),                       --19
84
    (3, 0, -1, -1),                     --20
85
    (2, 0, -1, -1),                     --21
86
    (1, 0, -1, -1),                     --22
87
    (5, 0, -1, -1),                     --23
88
    (4, 3, 1, 0),                       --24
89
    (3, 0, -1, -1),                     --25
90
    (8, 7, 1, 0),                       --26
91
    (8, 7, 1, 0),                       --27
92
    (3, 0, -1, -1),                     --28
93
    (2, 0, -1, -1),                     --29
94
    (16, 15, 1, 0),                     --30
95
    (3, 0, -1, -1),                     --31
96
    (28, 27, 1, 0),                     --32
97
    (13, 0, -1, -1),                    --33
98
    (15, 14, 1, 0),                     --34
99
    (2, 0, -1, -1),                     --35
100
    (11, 0, -1, -1));                   --36
101
  signal ak_test : std_logic_vector(width_g-1 downto 0);
102
begin
103
  p0 : process (clk, rst_n) is
104
    variable reg      : std_logic_vector(width_g-1 downto 0);
105
    variable feedback : std_logic;
106
  begin
107
    if rst_n = '0' then
108
      reg     := (others => '1');
109
--      q_out   <= (others => '0');
110
      ak_test <= (others => '1');
111
    elsif  clk'event and clk = '1' then
112
      if enable_in = '1' then
113
        feedback := ak_test(taps(width_g, 1));
114
        for i in 2 to 4 loop
115
          if taps(width_g, i) >= 0 then
116
            feedback := feedback xor ak_test(taps(width_g, i));
117
          end if;
118
        end loop;
119
        reg     := feedback & reg(width_g-1 downto 1);
120
        ak_test <= reg;
121
      else
122
        ak_test <= ak_test;
123
      end if;
124
    end if;
125
  end process p0;
126
    q_out <= ak_test;
127
 
128
end architecture rtl;
129
 

powered by: WebSVN 2.1.0

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