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

Subversion Repositories reed_solomon_decoder

[/] [reed_solomon_decoder/] [trunk/] [rtl/] [GF_mult_add_syndromes.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 aelmahmoud
 
2
/* This program is free software: you can redistribute it and/or modify
3
   it under the terms of the GNU General Public License as published by
4
   the Free Software Foundation, either version 3 of the License, or
5
   (at your option) any later version.
6
 
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
 
12
   You should have received a copy of the GNU General Public License
13
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 
15
   Email : semiconductors@varkongroup.com
16
   Tel   : 1-732-447-8611
17
 
18
*/
19
 
20
 
21
 
22
 
23
 
24
 
25
 
26
/// module to calculate syndromes by doing GF_multiply 
27
// then add outputs of multipliaction
28
module GF_mult_add_syndromes
29
(
30
input clk,
31
input reset,
32
input CE,
33
input [7:0] ip1,ip2,   /// power format
34
input [2:0] count_in, // input number
35
/// active high flag will be active for one clock when S of the RS_block is ready
36
output reg S_Ready,
37
output reg [7:0] S   /// decimal format output syndromes value
38
);
39
 
40
 
41
reg [8:0] add_inputs;
42
reg [7:0] out_GF_mult_0;
43
 
44
 
45
reg [7:0] address_GF_dec;
46
wire[7:0] out_GF_dec;
47
 
48
reg [7:0] xor_reg0,xor_reg1,xor_reg2,xor_reg3,xor_reg4,xor_reg5,xor_reg6,xor_reg7;
49
 
50
reg [7:0] cnt203_0,cnt203_1,cnt203_2,cnt203_3,cnt203_4,cnt203_5,cnt203_6,cnt203_7;
51
 
52
 
53
 
54
reg CE1;
55
//////////////////////GF_matrix_dec Rom //////////////////////////
56
GF_matrix_dec rom_instant
57
(
58
.clk(clk),
59
.re(CE || CE1),
60
.address_read(address_GF_dec),
61
.data_out(out_GF_dec)
62
);
63
//////////////////////////////////////////////////////////////////
64
 
65
 
66
 
67
reg [7:0] ip1_0;
68
reg [2:0] count_in0,count_in1,count_in2,count_in3;
69
reg F; // to indicate if ip1_0 is FF or not
70
////////////////////////GF_Multiply and accumilation //////////////
71
always@(posedge clk or posedge reset)
72
begin
73
        if (reset)
74
                begin
75
                        add_inputs<=0;
76
                        out_GF_mult_0<=0;
77
                        address_GF_dec<=0;
78
 
79
                        xor_reg0<=0;xor_reg1<=0;xor_reg2<=0;xor_reg3<=0;
80
                        xor_reg4<=0;xor_reg5<=0;xor_reg6<=0;xor_reg7<=0;
81
 
82
                        cnt203_0<=204;cnt203_1<=204;cnt203_2<=204;cnt203_3<=204;
83
                        cnt203_4<=204;cnt203_5<=204;cnt203_6<=204;cnt203_7<=204;
84
 
85
                        S_Ready<=0;
86
                        S<=0;
87
                        F<=1;
88
                        ip1_0<=8'hFF;
89
 
90
                        count_in0<=0;count_in1<=0;count_in2<=0;count_in3<=0;
91
                        CE1<=1;
92
                end
93
        else
94
                begin
95
                        if(CE)
96
                                begin
97
                                        CE1<=0;
98
                                        //======> 1st reg level---------------------------------
99
                                        ip1_0<=ip1;
100
                                        count_in0<=count_in;
101
                                        add_inputs <= ip1+ip2;  //// 9 bits adding
102
 
103
                                        //  ======> 2nd reg level -----------------------------------
104
                                        out_GF_mult_0<=add_inputs[7:0]+add_inputs[8];
105
                                        count_in1<=count_in0;
106
 
107
                                        if (&ip1_0)
108
                                        /// to make output take first value in GF_matrix_dec in this case ip1_0 == FF
109
                                                F<=1;
110
                                        else
111
                                                F<=0;
112
                                        //  ======> 3rd reg level------------------------------------
113
                                        count_in2<=count_in1;
114
                                        address_GF_dec<= (F)? 8'h00:(&out_GF_mult_0)?8'h01:out_GF_mult_0+1;
115
                                        //  ======> 4th reg level in the Rom latency---------------------
116
                                        count_in3<=count_in2;
117
                                //////////////////////////////////////////////////////////////////
118
                                        case (count_in3)
119
                                                4: xor_reg4 <= xor_reg4 ^ out_GF_dec;
120
                                                5: xor_reg5 <= xor_reg5 ^ out_GF_dec;
121
                                                6: xor_reg6 <= xor_reg6 ^ out_GF_dec;
122
                                                7: xor_reg7 <= xor_reg7 ^ out_GF_dec;
123
                                                0: xor_reg0 <= xor_reg0 ^ out_GF_dec;
124
                                                1: xor_reg1 <= xor_reg1 ^ out_GF_dec;
125
                                                2: xor_reg2 <= xor_reg2 ^ out_GF_dec;
126
                                                default: xor_reg3 <= xor_reg3 ^ out_GF_dec;
127
                                        endcase
128
                                ///////////////////////////////////////////////////////////     
129
 
130
                                        //// to make S_ready for only one clock 
131
                                        if (S_Ready)
132
                                                begin
133
                                                        S_Ready<=0;
134
                                                end
135
 
136
                                        //////////////////////////////////////////////////////////
137
                                        /////////////////////////////////////////////////////////
138
                                        /////////////////////////////////////////////////////////
139
                                        case (count_in)
140
                                        ///////////////////////////////////////////////////////
141
                                        0:
142
                                                begin
143
                                                        if (cnt203_0 == 0)
144
                                                                begin
145
                                                                        // start of output values , should be taken after this flag is high
146
                                                                        S_Ready <= 1;
147
                                                                        cnt203_0<=203;
148
                                                                        S<=xor_reg0;
149
                                                                        xor_reg0<=0;
150
                                //// when input frame ends and the first byte of the next frame is 
151
                                //// entered the output syndromes is available
152
                                                                end
153
                                                        else
154
                                                                cnt203_0 <=cnt203_0-1;
155
                                                end
156
                                        ///////////////////////////////////////////////////////////////////////
157
                                        1:
158
                                                begin
159
                                                        if (cnt203_1 == 0)
160
                                                                begin
161
                                                                        cnt203_1<=203;
162
                                                                        S<=xor_reg1;
163
                                                                        xor_reg1<=0;
164
                                                                        //// when input frame ends and the first byte of the next
165
                                                                        ////frame is entered the output syndromes is available
166
                                                                end
167
                                                        else
168
                                                                cnt203_1<=cnt203_1-1;
169
                                                end
170
                                        ///////////////////////////////////////////////////////////////
171
                                        2:
172
                                                begin
173
                                                        if (cnt203_2 == 0)
174
                                                                begin
175
                                                                        cnt203_2<=203;
176
                                                                        S<=xor_reg2;
177
                                                                        xor_reg2<=0;
178
                                                                        //// when input frame ends and the first byte 
179
                                                                        //of the next frame is entered the output syndromes is available
180
                                                                end
181
                                                        else
182
                                                                cnt203_2<=cnt203_2-1;
183
                                                end
184
                                        ///////////////////////////////////////////////////////////////////////
185
                                        3:
186
                                                begin
187
                                                        if (cnt203_3 == 0)
188
                                                                begin
189
                                                                        cnt203_3<=203;
190
                                                                        S<=xor_reg3;
191
                                                                        xor_reg3<=0;
192
                                                                        //// when input frame ends and the first byte
193
                                                                        ///of the next frame is entered the output syndromes is available
194
                                                                end
195
                                                        else
196
                                                                cnt203_3<=cnt203_3-1;
197
                                                end
198
                                        //////////////////////////////////////////////////////////////////////
199
                                        4:
200
                                                begin
201
                                                        if (cnt203_4 == 0)
202
                                                                begin
203
                                                                        cnt203_4<=203;
204
                                                                        S<=xor_reg4;
205
                                                                        xor_reg4<=0;
206
                                                                        //// when input frame ends and the first byte of
207
                                                                        ////the next frame is entered the output syndromes is available
208
                                                                end
209
                                                        else
210
                                                                cnt203_4<=cnt203_4-1;
211
                                                end
212
                                        ////////////////////////////////////////////////////////////////
213
                                        5:
214
                                                begin
215
                                                        if (cnt203_5 == 0)
216
                                                                begin
217
                                                                        cnt203_5<=203;
218
                                                                        S<=xor_reg5;
219
                                                                        xor_reg5<=0;
220
                                                                        //// when input frame ends and the first byte
221
                                                                        ////of the next frame is entered the output syndromes is available
222
                                                                end
223
                                                        else
224
                                                                cnt203_5<=cnt203_5-1;
225
                                                end
226
                                        //////////////////////////////////////////////////////////////
227
                                        6:
228
                                                begin
229
                                                        if (cnt203_6 == 0)
230
                                                                begin
231
                                                                        cnt203_6<=203;
232
                                                                        S<=xor_reg6;
233
                                                                        xor_reg6<=0;
234
                                                                        //// when input frame ends and the first byte of 
235
                                                                        ///the next frame is entered the output syndromes is available
236
                                                                end
237
                                                        else
238
                                                                cnt203_6 <=cnt203_6-1;
239
                                                end
240
                                        ///////////////////////////////////////////////////
241
                                        default:
242
                                                begin
243
                                                        if (cnt203_7 == 0)
244
                                                                begin
245
                                                                        cnt203_7<=203;
246
                                                                        S<=xor_reg7;
247
                                                                        xor_reg7<=0;
248
                                                                        //// when input frame ends and the first byte of
249
                                                                        ///the next frame is entered the output syndromes is available
250
                                                                end
251
                                                        else
252
                                                                cnt203_7 <=cnt203_7-1;
253
                                                end
254
                                        //////////////////////////////////////
255
                                        endcase
256
                                /////////////////////////////////////////////////
257
                                /////////////////////////////////////////////////
258
                                ////////////////////////////////////////////////
259
 
260
                                end  // end if CE
261
 
262
                end //end  else
263
end     // end always   
264
//////////////////////////////////////////////////////////////////
265
 
266
endmodule

powered by: WebSVN 2.1.0

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