Changeset 123
- Timestamp:
- Feb 21, 2011, 12:33:56 AM (14 years ago)
- Location:
- sandbox/MultiChannelUSB
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/MultiChannelUSB/Paella.v
r108 r123 119 119 wire [11:0] ana_base [N-1:0]; 120 120 121 wire amp_ good[N-1:0];121 wire amp_flag [N-1:0]; 122 122 wire [11:0] amp_data [N-1:0]; 123 123 … … 134 134 wire [11:0] del_data; 135 135 136 wire [31:0] uwt_d1 [N-1:0]; 137 wire [31:0] uwt_a1 [N-1:0]; 138 wire [31:0] uwt_d2 [N-1:0]; 139 wire [31:0] uwt_a2 [N-1:0]; 140 wire [31:0] uwt_d3 [N-1:0]; 141 wire [31:0] uwt_a3 [N-1:0]; 142 136 wire [15:0] uwt_data1 [N-1:0]; 137 wire [18:0] uwt_data2 [N-1:0]; 143 138 wire [1:0] uwt_flag1 [N-1:0]; 144 139 wire [1:0] uwt_flag2 [N-1:0]; 145 wire [1:0] uwt_flag3 [N-1:0]; 146 147 wire [11:0] cic_mux_data; 148 wire [13:0] cic_lfsr; 149 wire [24:0] cic_data1 [N-1:0]; 150 wire [24:0] cic_data2 [N-1:0]; 151 wire [24:0] cic_data3 [N-1:0]; 140 141 wire [27:0] cic_data1 [N-1:0]; 142 wire [27:0] cic_data2 [N-1:0]; 143 wire [27:0] cic_data3 [N-1:0]; 144 145 wire [11:0] dec_data [N-1:0]; 146 147 wire [1:0] ext_flag [N-1:0]; 152 148 153 149 wire i2c_reset; … … 216 212 begin : MUX_DATA 217 213 assign int_mux_data[j] = { 218 {4'd0, uwt_flag3[j][1], 7'd0},219 {4'd0, uwt_flag3[j][0], 7'd0},220 {12'd0},221 // {4'd0, amp_good[j], 7'd0},222 cic_data1[j][14:3],223 cic_data2[j][18:7],224 cic_data3[j][22:11],225 // {8'd0, cic_lfsr[3:0]},226 // {8'd0, cic_lfsr[5:2]},227 // uwt_a3[j][20:9],214 // {4'd0, amp_flag[j], 7'd0}, 215 // dec_data[j][37:26], 216 // dec_data[j][36:25], 217 // dec_data[j][35:24], 218 dec_data[j][11:0], 219 dec_data[j][11:0], 220 amp_data[j][11:0], 221 {ext_flag[j][1], 11'd0}, 222 {ext_flag[j][0], 11'd0}, 223 cic_data3[j][26:15], 228 224 sys_data[j]}; 229 225 end … … 253 249 .data({int_mux_data[2], int_mux_data[1], int_mux_data[0]}), 254 250 .result(osc_mux_data[j])); 255 256 251 end 257 252 endgenerate … … 291 286 .out_data({cic_data1[2], cic_data1[1], cic_data1[0]})); 292 287 288 deconv #(.size(1), .shift(25), .width(27), .widthr(12)) deconv_unit ( 289 .clock(sys_clock), 290 .frame(sys_frame), 291 .reset(1'b0), 292 .del_data({6'd20, 6'd20, 6'd20}), 293 .amp_data({8'd1, 8'd1, 8'd1}), 294 .tau_data({16'd980, 16'd980, 16'd980}), 295 // .del_data({cfg_bits[16][5:0], cfg_bits[15][13:8], cfg_bits[15][5:0]}), 296 // .amp_data({cfg_bits[18][7:0], cfg_bits[17][15:8], cfg_bits[17][7:0]}), 297 // .tau_data({cfg_bits[21], cfg_bits[20], cfg_bits[19]}), 298 .inp_data({cic_data3[2][26:0], cic_data3[1][26:0], cic_data3[0][26:0]}), 299 .out_data({dec_data[2], dec_data[1], dec_data[0]})); 300 301 293 302 generate 294 303 for (j = 0; j < 3; j = j + 1) … … 296 305 297 306 assign sys_data[j] = (cfg_bits[1][4*j]) ? (adc_data[j] ^ 12'hfff) : (adc_data[j]); 298 299 307 /* 308 uwt_bior31 #(.level(1), .width(13)) uwt_1_unit ( 309 .clock(sys_clock), 310 .frame(sys_frame), 311 .reset(1'b0), 312 .inp_data(dec_data[j][12:0]), 313 .out_data(uwt_data1[j]), 314 .out_flag(uwt_flag1[j])); 315 316 uwt_bior31 #(.level(1), .width(16)) uwt_2_unit ( 317 .clock(sys_clock), 318 .frame(sys_frame), 319 .reset(1'b0), 320 .inp_data(uwt_data1[j]), 321 .out_data(uwt_data2[j]), 322 .out_flag(uwt_flag2[j])); 323 */ 324 extrema #(.width(12)) extrema_unit ( 325 .clock(sys_clock), 326 .frame(sys_frame), 327 .reset(1'b0), 328 // .inp_data(cic_data3[j][26:15]), 329 .inp_data(dec_data[j]), 330 .out_flag(ext_flag[j])); 331 300 332 analyser analyser_unit ( 301 333 .clock(sys_clock), … … 304 336 .cfg_data({cfg_bits[7+2*j][12:0], cfg_bits[6+2*j][11:0]}), 305 337 .uwt_flag(uwt_flag2[j]), 306 .uwt_data(uwt_ a2[j][17:6]),338 .uwt_data(uwt_data2[j][18:7]), 307 339 .ana_dead(ana_dead[j]), 308 340 .ana_good(ana_good[j]), … … 310 342 .ana_base(ana_base[j])); 311 343 312 amplitude amplitude_unit (344 amplitude #(.width(12)) amplitude_unit ( 313 345 .clock(sys_clock), 314 346 .frame(sys_frame), 315 347 .reset(cfg_bits[0][2+j]), 316 .cfg_data(cfg_bits[12][11:0]),317 // .cfg_data(10'd5),318 .uwt_flag(uwt_flag3[j]),319 . uwt_data(uwt_a3[j][20:9]),320 . amp_good(amp_good[j]),321 . amp_data(amp_data[j]));348 // .cfg_data(cfg_bits[12][11:0]), 349 .cfg_data(12'd5), 350 // .inp_data(cic_data3[j][22:11]), 351 .inp_data(dec_data[j]), 352 .out_flag(amp_flag[j]), 353 .out_data(amp_data[j])); 322 354 end 323 355 endgenerate … … 330 362 .hst_data(ana_data[0]), 331 363 /* 332 .hst_good((amp_ good[j]) & (cnt_good[j]) & (cfg_bits[13][1])),364 .hst_good((amp_flag[j]) & (cnt_good[j]) & (cfg_bits[13][1])), 333 365 .hst_data(amp_data[j]), 334 366 */ -
sandbox/MultiChannelUSB/amplitude.v
r107 r123 1 1 module amplitude 2 #( 3 parameter width = 12 // bit width of the input data 4 ) 2 5 ( 3 input wire clock, frame, reset, 4 input wire [11:0] cfg_data, 5 input wire [1:0] uwt_flag, 6 input wire [11:0] uwt_data, 7 output wire amp_good, 8 output wire [11:0] amp_data 6 input wire clock, frame, reset, 7 input wire [width-1:0] cfg_data, 8 input wire [width-1:0] inp_data, 9 output wire [width-1:0] out_data, 10 output wire out_flag 9 11 ); 10 12 11 reg state_reg, state_next; 12 reg [11:0] minimum_reg, minimum_next; 13 reg amp_good_reg, amp_good_next; 14 reg [11:0] amp_data_reg, amp_data_next; 15 reg [11:0] uwt_data_reg, uwt_data_next; 13 reg int_case_reg, int_case_next; 14 reg out_flag_reg, out_flag_next; 15 reg int_flag_reg, int_flag_next; 16 reg [width-1:0] int_mini_reg, int_mini_next; 17 reg [width-1:0] out_data_reg, out_data_next; 18 reg [width-1:0] inp_data_reg, inp_data_next; 19 20 wire int_comp_wire; 21 reg int_comp_reg, int_comp_next; 22 23 assign int_comp_wire = (inp_data_reg < inp_data); 16 24 17 25 always @(posedge clock) … … 19 27 if (reset) 20 28 begin 21 state_reg <= 1'b0; 22 minimum_reg <= 12'd0; 23 amp_good_reg <= 1'b0; 24 amp_data_reg <= 12'd0; 25 uwt_data_reg <= 12'd0; 29 int_case_reg <= 1'b0; 30 int_mini_reg <= {(width){1'b0}}; 31 inp_data_reg <= {(width){1'b0}}; 32 out_data_reg <= {(width){1'b0}}; 33 out_flag_reg <= 1'b0; 34 int_flag_reg <= 1'b0; 35 int_comp_reg <= 1'b0; 26 36 end 27 37 else 28 38 begin 29 state_reg <= state_next; 30 minimum_reg <= minimum_next; 31 amp_good_reg <= amp_good_next; 32 amp_data_reg <= amp_data_next; 33 uwt_data_reg <= uwt_data_next; 39 int_case_reg <= int_case_next; 40 int_mini_reg <= int_mini_next; 41 inp_data_reg <= inp_data_next; 42 out_data_reg <= out_data_next; 43 out_flag_reg <= out_flag_next; 44 int_flag_reg <= int_flag_next; 45 int_comp_reg <= int_comp_next; 34 46 end 35 47 end … … 37 49 always @* 38 50 begin 39 state_next = state_reg; 40 minimum_next = minimum_reg; 41 amp_good_next = amp_good_reg; 42 amp_data_next = amp_data_reg; 43 uwt_data_next = uwt_data_reg; 51 int_case_next = int_case_reg; 52 int_mini_next = int_mini_reg; 53 inp_data_next = inp_data_reg; 54 out_data_next = out_data_reg; 55 out_flag_next = out_flag_reg; 56 int_flag_next = int_flag_reg; 57 int_comp_next = int_comp_reg; 44 58 45 case ( state_reg)59 case (int_case_reg) 46 60 0: 47 61 begin 48 62 if (frame) 49 63 begin 50 uwt_data_next = uwt_data; 51 amp_good_next = 1'b0; 64 inp_data_next = inp_data; 65 int_comp_next = int_comp_wire; 66 out_data_next = {(width){1'b0}}; 67 out_flag_next = 1'b0; 52 68 // minimum 53 if ( uwt_flag[0])69 if ((~int_comp_reg) & (int_comp_wire)) 54 70 begin 55 minimum_next = uwt_data_reg; 71 int_mini_next = inp_data_reg; 72 int_flag_next = 1'b1; 56 73 end 57 else if ((uwt_flag[1]) & (uwt_data > minimum_reg)) 74 // maximum 75 else if ((int_comp_reg) & (~int_comp_wire) & (int_flag_reg)) 58 76 begin 59 amp_data_next = uwt_data - minimum_reg; 60 state_next = 1'b1; 77 out_data_next = inp_data_reg - int_mini_reg; 78 int_flag_next = 1'b0; 79 int_case_next = 1'b1; 61 80 end 62 81 end … … 65 84 1: 66 85 begin 67 amp_good_next = (amp_data_reg >= cfg_data);68 state_next = 1'b0;86 out_flag_next = (out_data_reg >= cfg_data); 87 int_case_next = 1'b0; 69 88 end 70 89 … … 72 91 end 73 92 74 assign amp_good = amp_good_reg;75 assign amp_data = amp_data_reg;93 assign out_data = out_data_reg; 94 assign out_flag = out_flag_reg; 76 95 77 96 endmodule -
sandbox/MultiChannelUSB/cic_filter.v
r122 r123 12 12 ); 13 13 14 localparam widthr = width + 18; 15 14 localparam widthr = width + 16; 16 15 /* 17 16 4-bit LFSR with additional bits to keep track of previous values … … 76 75 .sel(int_chan_next), 77 76 .data({ 78 2'd3, int_lfsr_reg[2* 6+3:2*6], int_lfsr_reg[6+3:6],79 2'd2, int_lfsr_reg[2* 5+3:2*5], int_lfsr_reg[5+3:5],80 2'd1, int_lfsr_reg[2* 4+3:2*4], int_lfsr_reg[4+3:4],77 2'd3, int_lfsr_reg[2*5+3:2*5], int_lfsr_reg[5+3:5], 78 2'd2, int_lfsr_reg[2*4+3:2*4], int_lfsr_reg[4+3:4], 79 2'd1, int_lfsr_reg[2*3+3:2*3], int_lfsr_reg[3+3:3], 81 80 2'd0, int_lfsr_reg[2*3+3:2*3], int_lfsr_reg[3+3:3]}), 82 .result(int_addr_wire)); 81 .result(int_addr_wire)); 83 82 84 83 always @(posedge clock) -
sandbox/MultiChannelUSB/deconv.v
r120 r123 2 2 #( 3 3 parameter size = 1, // number of channels 4 parameter width = 24 // bit width of the input data 4 parameter shift = 24, // right shift of the result 5 parameter width = 27, // bit width of the input data 6 parameter widthr = 13 // bit width of the output data 5 7 ) 6 8 ( … … 9 11 input wire [3*size*8-1:0] amp_data, 10 12 input wire [3*size*16-1:0] tau_data, 11 input wire [3*size*6-1:0] cls_data,12 13 input wire [3*size*width-1:0] inp_data, 13 14 output wire [3*size*widthr-1:0] out_data … … 16 17 localparam width1 = width + 1; 17 18 localparam width2 = width + 6 + 1; 18 localparam width r= width + 16 + 3;19 localparam width3 = width + 16 + 3; 19 20 20 21 reg int_wren_reg, int_wren_next; … … 30 31 wire [size*widthr-1:0] out_data_wire; 31 32 32 wire [size*width r-1:0] add_data_wire;33 34 wire [size*width r-1:0] mul_data_wire [1:0];33 wire [size*width3-1:0] add_data_wire; 34 35 wire [size*width3-1:0] mul_data_wire [1:0]; 35 36 36 37 reg [size*width2-1:0] acc_data_reg [3:0], acc_data_next [3:0]; … … 47 48 reg [size*16-1:0] tau_data_reg, tau_data_next; 48 49 wire [size*16-1:0] tau_data_wire [2:0]; 49 50 reg [size*6-1:0] cls_data_reg, cls_data_next;51 wire [size*6-1:0] cls_data_wire [2:0];52 50 53 51 integer i; … … 66 64 assign tau_data_wire[1][j*16+16-1:j*16] = tau_data[(3*j+1)*16+16-1:(3*j+1)*16]; 67 65 assign tau_data_wire[2][j*16+16-1:j*16] = tau_data[(3*j+2)*16+16-1:(3*j+2)*16]; 68 assign cls_data_wire[0][j*6+6-1:j*6] = cls_data[(3*j+0)*6+6-1:(3*j+0)*6];69 assign cls_data_wire[1][j*6+6-1:j*6] = cls_data[(3*j+1)*6+6-1:(3*j+1)*6];70 assign cls_data_wire[2][j*6+6-1:j*6] = cls_data[(3*j+2)*6+6-1:(3*j+2)*6];71 66 72 67 lpm_mux #( … … 119 114 .lpm_widtha(width1), 120 115 .lpm_widthb(17), 121 .lpm_widthp(width r)) mult_unit_1 (116 .lpm_widthp(width3)) mult_unit_1 ( 122 117 .clock(clock), 123 118 .clken(int_wren_reg), 124 119 .dataa(sub_data_wire[j*width1+width1-1:j*width1]), 125 120 .datab({1'b0, tau_data_reg[j*16+16-1:j*16]}), 126 .result(mul_data_wire[0][j*width r+widthr-1:j*widthr]));121 .result(mul_data_wire[0][j*width3+width3-1:j*width3])); 127 122 128 123 lpm_mult #( … … 133 128 .lpm_widtha(width2), 134 129 .lpm_widthb(8), 135 .lpm_widthp(width r)) mult_unit_2 (130 .lpm_widthp(width3)) mult_unit_2 ( 136 131 .clock(clock), 137 132 .clken(int_wren_reg), 138 133 .dataa(acc_data_reg[0][j*width2+width2-1:j*width2]), 139 134 .datab(amp_data_reg[j*8+8-1:j*8]), 140 .result(mul_data_wire[1][j*width r+widthr-1:j*widthr]));135 .result(mul_data_wire[1][j*width3+width3-1:j*width3])); 141 136 142 137 lpm_add_sub #( … … 145 140 .lpm_representation("SIGNED"), 146 141 .lpm_type("LPM_ADD_SUB"), 147 .lpm_width(width r)) add_unit_2 (148 .dataa(mul_data_wire[0][j*width r+widthr-1:j*widthr]),149 .datab(mul_data_wire[1][j*width r+widthr-1:j*widthr]),150 .result(add_data_wire[j*width r+widthr-1:j*widthr]));151 152 153 lpm_ clshift#(154 .lpm_ shifttype("LOGICAL"),155 .lpm_ type("LPM_CLSHIFT"),156 .lpm_ width(widthr),157 .lpm_ widthdist(6)) shift_unit_1 (158 . distance(cls_data_reg[j*6+6-1:j*6]),159 .d irection(1'b1),160 .data (add_data_wire[j*widthr+widthr-1:j*widthr]),142 .lpm_width(width3)) add_unit_2 ( 143 .dataa(mul_data_wire[0][j*width3+width3-1:j*width3]), 144 .datab(mul_data_wire[1][j*width3+width3-1:j*width3]), 145 .result(add_data_wire[j*width3+width3-1:j*width3])); 146 147 148 lpm_add_sub #( 149 .lpm_direction("ADD"), 150 .lpm_hint("ONE_INPUT_IS_CONSTANT=NO,CIN_USED=NO"), 151 .lpm_representation("UNSIGNED"), 152 .lpm_type("LPM_ADD_SUB"), 153 .lpm_width(widthr)) add_unit_3 ( 154 .dataa(add_data_wire[j*width3+shift+widthr-1:j*width3+shift]), 155 .datab({{(widthr-1){1'b0}}, add_data_wire[j*width3+shift-1]}), 161 156 .result(out_data_wire[j*widthr+widthr-1:j*widthr])); 162 157 … … 220 215 amp_data_reg <= 8'd0; 221 216 tau_data_reg <= 16'd0; 222 cls_data_reg <= 6'd0;223 217 for(i = 0; i <= 2; i = i + 1) 224 218 begin … … 240 234 amp_data_reg <= amp_data_next; 241 235 tau_data_reg <= tau_data_next; 242 cls_data_reg <= cls_data_next;243 236 for(i = 0; i <= 2; i = i + 1) 244 237 begin … … 262 255 amp_data_next = amp_data_reg; 263 256 tau_data_next = tau_data_reg; 264 cls_data_next = cls_data_reg;265 257 for(i = 0; i <= 2; i = i + 1) 266 258 begin … … 282 274 amp_data_next = 8'd0; 283 275 tau_data_next = 16'd0; 284 cls_data_next = 6'd0;285 276 for(i = 0; i <= 2; i = i + 1) 286 277 begin … … 327 318 tau_data_next = tau_data_wire[0]; 328 319 amp_data_next = amp_data_wire[0]; 329 cls_data_next = cls_data_wire[0];330 320 331 321 int_case_next = 3'd3; … … 346 336 tau_data_next = tau_data_wire[1]; 347 337 amp_data_next = amp_data_wire[1]; 348 cls_data_next = cls_data_wire[1];349 338 350 339 // register 1st sum … … 364 353 tau_data_next = tau_data_wire[2]; 365 354 amp_data_next = amp_data_wire[2]; 366 cls_data_next = cls_data_wire[2];367 355 368 356 // register 2nd sum
Note:
See TracChangeset
for help on using the changeset viewer.