PageRenderTime 70ms CodeModel.GetById 38ms app.highlight 28ms RepoModel.GetById 1ms app.codeStats 0ms

/dvbt/trunk/release/rtl/rtl_top_fold/kes_fold_rtl.v

http://github.com/zaqwes8811/decoder-reed-solomon
V | 330 lines | 253 code | 9 blank | 68 comment | 6 complexity | 770bfa5020e0aed3fd660569623a3b9e MD5 | raw file
  1/**
  2  file : kes_fold_rtl.v
  3  
  4  abst. :  ????????????????? ?????????? ??????????? 
  5    ??? kes-?????  
  6  
  7  feat. :
  8  
  9  con. :
 10  kes_block_rtl #(
 11    .FFACTOR(FFACTOR));
 12    label_kes(
 13      .clk(clk), .rst(rst), .clk_ena(clk_ena), 
 14      // control ////
 15      .kes_slave(kes_slave), 
 16      // out
 17      .kes_master(kes_master),
 18      // dataflow ///
 19      .psindrom(psindrom), 
 20      // out
 21      .plambda(plambda),
 22      .phomega(phomega)
 23    );
 24 */
 25 
 26`include "vc_top.v"
 27module kes_fold_rtl(
 28  rst, clk, clk_ena, 
 29  // control ////
 30  kes_slave, 
 31  // out
 32  kes_master,  // ?? ??? ????? ?????
 33  //kes_master_short,  
 34  // dataflow ///
 35  psindroms, 
 36  // out
 37  plambda,
 38  phomega,
 39  degree
 40);
 41  input clk, rst, clk_ena;
 42  input kes_slave;
 43  input [`SC_OUT_WIDTH-1:0] psindroms;  // ??????????? ?????????? ????????  
 44  output kes_master;
 45  output [`DEGREE_BUS-1:0] degree;
 46  
 47  //
 48  output [`KES_OUT_HOME-1:0] phomega;
 49    wire [`KES_OUT_HOME-1:0] phomega_tmp;
 50  output [`KES_OUT_LAM-1:0] plambda;  // ??????????? ?????????? ????????
 51    wire [`KES_OUT_LAM-1:0] plambda_tmp;  // 
 52  // enab.
 53  wire windows;
 54  wire carry;  // LCr - ??????? ???????? ???????(?????)
 55    assign clk_ena_cont = clk_ena & carry & windows;  // ????????
 56    wire clk_ena_calc;
 57      assign clk_ena_calc = clk_ena & windows;
 58  wire load;
 59    assign load = kes_slave;
 60  wire pre_kes_master;
 61  wire pre_master = clk_ena & pre_kes_master;
 62
 63  // loc. //
 64  wire [(`WIDTH)*(`ST)-1:0] first_zeros;  // ?????? ????
 65    assign first_zeros = 0;
 66  wire [(`WIDTH)*3*(`ST+1)-1:0] psyndval_src_tmp;  // ??? ???. ?????
 67  wire [`WIDTH-1:0] intcon [`NUM_BLK-2:0];  // ?????????? ????? ???????
 68   // out.
 69  wire [`WIDTH-1:0] deltair;
 70  wire [`WIDTH-1:0] tttar;
 71  
 72  // contr.
 73  wire [`WIDTH-1:0] gammar;
 74  wire [`WIDTH-1:0] tst; 
 75  wire [`WIDTH-1:0] delta0r; 
 76    assign delta0r = deltair;
 77  wire MCr;
 78  wire LCr;
 79  // ??? ??????. ???????
 80  wire [`ST:0] scan_w;  // ?? ???????, ?? ????? ????????? ? ????. ???.
 81  wire [`DEGREE_BUS-1:0] degree_tmp;
 82  //
 83  wire [`BIG_DEL-1:0]  bigdelta [0:(`NUM_BLK-1)];  // ??????? ????????
 84  wire [(`BIG_DEL)*(`NUM_BLK)-1:0] pdelta;
 85  wire [(`BIG_DEL)*(`NUM_BLK)-1:0] pdelta_tmp;
 86  wire [2*8-1:0] last_zeros;  // ? ????????? ?? ??????, ????? ????? ????????
 87    assign last_zeros = 0;
 88  wire [`SC_OUT_WIDTH-1:0] psindroms_rout;  // ??????????? ?????????? ????????
 89  
 90  // split and union
 91  // ????????????? ???????? ??????.// ???? ???, ?.?. ???? ??? ?????? ?????????
 92  
 93  genvar b;
 94  generate for(b = 1; b < 2*(`ST)+1; b = b+1) begin : as // ???????????? ????????
 95    assign psindroms_rout[(b)*(`WIDTH)-1:(b-1)*(`WIDTH)] = 
 96	  psindroms[`SC_OUT_WIDTH-1-(b-1)*(`WIDTH):`SC_OUT_WIDTH-(b)*(`WIDTH)];
 97  end endgenerate
 98  assign psyndval_src_tmp = 
 99  { // ????? ????????? ?????? ??????
100    psindroms_rout,
101    // ?????????? ?????? ? ????? ????????
102    first_zeros,
103    // ?????????
104    8'd1};
105  wire [(`WIDTH)*(`NUM_REG)*(`NUM_BLK)-1:0] psyndval_src;  // ??? ???. ?????
106  generate if(`FLAG == 1) begin
107    assign psyndval_src = {psyndval_src_tmp};
108  end endgenerate
109  generate if(`FLAG == 0) begin
110    assign psyndval_src = {psyndval_src_tmp, last_zeros};
111  end endgenerate
112  
113  // con. ///
114  // ??????????? ??????????? ?????????? ? ???????? ???????
115  // ?????????? ?????? ? ???????
116  sm_control_v3 #(
117    .WIDTH(`WIDTH+1), 
118    .MOD_COUNT(`KES_DELAY_FOLD))
119    label_kes(  // ???? ????????
120      .clk(clk), .rst(rst), .clk_ena(clk_ena),
121      // control ///
122      // slave
123      .first(load),  // ?????????? ???????? ? ???????? ??????? ??????? ?????
124      .windows(windows),
125      // master
126      .last(pre_kes_master)  // ?????????? ???????? ? ???? ???????? ???????
127    );
128  // ???????????? ??????? ?????????????
129  a_dff #(.WIDTH(1)) label_aff_out_ena(
130     .clk(clk), .aclr(rst), .ena(clk_ena),
131     .data(pre_master), 
132     .q(
133     pre_kes_master_tmp)
134     );  //* /
135  
136  // ?????????? ??????????
137  calc_control 
138    ccontr(
139      .clk(clk), .rst(rst), .clk_ena(clk_ena_cont),  
140      // control /////
141      .deltar(
142      delta0r),  // ??????? ???????
143      .load(load),
144      // out ///
145      .deltarout(delta0r_tst),
146      .gammar(gammar),
147      .MCr(MCr)
148    );
149	assign rst_warrn = carry | load;
150  counter_load_down_set #(  // ?????????? ???????
151    .MOD_COUNT(`NUM_REG),
152    .WIDTH(`NUM_REG))  // ????? ? ???????, ??? ???? ?????
153    label_cl(
154      .clk(clk), .rst(rst), 
155	  .clk_ena(clk_ena_calc),
156      // control /// 
157      .load(
158	  rst_warrn),
159	  //carry),  // ????????? ??????
160	  .set(pre_master),
161      // out
162      .carry(carry),  // ???????? ????????
163      // datastream ///
164      .dfload(`NUM_REG-1)  // data for loading
165    );
166  assign LCr = carry;
167  
168  // con. PE /// /// /// ///
169  genvar bb;  // ????????? ?????? ? ???????????? ????
170  generate for(bb = 1; bb < `NUM_BLK+1 ; bb = bb+1) begin :asd
171    assign pdelta_tmp[(bb)*(`BIG_DEL)-1:(bb-1)*(`BIG_DEL)] = bigdelta[(`NUM_BLK)-bb];
172  end endgenerate
173  generate for(bb = 1; bb < `NUM_BY+1; bb = bb+1) begin : asdf // ???????????? ????????
174    assign pdelta[(bb)*(`WIDTH)-1:(bb-1)*(`WIDTH)] = 
175	  pdelta_tmp[(`BIG_DEL)*(`NUM_BLK)-1-(bb-1)*(`WIDTH):(`BIG_DEL)*(`NUM_BLK)-(bb)*(`WIDTH)];
176  end endgenerate
177  
178  PE_fold PE0_fold(
179    .clk(clk), .rst(rst), .clk_ena(clk_ena_calc),
180    // control
181    .load(load),  // ???????? ????????
182    .MCr(MCr), 
183    .LCr(LCr), 
184    // dataflow ///
185    .delta0r(delta0r),  // ??????? ???????
186    .gammar(gammar),  //
187    /////
188    .deltaiir(
189    intcon[0]),
190    //deltaiir),
191    .syndvali(
192    psyndval_src[(`NUM_BLK)*((`WIDTH)*(`NUM_REG))-1:
193      (`NUM_BLK-1)*(`WIDTH*(`NUM_REG))]),  // ???????. ???? ?????????
194    // out 
195    .deltair(deltair),  // ?? ??????????? ?????? del0 ?? ????
196    .bigdelta(bigdelta[0])
197  );
198  // ????. ??. ??.
199  genvar g;
200  generate for(g = 1; g < (`NUM_BLK-1); g = g+1) begin : adfas
201    PE_fold 
202      PEj_fold(
203        .clk(clk), .rst(rst), .clk_ena(clk_ena_calc),
204        // control
205        .load(load),  // ???????? ????????
206        .MCr(MCr), 
207        .LCr(LCr), 
208        // dataflow ///
209        .delta0r(delta0r),  // ??????? ???????
210        .gammar(gammar),  //
211        
212        /////////
213        .deltaiir(
214        intcon[g]),
215        //deltaiir),
216        .syndvali(
217        psyndval_src[(`NUM_BLK-g)*((`WIDTH)*(`NUM_REG))-1:
218          (`NUM_BLK-1-g)*(`WIDTH*(`NUM_REG))]),
219        // out 
220        .deltair(
221        intcon[g-1]),  // ?? ??????????? ??????
222        .bigdelta(bigdelta[g])
223      );
224  end endgenerate
225    // ?????????
226    PE_fold 
227      PE_last_fold(
228        .clk(clk), .rst(rst), .clk_ena(clk_ena_calc),
229        // control
230        .load(load),  // ???????? ????????
231        .MCr(MCr), 
232        .LCr(LCr), 
233        // dataflow ///
234        .delta0r(delta0r),  // ??????? ???????
235        .gammar(gammar),  //
236        
237        /////////
238        .deltaiir(0),
239        .syndvali(
240        psyndval_src[(`NUM_BLK-(`NUM_BLK-1))*((`WIDTH)*(`NUM_REG))-1:
241          (`NUM_BLK-1-(`NUM_BLK-1))*(`WIDTH*(`NUM_REG))]),// ??????????????? ????????
242        // out 
243        .deltair(intcon[(`NUM_BLK-1)-1]),
244        /////
245        .bigdelta(bigdelta[(`NUM_BLK-1)])
246      );
247  // ????. ???. ? ?????? ???????  
248  
249  
250  // out. and tst ///
251  // ????????? ?????
252  generate for(g = 1; g < `ST+1; g = g+1) begin : asdfg
253    assign phomega_tmp[(g)*(`WIDTH)-1:(g-1)*(`WIDTH)] = 
254	  pdelta[(g)*(`WIDTH)-1:(g-1)*(`WIDTH)]; 
255  end endgenerate
256  // latch homega
257  a_dff #(.WIDTH(`KES_OUT_LAM)) label_homega(
258     .clk(clk), .aclr(rst), .ena(pre_master), 
259     .data(phomega_tmp), 
260     .q(phomega));
261  
262  // ????????? ??????
263  // c ???????
264  generate for(g = 1; g < `ST+1+1; g = g+1) begin : qw
265    assign plambda_tmp[(g)*(`WIDTH)-1:(g-1)*(`WIDTH)] = 
266	  pdelta[(g+`ST)*(`WIDTH)-1:(g-1+`ST)*(`WIDTH)]; 
267	zero_detect_owire_not  // ??????? ??????? ????????
268      label_not_zd(
269        .in(pdelta[(g+`ST)*(`WIDTH)-1:(g-1+`ST)*(`WIDTH)]),  // 
270        .out(scan_w[g-1])
271      );
272  end endgenerate
273  
274  pow_pol_8  // ??????????? ??????????
275    label_pow_pol_8(
276      // datastream ///
277      .din(scan_w[`ST:1]), 
278      // out
279      .dout(degree_tmp)
280    );
281  a_dff #(.WIDTH(`DEGREE_BUS)) label_aff_deg(
282     .clk(clk), .aclr(rst), .ena(pre_master),
283     .data(degree_tmp), 
284     .q(degree));  //* /
285  // latch Lambda
286  // ??????????? ? ???????? ????????
287  a_dff #(.WIDTH(`KES_OUT_LAM)) label_plambda(
288     .clk(clk), .aclr(rst), .ena(pre_master), 
289     .data(plambda_tmp), 
290     .q(
291	 plambda));
292	 //plambda_dnc));
293  //assign plambda = 
294    //degree_tmp;
295    //kes_slave;
296	//delta0r;
297  
298// ??????
299    sm_control_v3 #(
300    .WIDTH(`WIDTH+1), 
301    .MOD_COUNT(`SC_DELAY)
302  )label_sm_full(  // ???? ????????
303    .clk(clk), .rst(rst), .clk_ena(clk_ena),
304    // control ///
305    // slave
306    .first(kes_slave),  // ?????????? ???????? ? ???????? ??????? ??????? ?????
307    .windows(windows_tmp),
308    // master
309    .last(pre_kes_master_full)  // ?????????? ???????? ? ???? ???????? ???????
310  );
311  // ???????????? ??????? ?????????????
312  a_dff #(.WIDTH(1)) label_aff_out_ena_2(
313     .clk(clk), .aclr(rst), .ena(clk_ena), 
314     .data(pre_kes_master_full), 
315     .q(kes_master));  //* /
316  
317  //assign kes_master = 
318  //LCr;
319  //MCr;
320  //pre_kes_master_tmp;
321endmodule
322/** 
323  deb. :
324  `define POS 1//1*9+1+7
325  assign degree = 
326  {4'b0,degree_tmp};
327  //plambda[(`POS)*(`WIDTH)-1:(`POS-1)*(`WIDTH)];
328  //phomega[(`POS)*(`WIDTH)-1:(`POS-1)*(`WIDTH)];
329
330*/