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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [basal/] [src/] [PRBS/] [prbs_7_to_8.v] - Blame information for rev 34

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[6:0]=1+x^6+x^7;
13
//-----------------------------------------------------------------------------
14
module prbs_7_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 [6:0] lfsr_q,lfsr_c;
23
  reg [7:0] data_c;
24
 
25
  always @( * ) begin
26
    lfsr_c[0] = lfsr_q[0] ^ lfsr_q[1] ^ lfsr_q[2] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5];
27
    lfsr_c[1] = lfsr_q[0] ^ lfsr_q[1] ^ lfsr_q[2] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
28
    lfsr_c[2] = lfsr_q[1] ^ lfsr_q[2] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
29
    lfsr_c[3] = lfsr_q[2] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
30
    lfsr_c[4] = lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
31
    lfsr_c[5] = lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
32
    lfsr_c[6] = lfsr_q[0] ^ lfsr_q[1] ^ lfsr_q[2] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[6];
33
 
34
    data_c[0] = data_in[0] ^ lfsr_q[6];
35
    data_c[1] = data_in[1] ^ lfsr_q[5] ^ lfsr_q[6];
36
    data_c[2] = data_in[2] ^ lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
37
    data_c[3] = data_in[3] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
38
    data_c[4] = data_in[4] ^ lfsr_q[2] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
39
    data_c[5] = data_in[5] ^ lfsr_q[1] ^ lfsr_q[2] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
40
    data_c[6] = data_in[6] ^ lfsr_q[0] ^ lfsr_q[1] ^ lfsr_q[2] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5] ^ lfsr_q[6];
41
    data_c[7] = data_in[7] ^ lfsr_q[0] ^ lfsr_q[1] ^ lfsr_q[2] ^ lfsr_q[3] ^ lfsr_q[4] ^ lfsr_q[5];
42
  end // always
43
 
44
  always @(posedge clk, posedge rst) begin
45
    if(rst) begin
46
      lfsr_q <= {7{1'b1}};
47
      data_out <= {8{1'b0}};
48
    end
49
    else begin
50
      lfsr_q <= scram_rst ? {7{1'b1}} : scram_en ? lfsr_c : lfsr_q;
51
      data_out <= scram_en ? data_c : data_out;
52
    end
53
  end // always
54
endmodule // scrambler
55
 

powered by: WebSVN 2.1.0

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