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

Subversion Repositories nysa_sata

[/] [nysa_sata/] [trunk/] [rtl/] [link/] [scrambler.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 cospan
// Copyright (C) 2012
2
// Ashwin A. Mendon
3
//
4
// This file is part of SATA2 core.
5
//
6
// This program is free software; you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation; either version 3 of the License, or
9
// (at your option) any later version.
10
//
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License
17
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
19
 
20
 
21
////////////////////////////////////////////////////////////////////////////////////////
22
// ENTITY: scrambler
23
// Version: 1.0
24
// Author:  Ashwin Mendon
25
// Description: This sub/module implements the Scrambler Circuit for the SATA Protocol
26
//              The code provides a parallel implementation of the following
27
//              generator polynomial
28
//                          16  15  13  4
29
//                  G(x) = x + x + x + x + 1
30
//              The output of this scrambler is then XORed with the input data DWORD
31
//              The scrambler is initialized to a value of 0xF0F6.
32
//              The first DWORD output of the implementation is equal to 0xC2D2768D
33
// PORTS:
34
/////////////////////////////////////////////////////////////////////////////////////////
35
 
36
 
37
module scrambler (
38
  clk,
39
  rst,
40
  en,
41
  prim_scrambler,
42
  din,
43
  dout
44
);
45
input               clk;
46
input               rst;
47
input               en;
48
input               prim_scrambler;
49
input   [31:0]      din;
50
output  [31:0]      dout;
51
 
52
//Parameters
53
parameter           SCRAMBLER_INIT  = 16'hF0F6;
54
 
55
//Registers/Wires
56
reg     [15:0]      context;
57
wire    [31:0]      context_next;
58
reg     [31:0]      context_reg;
59
 
60
//Synchronous Logic
61
always @ (posedge clk) begin
62
  if (rst) begin
63
    context         <=  SCRAMBLER_INIT;
64
    context_reg     <=  32'h0;
65
  end
66
  else begin
67
    if (en) begin
68
      context         <=  context_next[31:16];
69
      context_reg     <=  context_next;
70
    end
71
  end
72
end
73
 
74
assign  dout           =  (prim_scrambler) ? context_reg : context_reg ^ din;
75
 
76
//Aysnchronous Logic
77
assign context_next[31] =  context[12] ^
78
                           context[10] ^
79
                           context[7]  ^
80
                           context[3]  ^
81
                           context[1]  ^
82
                           context[0];
83
 
84
assign context_next[30] =  context[15] ^
85
                           context[14] ^
86
                           context[12] ^
87
                           context[11] ^
88
                           context[9]  ^
89
                           context[6]  ^
90
                           context[3]  ^
91
                           context[2]  ^
92
                           context[0];
93
 
94
assign context_next[29] =  context[15] ^
95
                           context[13] ^
96
                           context[12] ^
97
                           context[11] ^
98
                           context[10] ^
99
                           context[8]  ^
100
                           context[5]  ^
101
                           context[3]  ^
102
                           context[2]  ^
103
                           context[1];
104
 
105
assign context_next[28] =  context[14] ^
106
                           context[12] ^
107
                           context[11] ^
108
                           context[10] ^
109
                           context[9]  ^
110
                           context[7]  ^
111
                           context[4]  ^
112
                           context[2]  ^
113
                           context[1]  ^
114
                           context[0];
115
 
116
assign context_next[27] =  context[15] ^
117
                           context[14] ^
118
                           context[13] ^
119
                           context[12] ^
120
                           context[11] ^
121
                           context[10] ^
122
                           context[9]  ^
123
                           context[8]  ^
124
                           context[6]  ^
125
                           context[1]  ^
126
                           context[0];
127
 
128
assign context_next[26] =  context[15] ^
129
                           context[13] ^
130
                           context[11] ^
131
                           context[10] ^
132
                           context[9]  ^
133
                           context[8]  ^
134
                           context[7]  ^
135
                           context[5]  ^
136
                           context[3]  ^
137
                           context[0];
138
 
139
assign context_next[25] =  context[15] ^
140
                           context[10] ^
141
                           context[9]  ^
142
                           context[8]  ^
143
                           context[7]  ^
144
                           context[6]  ^
145
                           context[4]  ^
146
                           context[3]  ^
147
                           context[2];
148
 
149
assign context_next[24] =  context[14] ^
150
                           context[9]  ^
151
                           context[8]  ^
152
                           context[7]  ^
153
                           context[6]  ^
154
                           context[5]  ^
155
                           context[3]  ^
156
                           context[2]  ^
157
                           context[1];
158
 
159
assign context_next[23] =  context[13] ^
160
                           context[8]  ^
161
                           context[7]  ^
162
                           context[6]  ^
163
                           context[5]  ^
164
                           context[4]  ^
165
                           context[2]  ^
166
                           context[1]  ^
167
                           context[0];
168
 
169
assign context_next[22] =  context[15] ^
170
                           context[14] ^
171
                           context[7]  ^
172
                           context[6]  ^
173
                           context[5]  ^
174
                           context[4]  ^
175
                           context[1]  ^
176
                           context[0];
177
 
178
assign context_next[21] =  context[15] ^
179
                           context[13] ^
180
                           context[12] ^
181
                           context[6]  ^
182
                           context[5]  ^
183
                           context[4]  ^
184
                           context[0];
185
 
186
assign context_next[20] =  context[15] ^
187
                           context[11] ^
188
                           context[5]  ^
189
                           context[4];
190
 
191
assign context_next[19] =  context[14] ^
192
                           context[10] ^
193
                           context[4]  ^
194
                           context[3];
195
 
196
assign context_next[18] =  context[13] ^
197
                           context[9]  ^
198
                           context[3]  ^
199
                           context[2];
200
 
201
assign context_next[17] =  context[12] ^
202
                           context[8]  ^
203
                           context[2]  ^
204
                           context[1];
205
 
206
assign context_next[16] =  context[11] ^
207
                           context[7]  ^
208
                           context[1]  ^
209
                           context[0];
210
 
211
assign context_next[15] =  context[15] ^
212
                           context[14] ^
213
                           context[12] ^
214
                           context[10] ^
215
                           context[6]  ^
216
                           context[3]  ^
217
                           context[0];
218
 
219
assign context_next[14] =  context[15] ^
220
                           context[13] ^
221
                           context[12] ^
222
                           context[11] ^
223
                           context[9]  ^
224
                           context[5]  ^
225
                           context[3]  ^
226
                           context[2];
227
 
228
assign context_next[13] =  context[14] ^
229
                           context[12] ^
230
                           context[11] ^
231
                           context[10] ^
232
                           context[8]  ^
233
                           context[4]  ^
234
                           context[2]  ^
235
                           context[1];
236
 
237
assign context_next[12] =  context[13] ^
238
                           context[11] ^
239
                           context[10] ^
240
                           context[9]  ^
241
                           context[7]  ^
242
                           context[3]  ^
243
                           context[1]  ^
244
                           context[0];
245
 
246
assign context_next[11] =  context[15] ^
247
                           context[14] ^
248
                           context[10] ^
249
                           context[9] ^
250
                           context[8] ^
251
                           context[6] ^
252
                           context[3] ^
253
                           context[2] ^
254
                           context[0];
255
 
256
assign context_next[10] =  context[15] ^
257
                           context[13] ^
258
                           context[12] ^
259
                           context[9]  ^
260
                           context[8]  ^
261
                           context[7]  ^
262
                           context[5]  ^
263
                           context[3]  ^
264
                           context[2]  ^
265
                           context[1];
266
 
267
assign context_next[9] =   context[14] ^
268
                           context[12] ^
269
                           context[11] ^
270
                           context[8]  ^
271
                           context[7]  ^
272
                           context[6]  ^
273
                           context[4]  ^
274
                           context[2]  ^
275
                           context[1]  ^
276
                           context[0];
277
 
278
assign context_next[8] =   context[15] ^
279
                           context[14] ^
280
                           context[13] ^
281
                           context[12] ^
282
                           context[11] ^
283
                           context[10] ^
284
                           context[7]  ^
285
                           context[6]  ^
286
                           context[5]  ^
287
                           context[1]  ^
288
                           context[0];
289
 
290
assign context_next[7] =   context[15] ^
291
                           context[13] ^
292
                           context[11] ^
293
                           context[10] ^
294
                           context[9]  ^
295
                           context[6]  ^
296
                           context[5]  ^
297
                           context[4]  ^
298
                           context[3]  ^
299
                           context[0];
300
 
301
assign context_next[6] =   context[15] ^
302
                           context[10] ^
303
                           context[9]  ^
304
                           context[8]  ^
305
                           context[5]  ^
306
                           context[4]  ^
307
                           context[2];
308
 
309
assign context_next[5] =   context[14] ^
310
                           context[9]  ^
311
                           context[8]  ^
312
                           context[7]  ^
313
                           context[4]  ^
314
                           context[3]  ^
315
                           context[1];
316
 
317
assign context_next[4] =   context[13] ^
318
                           context[8]  ^
319
                           context[7]  ^
320
                           context[6]  ^
321
                           context[3]  ^
322
                           context[2]  ^
323
                           context[0];
324
 
325
assign context_next[3] =   context[15] ^
326
                           context[14] ^
327
                           context[7]  ^
328
                           context[6]  ^
329
                           context[5]  ^
330
                           context[3]  ^
331
                           context[2]  ^
332
                           context[1];
333
 
334
assign context_next[2] =   context[14] ^
335
                           context[13] ^
336
                           context[6]  ^
337
                           context[5]  ^
338
                           context[4]  ^
339
                           context[2]  ^
340
                           context[1]  ^
341
                           context[0];
342
 
343
assign context_next[1] =   context[15] ^
344
                           context[14] ^
345
                           context[13] ^
346
                           context[5]  ^
347
                           context[4]  ^
348
                           context[1]  ^
349
                           context[0];
350
 
351
assign context_next[0] =   context[15] ^
352
                           context[13] ^
353
                           context[4]  ^
354
                           context[0];
355
 
356
 
357
 
358
 
359
endmodule

powered by: WebSVN 2.1.0

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