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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [rtl/] [hmc_controller/] [tx/] [tx_scrambler.v] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 juko
/*
2
 *                              .--------------. .----------------. .------------.
3
 *                             | .------------. | .--------------. | .----------. |
4
 *                             | | ____  ____ | | | ____    ____ | | |   ______ | |
5
 *                             | ||_   ||   _|| | ||_   \  /   _|| | | .' ___  || |
6
 *       ___  _ __   ___ _ __  | |  | |__| |  | | |  |   \/   |  | | |/ .'   \_|| |
7
 *      / _ \| '_ \ / _ \ '_ \ | |  |  __  |  | | |  | |\  /| |  | | || |       | |
8
 *       (_) | |_) |  __/ | | || | _| |  | |_ | | | _| |_\/_| |_ | | |\ `.___.'\| |
9
 *      \___/| .__/ \___|_| |_|| ||____||____|| | ||_____||_____|| | | `._____.'| |
10
 *           | |               | |            | | |              | | |          | |
11
 *           |_|               | '------------' | '--------------' | '----------' |
12
 *                              '--------------' '----------------' '------------'
13
 *
14
 *  openHMC - An Open Source Hybrid Memory Cube Controller
15
 *  (C) Copyright 2014 Computer Architecture Group - University of Heidelberg
16
 *  www.ziti.uni-heidelberg.de
17
 *  B6, 26
18
 *  68159 Mannheim
19
 *  Germany
20
 *
21
 *  Contact: openhmc@ziti.uni-heidelberg.de
22
 *  http://ra.ziti.uni-heidelberg.de/openhmc
23
 *
24
 *   This source file is free software: you can redistribute it and/or modify
25
 *   it under the terms of the GNU Lesser General Public License as published by
26
 *   the Free Software Foundation, either version 3 of the License, or
27
 *   (at your option) any later version.
28
 *
29
 *   This source file is distributed in the hope that it will be useful,
30
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 *   GNU Lesser General Public License for more details.
33
 *
34
 *   You should have received a copy of the GNU Lesser General Public License
35
 *   along with this source file.  If not, see <http://www.gnu.org/licenses/>.
36
 *
37
 *
38
 *  Module name: tx_scrambler
39
 *
40
 *  Description:
41
 *
42
 *  This module implements a parallel scrambler based on the
43
 *  polynomial 1+ x^(-14) + x^(-15).
44
 *  Such Scrambler is typically shown as a 15 bit Linear Feedback Shift Register
45
 *  (LFSR) with bits shifting from register 1 on the left to register 15 on the
46
 *  right, with register 14 and 15 combining to shift into register 1.
47
 *  The HMC Serializer outputs data[0] first from parallel tx data[n:0],
48
 *  so if data[n:0] is to be bitwise scrambled with LFSR[n:0], we need the LFSR
49
 *  to shift from n -> 0, the opposite direction from the typical illustration.
50
 *  This implementation shifts data from LFSR[14] on the left to LFSR[0] on the
51
 *  right, with LFSR[1] and [0] combining to shift into LFSR[14]. This way
52
 *  LFSR[14:0] can bitwise scramble data[14:0] and be compatible with serializ-
53
 *  ation that shifts out on the data[0] side.
54
 *  Put otherwise: Polynomial 1+ x^(-14) + x^(-15) is equiv to
55
 *  x^15 + x^1 + x^0
56
 *  This parallelized version calculates the next LANE_WIDTH steps of values for
57
 *  the LFSR.  These bits are used to scramble the parallel input, and to
58
 *  choose the next value of lfsr (lfsr_steps[LANE_WIDTH-1]).
59
 */
60
 
61
`default_nettype none
62
 
63
module tx_scrambler #(
64 15 juko
    parameter LANE_WIDTH        = 16,
65 11 juko
    parameter HMC_RX_AC_COUPLED = 1
66
)
67
(
68
    input wire              clk,
69
    input wire              res_n,
70
    input wire              disable_scrambler,
71
    input wire [14:0]       seed, // unique per lane
72
    input wire [LANE_WIDTH-1:0] data_in,
73
    output reg [LANE_WIDTH-1:0] data_out,
74
    input wire              rf_run_length_enable,
75
    output wire             rf_run_length_bit_flip
76
);
77
 
78
//=====================================================================================================
79
//-----------------------------------------------------------------------------------------------------
80
//---------WIRING AND SIGNAL STUFF---------------------------------------------------------------------
81
//-----------------------------------------------------------------------------------------------------
82
//=====================================================================================================
83
wire [LANE_WIDTH-1:0]   data_out_tmp;
84
wire [LANE_WIDTH-1:0]   run_length_d_out;
85
reg  [14:0]             lfsr; // LINEAR FEEDBACK SHIFT REGISTER
86
wire [14:0]             lfsr_steps [LANE_WIDTH-1:0]; // LFSR values for serial time steps
87
 
88
// SEQUENTIAL PROCESS
89
`ifdef ASYNC_RES
90
always @(posedge clk or negedge res_n)  begin `else
91
always @(posedge clk)  begin `endif
92 15 juko
    `ifdef RESET_ALL
93
        if(!res_n) begin
94
            data_out <= {LANE_WIDTH{1'b0}};
95
        end else
96
    `endif
97 11 juko
    begin
98
        data_out <= run_length_d_out;
99
    end
100
 
101 15 juko
    if(!res_n) lfsr <= seed;
102
    else       lfsr <= disable_scrambler ? {15{1'b0}} : lfsr_steps[LANE_WIDTH-1];
103
 
104
end
105
 
106 11 juko
// SCRAMBLE
107
genvar j;
108
generate
109
 
110
    assign data_out_tmp [0] = data_in[0] ^ lfsr[0]; // single bit scrambled.
111
    assign lfsr_steps[0]    = { (lfsr[1] ^ lfsr[0]) , lfsr[14:1] }; // lfsr at next bit clock
112
    for(j = 1; j < LANE_WIDTH; j = j + 1) begin : scrambler_gen
113
        assign data_out_tmp[j] = data_in[j] ^ lfsr_steps[j-1][0];
114
        assign lfsr_steps[j]   = { (lfsr_steps[j-1][1] ^ lfsr_steps[j-1][0]) , lfsr_steps[j-1][14:1] };
115
    end
116
endgenerate
117
 
118
//=====================================================================================================
119
//-----------------------------------------------------------------------------------------------------
120
//---------INSTANTIATIONS HERE-------------------------------------------------------------------------
121
//-----------------------------------------------------------------------------------------------------
122
//=====================================================================================================
123
 
124
generate
125
    if(HMC_RX_AC_COUPLED==1) begin
126
 
127
        tx_run_length_limiter #(
128
            .LANE_WIDTH(LANE_WIDTH)
129
        )
130
        run_length_limiter_I
131
        (
132
            .clk(clk),
133
            .res_n(res_n),
134
            .enable(rf_run_length_enable),
135
            .data_in(data_out_tmp),
136
            .data_out(run_length_d_out),
137
            .rf_bit_flip(rf_run_length_bit_flip)
138
        );
139
    end else begin
140
        assign rf_run_length_bit_flip = 1'b0;
141
        assign run_length_d_out = data_out_tmp;
142
    end
143
endgenerate
144
 
145
endmodule
146
 
147
`default_nettype wire
148
 

powered by: WebSVN 2.1.0

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