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

Subversion Repositories dvb_s2_ldpc_decoder

[/] [dvb_s2_ldpc_decoder/] [trunk/] [rtl/] [ldpc_shuffle.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jcorley
//-------------------------------------------------------------------------
2
//
3
// File name    :  ldpc_shuffle.v
4
// Title        :
5
//              :
6
// Purpose      : Barrel-rotate of NUINSTANCES, LLRWIDTH-bit inputs
7
//
8
// ----------------------------------------------------------------------
9
// Revision History :
10
// ----------------------------------------------------------------------
11
//   Ver  :| Author   :| Mod. Date   :| Changes Made:
12
//   v1.0  | JTC      :| 2008/07/02  :|
13
// ----------------------------------------------------------------------
14
`timescale 1ns/10ps
15
 
16
module ldpc_shuffle #(
17
  parameter FOLDFACTOR     = 4,
18
  parameter NUMINSTANCES   = 360/FOLDFACTOR,
19
  parameter LOG2INSTANCES  = 10 - FOLDFACTOR,
20
  parameter LLRWIDTH       = 4,
21
  parameter LASTSHIFTWIDTH = 3,
22
  parameter LASTSHIFTDIST  = 6
23
)(
24
  input clk,
25
  input rst,
26
 
27
  // control inputs
28
  input                     first_half,
29
  input[1:0]                shift0,
30
  input[2:0]                shift1,
31
  input[LASTSHIFTWIDTH-1:0] shift2,
32
 
33
  // message I/O
34
  input[NUMINSTANCES*LLRWIDTH-1:0]  vn_concat,
35
  input[NUMINSTANCES*LLRWIDTH-1:0]  cn_concat,
36
  output[NUMINSTANCES*LLRWIDTH-1:0] sh_concat
37
);
38
 
39
/*----------------*
40
 * Shift stage 0  *
41
 *----------------*/
42
wire[LLRWIDTH-1:0]     unshifted[NUMINSTANCES-1:0];
43
wire[LLRWIDTH-1:0]     shifted_0[NUMINSTANCES-1:0];
44
 
45
// convert to 2-d array to make simulation easier to follow, and mux vn/cn msgs
46
generate
47
  genvar vecpos;
48
 
49
  for( vecpos=0; vecpos<NUMINSTANCES; vecpos=vecpos+1 )
50
  begin: to2d
51
    assign unshifted[vecpos] =
52
      first_half ? vn_concat[vecpos*LLRWIDTH+LLRWIDTH-1 -: LLRWIDTH]
53
                 : cn_concat[vecpos*LLRWIDTH+LLRWIDTH-1 -: LLRWIDTH];
54
  end
55
endgenerate
56
 
57
// shift distance is shift0* SHIFT0_MULT, where SHIFT0_MULT=
58
// ceiling(360/FOLDFACTOR/4)
59
localparam SHIFT0_MULT = (FOLDFACTOR==1) ? 90 :
60
                         (FOLDFACTOR==2) ? 45 :
61
                         (FOLDFACTOR==3) ? 30 :
62
                         /* 4 */           23;
63
 
64
generate
65
  genvar pos0;
66
 
67
  for( pos0=0; pos0<NUMINSTANCES; pos0=pos0+1 )
68
  begin: quartershift
69
    wire[4*LLRWIDTH-1:0] muxinp0;
70
 
71
    assign muxinp0 = { unshifted[(NUMINSTANCES+pos0-3*SHIFT0_MULT) %NUMINSTANCES],
72
                       unshifted[(NUMINSTANCES+pos0-2*SHIFT0_MULT) %NUMINSTANCES],
73
                       unshifted[(NUMINSTANCES+pos0-  SHIFT0_MULT) %NUMINSTANCES],
74
                       unshifted[pos0]  };
75
 
76
    ldpc_muxreg #(
77
      .LLRWIDTH(LLRWIDTH),
78
      .NUMINPS (4),
79
      .MUXSIZE (4),
80
      .SELBITS (2)
81
    ) ldpc_muxregi (
82
      .clk( clk ),
83
      .rst( rst ),
84
      .sel( shift0 ),
85
      .din( muxinp0 ),
86
      .dout( shifted_0[pos0] )
87
    );
88
  end
89
endgenerate
90
 
91
/*----------------*
92
 * Shift stage 1  *
93
 *----------------*/
94
wire[LLRWIDTH-1:0]     shifted_1[NUMINSTANCES-1:0];
95
 
96
// shift distance is shift1* SHIFT1_MULT, where SHIFT1_MULT=
97
// ceiling(360/FOLDFACTOR/4/8)
98
localparam SHIFT1_MULT = (FOLDFACTOR==1) ? 12 :
99
                         (FOLDFACTOR==2) ? 6  :
100
                         (FOLDFACTOR==3) ? 4  :
101
                         /* 4 */           3;
102
 
103
generate
104
  genvar pos1;
105
 
106
  for( pos1=0; pos1<NUMINSTANCES; pos1=pos1+1 )
107
  begin: middleshift
108
    wire[8*LLRWIDTH-1:0] muxinp1;
109
 
110
    assign muxinp1 = { shifted_0[(NUMINSTANCES+pos1-7*SHIFT1_MULT) %NUMINSTANCES],
111
                       shifted_0[(NUMINSTANCES+pos1-6*SHIFT1_MULT) %NUMINSTANCES],
112
                       shifted_0[(NUMINSTANCES+pos1-5*SHIFT1_MULT) %NUMINSTANCES],
113
                       shifted_0[(NUMINSTANCES+pos1-4*SHIFT1_MULT) %NUMINSTANCES],
114
                       shifted_0[(NUMINSTANCES+pos1-3*SHIFT1_MULT) %NUMINSTANCES],
115
                       shifted_0[(NUMINSTANCES+pos1-2*SHIFT1_MULT) %NUMINSTANCES],
116
                       shifted_0[(NUMINSTANCES+pos1-  SHIFT1_MULT) %NUMINSTANCES],
117
                       shifted_0[pos1]  };
118
 
119
    ldpc_muxreg #(
120
      .LLRWIDTH(LLRWIDTH),
121
      .NUMINPS (8),
122
      .MUXSIZE (8),
123
      .SELBITS (3)
124
    ) ldpc_muxregi (
125
      .clk( clk ),
126
      .rst( rst ),
127
      .sel( shift1 ),
128
      .din( muxinp1 ),
129
      .dout( shifted_1[pos1] )
130
    );
131
  end
132
endgenerate
133
 
134
/*----------------*
135
 * Shift stage 2  *
136
 *----------------*/
137
// This stage is a little more complicated than the others, since there is a
138
// maximum shift distance
139
wire[LLRWIDTH-1:0]    shifted_2[NUMINSTANCES-1:0];
140
reg[NUMINSTANCES-1:0] increment_int;
141
 
142
generate
143
  genvar pos2;
144
 
145
  for( pos2=0; pos2<NUMINSTANCES; pos2=pos2+1 )
146
  begin: lastshift
147
    wire[12*LLRWIDTH-1:0] muxinp2;
148
 
149
    assign muxinp2 = { shifted_1[(NUMINSTANCES+pos2-11) %NUMINSTANCES],
150
                       shifted_1[(NUMINSTANCES+pos2-10) %NUMINSTANCES],
151
                       shifted_1[(NUMINSTANCES+pos2-9)  %NUMINSTANCES],
152
                       shifted_1[(NUMINSTANCES+pos2-8)  %NUMINSTANCES],
153
                       shifted_1[(NUMINSTANCES+pos2-7)  %NUMINSTANCES],
154
                       shifted_1[(NUMINSTANCES+pos2-6)  %NUMINSTANCES],
155
                       shifted_1[(NUMINSTANCES+pos2-5)  %NUMINSTANCES],
156
                       shifted_1[(NUMINSTANCES+pos2-4)  %NUMINSTANCES],
157
                       shifted_1[(NUMINSTANCES+pos2-3)  %NUMINSTANCES],
158
                       shifted_1[(NUMINSTANCES+pos2-2)  %NUMINSTANCES],
159
                       shifted_1[(NUMINSTANCES+pos2-1)  %NUMINSTANCES],
160
                       shifted_1[pos2]  };
161
 
162
    ldpc_muxreg #(
163
      .LLRWIDTH(LLRWIDTH),
164
      .NUMINPS (12),
165
      .MUXSIZE ((LASTSHIFTDIST+1)),
166
      .SELBITS (LASTSHIFTWIDTH)
167
    ) ldpc_muxregi (
168
      .clk( clk ),
169
      .rst( rst ),
170
      .sel( shift2 ),
171
      .din( muxinp2 ),
172
      .dout( shifted_2[pos2] )
173
    );
174
  end
175
endgenerate
176
 
177
// assign 2-d array to 1-d output port
178
generate
179
  genvar ovecpos;
180
 
181
  for( ovecpos=0; ovecpos<NUMINSTANCES; ovecpos=ovecpos+1 )
182
  begin: to1d
183
    assign sh_concat[ovecpos*LLRWIDTH+LLRWIDTH-1 -: LLRWIDTH] =
184
              shifted_2[ovecpos];
185
  end
186
endgenerate
187
 
188
// decode
189
localparam SECTION_LEN = (FOLDFACTOR==1) ? 90 :
190
                         (FOLDFACTOR==2) ? 45 :
191
                         (FOLDFACTOR==3) ? 30 :
192
                                           23;
193
function[SECTION_LEN-1:0] Decoder( input[LOG2INSTANCES-3:0] incpointxx );
194
  integer position;
195
begin
196
  Decoder[0] = incpointxx==0;
197
 
198
  for( position=1; position<SECTION_LEN; position=position+1 )
199
    Decoder[position] = (incpointxx==position) || Decoder[position-1];
200
end
201
endfunction
202
 
203
endmodule

powered by: WebSVN 2.1.0

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