Merged r5566:5676 from jcorgan/snd into trunk, with minor changes. Component gr...
[debian/gnuradio] / gr-sounder / src / fpga / lib / lfsr_constants.v
1 // -*- verilog -*-
2 //
3 //  USRP - Universal Software Radio Peripheral
4 //
5 //  Copyright (C) 2007 Corgan Enterprises LLC
6 //
7 //  This program is free software; you can redistribute it and/or modify
8 //  it under the terms of the GNU General Public License as published by
9 //  the Free Software Foundation; either version 2 of the License, or
10 //  (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 51 Franklin Street, Boston, MA  02110-1301  USA
20 //
21
22 module lfsr_constants(clk_i,rst_i,degree_i,mask_o,len_o);
23    input             clk_i;
24    input             rst_i;
25    input      [4:0]  degree_i;
26    output reg [15:0] mask_o;
27    output reg [16:0] len_o;
28
29    integer len;
30    
31    always @(posedge clk_i)
32      if (rst_i)
33        begin
34           len_o <= #5 17'b0;
35           mask_o <= #5 16'b0;
36        end
37      else
38        begin
39           len_o <= #5 ((1 << degree_i) << 1)-3;
40           
41           case (degree_i)
42             5'd00: mask_o <= #5 16'h0000;
43             5'd01: mask_o <= #5 16'h0001;
44             5'd02: mask_o <= #5 16'h0003;
45             5'd03: mask_o <= #5 16'h0005;
46             5'd04: mask_o <= #5 16'h0009;
47             5'd05: mask_o <= #5 16'h0012;
48             5'd06: mask_o <= #5 16'h0021;
49             5'd07: mask_o <= #5 16'h0041;
50             5'd08: mask_o <= #5 16'h008E;
51             5'd09: mask_o <= #5 16'h0108;
52             5'd10: mask_o <= #5 16'h0204;
53             5'd11: mask_o <= #5 16'h0402;
54             5'd12: mask_o <= #5 16'h0829;
55             5'd13: mask_o <= #5 16'h100D;
56             5'd14: mask_o <= #5 16'h2015;
57             5'd15: mask_o <= #5 16'h4001;
58             5'd16: mask_o <= #5 16'h8016;
59             default: mask_o <= #5 16'h0000;
60           endcase // case(degree_i)
61        end // else: !if(rst_i)
62
63 endmodule // lfsr_constants