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

Subversion Repositories dmt_tx

[/] [dmt_tx/] [trunk/] [const_encoder/] [rtl/] [const_enc.v] - Blame information for rev 23

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 dannori
/* *****************************************************************
2
 *
3 16 dannori
 *  This file is part of the
4
 *
5
 *  Tone Order and Constellation Encoder Core.
6
 *
7
 *  Description:
8
 *
9
 *  The conste_enc module implements the tone ordering and
10
 *  constellation encoding as described in ITU G.992.1
11
 *
12
 *********************************************************************
13 13 dannori
 *  Copyright (C) 2007 Guenter Dannoritzer
14
 *
15
 *   This source is free software; you can redistribute it
16
 *   and/or modify it under the terms of the
17
 *             GNU General Public License
18
 *   as published by the Free Software Foundation;
19
 *   either version 3 of the License,
20
 *   or (at your option) any later version.
21
 *
22
 *   This source is distributed in the hope
23
 *   that it will be useful, but WITHOUT ANY WARRANTY;
24
 *   without even the implied warranty of MERCHANTABILITY
25
 *   or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
 *   GNU General Public License for more details.
27
 *
28
 *   You should have received a copy of the
29 16 dannori
 *   GNU General Public License along with this source.
30 13 dannori
 *   If not, see <http://www.gnu.org/licenses/>.
31
 *
32
 * *****************************************************************/
33 12 dannori
 
34
module const_encoder(
35
                clk,
36
                reset,
37 16 dannori
                fast_ready_o,
38
                we_fast_data_i,
39
                fast_data_i,
40
                inter_ready_o,
41
                we_inter_data_i,
42
                inter_data_i,
43 12 dannori
                addr_i,
44
                we_conf_i,
45
                conf_data_i,
46
                xy_ready_o,
47 16 dannori
                carrier_num_o,
48 12 dannori
                x_o,
49
                y_o);
50
 
51
 
52 16 dannori
`include "parameters.vh"
53
 
54
//
55
// parameter
56
// 
57 12 dannori
 
58 16 dannori
input                 clk;
59
input                 reset;
60
output                fast_ready_o;
61
input                 we_fast_data_i;
62
input   [DW-1:0]      fast_data_i;
63
output                inter_ready_o;
64
input                 we_inter_data_i;
65
input   [DW-1:0]      inter_data_i;
66
input   [CONFAW-1:0]  addr_i;
67
input                 we_conf_i;
68
input   [CONFDW-1:0]  conf_data_i;
69
output                xy_ready_o;
70
output  [CNUMW-1:0]   carrier_num_o;
71 20 dannori
output  [CONSTW-1:0]  x_o;            reg signed [CONSTW-1:0] x_o;
72
output  [CONSTW-1:0]  y_o;            reg signed [CONSTW-1:0] y_o;
73 12 dannori
 
74 16 dannori
 
75
 
76
//
77
// local wire/regs
78
//
79 18 dannori
wire    [DW-1:0]          fast_data_o;
80
wire    [DW-1:0]          inter_data_o;
81 16 dannori
 
82 18 dannori
reg   [SHIFTW-1:0]        fast_shift_reg;
83
reg   [SHIFTW-1:0]        inter_shift_reg;
84 19 dannori
reg   [MAXBITNUM-1:0]     cin;
85
reg   [CONFDW-1:0]        bit_load;
86 16 dannori
 
87 19 dannori
reg   [4:0]               msb;
88
reg   [1:0]               msb_x;
89
reg   [1:0]               msb_y;
90
 
91 18 dannori
reg   [CONFDW-1:0]        BitLoading [0:REG_MEM_LEN-1];
92
reg   [CONFDW-1:0]        CarrierNumber [0:REG_MEM_LEN-1];
93
reg   [USED_C_REG_W-1:0]  UsedCarrier;
94
reg   [F_BITS_W-1:0]      FastBits;
95 16 dannori
 
96
//
97
// intantiate the fast path and interleaved path FIFOs
98
//
99
fifo  #(.AWIDTH(AW), .DWIDTH(DW))
100
      fifo_fast ( .clk(clk),
101
                  .reset(reset),
102
                  .empty_o(fast_empty_o),
103
                  .full_o(fast_full_o),
104
                  .one_available_o(fast_one_available_o),
105
                  .two_available_o(fast_two_available_o),
106
                  .we_i(we_fast_i),
107
                  .data_i(fast_data_i),
108
                  .re_i(re_fast_i),
109
                  .data_o(fast_data_o)
110
                  );
111
 
112
fifo  #(.AWIDTH(AW), .DWIDTH(DW))
113
      fifo_inter ( .clk(clk),
114
                  .reset(reset),
115
                  .empty_o(inter_empty_o),
116
                  .full_o(inter_full_o),
117
                  .one_available_o(inter_one_available_o),
118
                  .two_available_o(inter_two_available_o),
119
                  .we_i(we_inter_i),
120
                  .data_i(inter_data_i),
121
                  .re_i(re_inter_i),
122
                  .data_o(inter_data_o)
123
                  );
124
 
125
 
126
//
127
// configuration register access
128
//
129
always @(posedge clk or posedge reset) begin
130
 
131
  if(reset) begin
132
    UsedCarrier <= 0;
133
    FastBits <= 0;
134
 
135
  end
136
  else begin
137 18 dannori
    if(we_conf_i) begin
138
      if(addr_i >= 0 && addr_i < C_NUM_ST_ADR) begin
139
        BitLoading[addr_i] <= conf_data_i;
140
      end
141
      else if(addr_i >= C_NUM_ST_ADR && addr_i < USED_C_ADR) begin
142
        CarrierNumber[addr_i - C_NUM_ST_ADR] <= conf_data_i;
143
      end
144
      else if(addr_i == USED_C_ADR) begin
145
        UsedCarrier <= conf_data_i;
146
      end
147
      else if(addr_i == F_BITS_ADR) begin
148
        FastBits <= conf_data_i;
149
      end
150
    end
151 16 dannori
  end
152
 
153
end
154
 
155
 
156 19 dannori
//
157
// constellation mapping
158
//
159
always @(posedge reset or posedge clk) begin
160 16 dannori
 
161 19 dannori
  if(reset) begin
162
    x_o <= 9'b0;
163
    y_o <= 9'b0;
164
  end
165
  else begin
166
    case (bit_load)
167
      4'b0010:  begin // #2
168 20 dannori
                  x_o <= {cin[1], cin[1], cin[1], cin[1], cin[1], cin[1], cin[1], cin[1], 1'b1};
169
                  y_o <= {cin[0], cin[0], cin[0], cin[0], cin[0], cin[0], cin[0], cin[0], 1'b1};
170 19 dannori
                end
171
 
172
      4'b0011:  begin // #3
173
                  case (cin[2:0])
174 22 dannori
                    3'b000: begin x_o <= 9'b000000001; y_o <= 9'b000000001; end
175 19 dannori
                    3'b001: begin x_o <= 9'b000000001; y_o <= 9'b111111111; end
176
                    3'b010: begin x_o <= 9'b111111111; y_o <= 9'b000000001; end
177
                    3'b011: begin x_o <= 9'b111111111; y_o <= 9'b111111111; end
178
 
179
                    3'b100: begin x_o <= 9'b111111101; y_o <= 9'b000000001; end
180
                    3'b101: begin x_o <= 9'b000000001; y_o <= 9'b000000011; end
181
                    3'b110: begin x_o <= 9'b111111111; y_o <= 9'b111111101; end
182
                    3'b111: begin x_o <= 9'b000000011; y_o <= 9'b111111111; end
183
                  endcase
184
                end
185
 
186
      4'b0100:  begin // #4
187 22 dannori
                  x_o <= {cin[3], cin[3], cin[3], cin[3], cin[3], cin[3], cin[3], cin[1], 1'b1};
188
                  y_o <= {cin[2], cin[2], cin[2], cin[2], cin[2], cin[2], cin[2], cin[0], 1'b1};
189 19 dannori
                end
190
 
191
      4'b0101:  begin // #5
192
                  map_msb(cin[4:0], msb_x, msb_y);
193 22 dannori
                  x_o <= {msb_x[1], msb_x[1], msb_x[1], msb_x[1], msb_x[1], msb_x[1], msb_x[0], cin[1], 1'b1};
194
                  y_o <= {msb_y[1], msb_y[1], msb_y[1], msb_y[1], msb_y[1], msb_y[1], msb_y[0], cin[0], 1'b1};
195 19 dannori
                end
196
 
197
      4'b0110:  begin // #6
198
                  x_o <= {cin[4], cin[4], cin[4], cin[4], cin[4], cin[4], cin[2], cin[0], 1'b1};
199
                  y_o <= {cin[5], cin[5], cin[5], cin[5], cin[5], cin[5], cin[3], cin[1], 1'b1};
200
                end
201
 
202
      4'b0111:  begin // #7
203
                  map_msb(cin[6:2], msb_x, msb_y);
204
                  x_o <= {msb_x[1], msb_x[1], msb_x[1], msb_x[1], msb_x[1], msb_x[0], cin[2], cin[0], 1'b1};
205
                  y_o <= {msb_y[1], msb_y[1], msb_y[1], msb_y[1], msb_y[1], msb_y[0], cin[3], cin[1], 1'b1};
206
                end
207
      4'b1000:  begin // #8
208
                  x_o <= {cin[6], cin[6], cin[6], cin[6], cin[6], cin[4], cin[2], cin[0], 1'b1};
209
                  y_o <= {cin[7], cin[7], cin[7], cin[7], cin[7], cin[5], cin[3], cin[1], 1'b1};
210
                end
211
 
212
      4'b1001:  begin // #9
213
                  map_msb(cin[7:3], msb_x, msb_y);
214
                  x_o <= {msb_x[1], msb_x[1], msb_x[1], msb_x[1], msb_x[0], cin[4], cin[2], cin[0], 1'b1};
215
                  y_o <= {msb_y[1], msb_y[1], msb_y[1], msb_y[1], msb_y[0], cin[5], cin[3], cin[1], 1'b1};
216
                end
217
      4'b1010:  begin // #10
218
                  x_o <= {cin[8], cin[8], cin[8], cin[8], cin[6], cin[4], cin[2], cin[0], 1'b1};
219
                  y_o <= {cin[9], cin[9], cin[9], cin[9], cin[7], cin[5], cin[3], cin[1], 1'b1};
220
                end
221
 
222
      4'b1011:  begin // #11
223
                  map_msb(cin[8:4], msb_x, msb_y);
224
                  x_o <= {msb_x[1], msb_x[1], msb_x[1], msb_x[0], cin[6], cin[4], cin[2], cin[0], 1'b1};
225
                  y_o <= {msb_y[1], msb_y[1], msb_y[1], msb_y[0], cin[7], cin[5], cin[3], cin[1], 1'b1};
226
                end
227
      4'b1100:  begin // #12
228
                  x_o <= {cin[10], cin[10], cin[10], cin[8], cin[6], cin[4], cin[2], cin[0], 1'b1};
229
                  y_o <= {cin[11], cin[11], cin[11], cin[9], cin[7], cin[5], cin[3], cin[1], 1'b1};
230
                end
231
 
232
      4'b1101:  begin // #13
233
                  map_msb(cin[9:5], msb_x, msb_y);
234
                  x_o <= {msb_x[1], msb_x[1], msb_x[0], cin[8], cin[6], cin[4], cin[2], cin[0], 1'b1};
235
                  y_o <= {msb_y[1], msb_y[1], msb_y[0], cin[9], cin[7], cin[5], cin[3], cin[1], 1'b1};
236
                end
237
      4'b1110:  begin // #14
238
                  x_o <= {cin[12], cin[12], cin[10], cin[8], cin[6], cin[4], cin[2], cin[0], 1'b1};
239
                  y_o <= {cin[13], cin[13], cin[11], cin[9], cin[7], cin[5], cin[3], cin[1], 1'b1};
240
                end
241
 
242
      4'b1111:  begin // #15 TODO
243
                  map_msb(cin[10:6], msb_x, msb_y);
244
                  x_o <= {msb_x[1], msb_x[0], cin[10], cin[8], cin[6], cin[4], cin[2], cin[0], 1'b1};
245
                  y_o <= {msb_y[1], msb_y[0], cin[11], cin[9], cin[7], cin[5], cin[3], cin[1], 1'b1};
246
                end
247
 
248
    endcase
249
  end
250
end
251
 
252
//
253
// determine the top two bits of X and Y based on table 7-12 in G.992.1
254
//
255
task map_msb(input [4:0] t_msb, output [1:0] t_msb_x, output [1:0] t_msb_y );
256
  begin
257
  case (t_msb)
258
    5'b00000: begin t_msb_x <= 2'b00; t_msb_y <= 2'b00; end
259
    5'b00001: begin t_msb_x <= 2'b00; t_msb_y <= 2'b00; end
260
    5'b00010: begin t_msb_x <= 2'b00; t_msb_y <= 2'b00; end
261
    5'b00011: begin t_msb_x <= 2'b00; t_msb_y <= 2'b00; end
262
 
263
    5'b00100: begin t_msb_x <= 2'b00; t_msb_y <= 2'b11; end
264
    5'b00101: begin t_msb_x <= 2'b00; t_msb_y <= 2'b11; end
265
    5'b00110: begin t_msb_x <= 2'b00; t_msb_y <= 2'b11; end
266
    5'b00111: begin t_msb_x <= 2'b00; t_msb_y <= 2'b11; end
267
 
268
    5'b01000: begin t_msb_x <= 2'b11; t_msb_y <= 2'b00; end
269
    5'b01001: begin t_msb_x <= 2'b11; t_msb_y <= 2'b00; end
270
    5'b01010: begin t_msb_x <= 2'b11; t_msb_y <= 2'b00; end
271
    5'b01011: begin t_msb_x <= 2'b11; t_msb_y <= 2'b00; end
272
 
273
    5'b01100: begin t_msb_x <= 2'b11; t_msb_y <= 2'b11; end
274
    5'b01101: begin t_msb_x <= 2'b11; t_msb_y <= 2'b11; end
275
    5'b01110: begin t_msb_x <= 2'b11; t_msb_y <= 2'b11; end
276
    5'b01111: begin t_msb_x <= 2'b11; t_msb_y <= 2'b11; end
277
 
278
    5'b10000: begin t_msb_x <= 2'b01; t_msb_y <= 2'b00; end
279
    5'b10001: begin t_msb_x <= 2'b01; t_msb_y <= 2'b00; end
280
    5'b10010: begin t_msb_x <= 2'b10; t_msb_y <= 2'b00; end
281
    5'b10011: begin t_msb_x <= 2'b10; t_msb_y <= 2'b00; end
282
 
283
    5'b10100: begin t_msb_x <= 2'b00; t_msb_y <= 2'b01; end
284
    5'b10101: begin t_msb_x <= 2'b00; t_msb_y <= 2'b10; end
285
    5'b10110: begin t_msb_x <= 2'b00; t_msb_y <= 2'b01; end
286
    5'b10111: begin t_msb_x <= 2'b00; t_msb_y <= 2'b10; end
287
 
288
    5'b11000: begin t_msb_x <= 2'b11; t_msb_y <= 2'b01; end
289
    5'b11001: begin t_msb_x <= 2'b11; t_msb_y <= 2'b10; end
290
    5'b11010: begin t_msb_x <= 2'b11; t_msb_y <= 2'b01; end
291
    5'b11011: begin t_msb_x <= 2'b11; t_msb_y <= 2'b10; end
292
 
293
    5'b11100: begin t_msb_x <= 2'b01; t_msb_y <= 2'b11; end
294
    5'b11101: begin t_msb_x <= 2'b01; t_msb_y <= 2'b11; end
295
    5'b11110: begin t_msb_x <= 2'b10; t_msb_y <= 2'b11; end
296
    5'b11111: begin t_msb_x <= 2'b10; t_msb_y <= 2'b11; end
297
 
298
  endcase
299
end
300
endtask
301
 
302 12 dannori
endmodule

powered by: WebSVN 2.1.0

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