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

Subversion Repositories ata

[/] [ata/] [trunk/] [rtl/] [vhdl/] [ocidec3/] [atahost_lfsr.vhd] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 rherveille
---------------------------------------------------------------------
2
----                                                             ----
3
----  OpenCores IDE Controller                                   ----
4
----  Linear Feedback Shift Register                             ----
5
----                                                             ----
6
----  Author: Richard Herveille                                  ----
7
----          richard@asics.ws                                   ----
8
----          www.asics.ws                                       ----
9
----                                                             ----
10
---------------------------------------------------------------------
11
----                                                             ----
12
---- Copyright (C) 2001, 2002 Richard Herveille                  ----
13
----                          richard@asics.ws                   ----
14
----                                                             ----
15
---- This source file may be used and distributed without        ----
16
---- restriction provided that this copyright statement is not   ----
17
---- removed from the file and that any derivative work contains ----
18
---- the original copyright notice and the associated disclaimer.----
19
----                                                             ----
20
----     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ----
21
---- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ----
22
---- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ----
23
---- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ----
24
---- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ----
25
---- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ----
26
---- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ----
27
---- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ----
28
---- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ----
29
---- LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ----
30
---- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ----
31
---- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ----
32
---- POSSIBILITY OF SUCH DAMAGE.                                 ----
33
----                                                             ----
34
---------------------------------------------------------------------
35
 
36
-- rev.: 1.0 march 12th, 2001. Initial release
37
--
38
--  CVS Log
39
--
40
--  $Id: atahost_lfsr.vhd,v 1.1 2002-02-18 14:32:12 rherveille Exp $
41
--
42
--  $Date: 2002-02-18 14:32:12 $
43
--  $Revision: 1.1 $
44
--  $Author: rherveille $
45
--  $Locker:  $
46
--  $State: Exp $
47
--
48
-- Change History:
49
--               $Log: not supported by cvs2svn $
50
--
51
 
52
library ieee;
53
use ieee.std_logic_1164.all;
54
use ieee.std_logic_arith.all;
55
 
56
entity atahost_lfsr is
57
        generic(
58
                TAPS : positive range 16 downto 3 :=8;
59
                OFFSET : natural := 0
60
        );
61
        port(
62
                clk : in std_logic;                 -- clock input
63
                ena : in std_logic;                 -- count enable
64
                nReset : in std_logic;              -- asynchronous active low reset
65
                rst : in std_logic;                 -- synchronous active high reset
66
 
67
                Q : out unsigned(TAPS downto 1);    -- count value
68
                Qprev : out unsigned(TAPS downto 1) -- previous count value
69
        );
70
end entity atahost_lfsr;
71
 
72
architecture dataflow of atahost_lfsr is
73
        function lsb(tap : positive range 16 downto 3; Q : unsigned(TAPS downto 1) ) return std_logic is
74
        begin
75
                case tap is
76
                        when 3 =>
77
                                return Q(3) xnor Q(2);
78
                        when 4 =>
79
                                return Q(4) xnor Q(3);
80
                        when 5 =>
81
                                return Q(5) xnor Q(3);
82
                        when 6 =>
83
                                return Q(6) xnor Q(5);
84
                        when 7 =>
85
                                return Q(7) xnor Q(6);
86
                        when 8 =>
87
                                return (Q(8) xnor Q(6)) xnor (Q(5) xnor Q(4));
88
                        when 9 =>
89
                                return Q(9) xnor Q(5);
90
                        when 10 =>
91
                                return Q(10) xnor Q(7);
92
                        when 11 =>
93
                                return Q(11) xnor Q(9);
94
                        when 12 =>
95
                                return (Q(12) xnor Q(6)) xnor (Q(4) xnor Q(1));
96
                        when 13 =>
97
                                return (Q(13) xnor Q(4)) xnor (Q(3) xnor Q(1));
98
                        when 14 =>
99
                                return (Q(14) xnor Q(5)) xnor (Q(3) xnor Q(1));
100
                        when 15 =>
101
                                return Q(15) xnor Q(14);
102
                        when 16 =>
103
                                return (Q(16) xnor Q(15)) xnor (Q(13) xnor Q(4));
104
                end case;
105
        end function lsb;
106
 
107
        signal msb : std_logic;
108
        signal iQ : unsigned(TAPS downto 1);
109
 
110
begin
111
        --
112
        --      generate register
113
        --
114
        gen_regs: process(clk, nReset)
115
                variable tmpQ : unsigned(TAPS downto 1);
116
                variable tmpmsb : std_logic;
117
        begin
118
                tmpQ := (others => '0');
119
                tmpmsb := '1';
120
 
121
                for n in 1 to offset loop
122
                        tmpQ := (tmpQ(TAPS -1 downto 1) & lsb(TAPS, tmpQ) );
123
                        tmpmsb := tmpQ(TAPS);
124
                end loop;
125
 
126
                if (nReset = '0') then
127
                        iQ <= tmpQ;
128
                        msb <= tmpmsb;
129
                elsif (clk'event and clk = '1') then
130
                        if (rst = '1') then
131
                                iQ <= tmpQ;
132
                                msb <= tmpmsb;
133
                        elsif (ena = '1') then
134
                                iQ <= (iQ(TAPS -1 downto 1) & lsb(TAPS, iq) );
135
                                msb <= iQ(TAPS);
136
                        end if;
137
                end if;
138
        end process gen_regs;
139
 
140
        -- assign outputs
141
        Q <= iQ;
142
        Qprev <= (msb & iQ(TAPS downto 2));
143
end architecture dataflow;
144
 

powered by: WebSVN 2.1.0

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