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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [rtl/] [lib/] [lfsr.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2003-2018  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@finitron.ca
6
//       ||
7
//
8
//      lfsr.v
9
//  - linear feedback shift register
10
//  - parameterized
11
//              
12
//
13
// This source file is free software: you can redistribute it and/or modify 
14
// it under the terms of the GNU Lesser General Public License as published 
15
// by the Free Software Foundation, either version 3 of the License, or     
16
// (at your option) any later version.                                      
17
//                                                                          
18
// This source file is distributed in the hope that it will be useful,      
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
21
// GNU General Public License for more details.                             
22
//                                                                          
23
// You should have received a copy of the GNU General Public License        
24
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
25
//                                                                          
26
//
27
// ============================================================================
28
//
29
module lfsr(rst, clk, ce, cyc, o);
30
        parameter WID=17;
31
        parameter RST_VAL=0;
32
        localparam MSB=WID-1;
33
 
34
        input rst;
35
        input clk;
36
        input ce;
37
        input cyc;                              // shorten the feedback cycle
38
        output [WID:1] o;
39
 
40
        reg [WID:0] c;
41
        reg [23:0] n;
42
        assign o = c[WID:1];
43
 
44
        always @(posedge clk) begin
45
                case (WID)
46
                3:      n <= 24'h00_0003;
47
                4:      n <= 24'h00_0004;
48
                5:      n <= 24'h00_0003;
49
                6:      n <= 24'h00_0005;
50
                7:      n <= 24'h00_0006;
51
                8:      n <= 24'h06_0504;
52
                9:      n <= 24'h00_0005;
53
                10:     n <= 24'h00_0007;
54
                11:     n <= 24'h00_0009;
55
                12:     n <= 24'h06_0401;
56
                13:     n <= 24'h04_0301;
57
                14:     n <= 24'h05_0301;
58
                15:     n <= 24'h00_000E;
59
                16:     n <= 24'h0F_0D04;
60
                17: n <= 24'h00_000E;
61
                18: n <= 24'h00_000B;
62
                19: n <= 24'h06_0201;
63
                20: n <= 24'h00_0011;
64
                21: n <= 24'h00_0013;
65
                22:     n <= 24'h00_0015;
66
                23: n <= 24'h00_0012;
67
                24:     n <= 24'h17_1611;
68
                25: n <= 24'h00_0016;
69
                26: n <= 24'h06_0201;
70
                27: n <= 24'h05_0201;
71
                28: n <= 24'h00_0019;
72
                29: n <= 24'h00_001B;
73
                30: n <= 24'h06_0401;
74
                31: n <= 24'h00_001C;
75
                default:
76
                        n <= 24'h00_0000;
77
                endcase
78
        end
79
 
80
 
81
        always @(posedge clk)
82
                if (rst)
83
                        c <= RST_VAL;
84
                else if (ce)
85
                        c <= {c[MSB:0],~(c[WID]^c[n[23:16]]^c[n[15:8]]^c[n[7:0]]^cyc)};
86
 
87
endmodule
88
 

powered by: WebSVN 2.1.0

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