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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [basal/] [src/] [PRBS/] [prbs_23_to_8.v] - Blame information for rev 49

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
//-----------------------------------------------------------------------------
2
// Copyright (C) 2009 OutputLogic.com 
3
// This source file may be used and distributed without restriction 
4
// provided that this copyright statement is not removed from the file 
5
// and that any derivative work contains the original copyright notice 
6
// and the associated disclaimer. 
7
// 
8
// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS 
9
// OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 
10
// WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
11
//-----------------------------------------------------------------------------
12
// scrambler module for data[7:0],   lfsr[22:0]=1+x^18+x^23;
13
//-----------------------------------------------------------------------------
14
module prbs_23_to_8(
15
  input [7:0] data_in,
16
  input scram_en,
17
  input scram_rst,
18
  output reg [7:0] data_out,
19
  input rst,
20
  input clk);
21
 
22
  reg [22:0] lfsr_q,lfsr_c;
23
  reg [7:0] data_c;
24
 
25
  always @( * ) begin
26
    lfsr_c[0] = lfsr_q[15] ^ lfsr_q[20];
27
    lfsr_c[1] = lfsr_q[16] ^ lfsr_q[21];
28
    lfsr_c[2] = lfsr_q[17] ^ lfsr_q[22];
29
    lfsr_c[3] = lfsr_q[18];
30
    lfsr_c[4] = lfsr_q[19];
31
    lfsr_c[5] = lfsr_q[20];
32
    lfsr_c[6] = lfsr_q[21];
33
    lfsr_c[7] = lfsr_q[22];
34
    lfsr_c[8] = lfsr_q[0];
35
    lfsr_c[9] = lfsr_q[1];
36
    lfsr_c[10] = lfsr_q[2];
37
    lfsr_c[11] = lfsr_q[3];
38
    lfsr_c[12] = lfsr_q[4];
39
    lfsr_c[13] = lfsr_q[5];
40
    lfsr_c[14] = lfsr_q[6];
41
    lfsr_c[15] = lfsr_q[7];
42
    lfsr_c[16] = lfsr_q[8];
43
    lfsr_c[17] = lfsr_q[9];
44
    lfsr_c[18] = lfsr_q[10] ^ lfsr_q[15] ^ lfsr_q[20];
45
    lfsr_c[19] = lfsr_q[11] ^ lfsr_q[16] ^ lfsr_q[21];
46
    lfsr_c[20] = lfsr_q[12] ^ lfsr_q[17] ^ lfsr_q[22];
47
    lfsr_c[21] = lfsr_q[13] ^ lfsr_q[18];
48
    lfsr_c[22] = lfsr_q[14] ^ lfsr_q[19];
49
 
50
    data_c[0] = data_in[0] ^ lfsr_q[22];
51
    data_c[1] = data_in[1] ^ lfsr_q[21];
52
    data_c[2] = data_in[2] ^ lfsr_q[20];
53
    data_c[3] = data_in[3] ^ lfsr_q[19];
54
    data_c[4] = data_in[4] ^ lfsr_q[18];
55
    data_c[5] = data_in[5] ^ lfsr_q[17] ^ lfsr_q[22];
56
    data_c[6] = data_in[6] ^ lfsr_q[16] ^ lfsr_q[21];
57
    data_c[7] = data_in[7] ^ lfsr_q[15] ^ lfsr_q[20];
58
  end // always
59
 
60
  always @(posedge clk, posedge rst) begin
61
    if(rst) begin
62
      lfsr_q <= {23{1'b1}};
63
      data_out <= {8{1'b0}};
64
    end
65
    else begin
66
      lfsr_q <= scram_rst ? {23{1'b1}} : scram_en ? lfsr_c : lfsr_q;
67
      data_out <= scram_en ? data_c : data_out;
68
    end
69
  end // always
70
endmodule // scrambler

powered by: WebSVN 2.1.0

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