Changeset 45 for trunk/MultiChannelUSB/Paella.v
- Timestamp:
- Sep 15, 2009, 3:27:35 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MultiChannelUSB/Paella.v
r44 r45 111 111 reg [10:0] tst_counter; 112 112 113 reg ana_reset [ 2:0];114 wire ana_peak_ready [ 2:0];115 wire [11:0] ana_peak [ 2:0];113 reg ana_reset [3:0]; 114 wire ana_peak_ready [3:0]; 115 wire [11:0] ana_peak [3:0]; 116 116 117 117 reg [9:0] osc_counter; 118 reg osc_byte_num; 119 120 reg osc_reset_mux, osc_reset [2:0]; 121 wire [9:0] osc_start_addr [2:0]; 122 reg [9:0] osc_start_addr_mux, osc_addr_mux, osc_addr [2:0]; 123 wire [15:0] osc_q [2:0]; 118 119 reg osc_reset [3:0]; 120 wire [9:0] osc_start_addr [3:0]; 121 reg [9:0] osc_addr [3:0]; 122 wire [15:0] osc_q [3:0]; 124 123 reg [15:0] osc_q_mux; 125 124 126 reg [1:0] hst_byte_num; 127 128 reg hst_reset_mux, hst_reset [2:0]; 129 reg [11:0] hst_addr_mux, hst_addr [2:0]; 130 wire [31:0] hst_q [2:0]; 131 reg [31:0] hst_q_mux; 132 133 reg [3:0] select, state1, state2; 125 reg hst_reset [3:0]; 126 reg [11:0] hst_addr [3:0]; 127 wire [23:0] hst_q [3:0]; 128 129 reg mux_reset, mux_type; 130 reg [1:0] mux_chan, mux_byte, mux_max_byte; 131 reg [15:0] mux_addr, mux_min_addr, mux_max_addr; 132 reg [7:0] mux_q; 133 134 reg [3:0] state1, state2; 134 135 reg adc_fifo_aclr; 135 136 136 wire adc_clk; 137 138 reg [11:0] adc_data; 139 140 wire adc_data_ready [2:0]; 141 wire [11:0] adc_lvds_data [2:0]; 142 143 wire [11:0] raw_data [2:0]; 144 wire [11:0] uwt_data [2:0]; 145 wire [1:0] uwt_flag [2:0]; 146 137 wire adc_clk [3:0]; 138 139 // reg [11:0] adc_data; 140 141 wire adc_data_ready [3:0]; 142 wire [11:0] adc_data [3:0]; 143 144 wire [11:0] raw_data [3:0]; 145 wire [11:0] uwt_data [3:0]; 146 wire [1:0] uwt_flag [3:0]; 147 148 assign adc_clk[0] = ADC_FCO; 149 assign adc_clk[1] = ADC_FCO; 150 assign adc_clk[2] = ADC_FCO; 151 assign adc_clk[3] = CON_B[0]; 152 assign adc_data[3] = CON_B[12:1]; 153 /* 147 154 pll pll_unit( 148 155 .inclk0(CLK_50MHz), 149 156 .c0(adc_clk)); 157 */ 150 158 /* 151 159 altserial_flash_loader #( … … 165 173 .lvds_fco(ADC_FCO), 166 174 .lvds_d(ADC_D), 167 .adc_db(adc_ lvds_data[0]),168 .adc_dc(adc_ lvds_data[1]),169 .adc_dd(adc_ lvds_data[2]));175 .adc_db(adc_data[0]), 176 .adc_dc(adc_data[1]), 177 .adc_dd(adc_data[2])); 170 178 171 179 genvar i; 172 180 generate 173 for (i = 0; i < 3; i = i + 1)181 for (i = 0; i < 4; i = i + 1) 174 182 begin : MCA_CHAIN 175 183 adc_fifo adc_fifo_unit ( 176 .adc_clk( ADC_FCO),177 .adc_data(adc_ lvds_data[i]),184 .adc_clk(adc_clk[i]), 185 .adc_data(adc_data[i]), 178 186 .aclr(adc_fifo_aclr), 179 187 .rdclk(CLK_50MHz), … … 229 237 always @* 230 238 begin 231 case(select) 232 4'h0: 233 begin 234 osc_reset[0] = osc_reset_mux; 235 osc_addr[0] = osc_addr_mux; 236 osc_q_mux = osc_q[0]; 237 osc_start_addr_mux = osc_start_addr[0]; 238 239 hst_reset[0] = hst_reset_mux; 240 hst_addr[0] = hst_addr_mux; 241 hst_q_mux = hst_q[0]; 242 end 243 4'h1: 244 begin 245 osc_reset[1] = osc_reset_mux; 246 osc_addr[1] = osc_addr_mux; 247 osc_q_mux = osc_q[1]; 248 osc_start_addr_mux = osc_start_addr[1]; 249 250 hst_reset[1] = hst_reset_mux; 251 hst_addr[1] = hst_addr_mux; 252 hst_q_mux = hst_q[1]; 253 end 254 4'h2: 255 begin 256 osc_reset[2] = osc_reset_mux; 257 osc_addr[2] = osc_addr_mux; 258 osc_q_mux = osc_q[2]; 259 osc_start_addr_mux = osc_start_addr[2]; 260 261 hst_reset[2] = hst_reset_mux; 262 hst_addr[2] = hst_addr_mux; 263 hst_q_mux = hst_q[2]; 264 end 265 default: 266 begin 267 osc_reset[0] = osc_reset_mux; 268 osc_addr[0] = osc_addr_mux; 269 osc_q_mux = osc_q[0]; 270 osc_start_addr_mux = osc_start_addr[0]; 271 272 hst_reset[0] = hst_reset_mux; 273 hst_addr[0] = hst_addr_mux; 274 hst_q_mux = hst_q[0]; 239 osc_reset[0] = 1'b0; 240 osc_addr[0] = 10'b0; 241 osc_reset[1] = 1'b0; 242 osc_addr[1] = 10'b0; 243 osc_reset[2] = 1'b0; 244 osc_addr[2] = 10'b0; 245 osc_reset[3] = 1'b0; 246 osc_addr[3] = 10'b0; 247 hst_reset[0] = 1'b0; 248 hst_addr[0] = 12'b0; 249 hst_reset[1] = 1'b0; 250 hst_addr[1] = 12'b0; 251 hst_reset[2] = 1'b0; 252 hst_addr[2] = 12'b0; 253 hst_reset[3] = 1'b0; 254 hst_addr[3] = 12'b0; 255 case({mux_type,mux_chan}) 256 3'b000, 3'b001, 3'b010, 3'b011: 257 begin 258 osc_reset[mux_chan] = mux_reset; 259 osc_addr[mux_chan] = mux_addr[9:0]; 260 mux_max_byte = 2'd1; 261 mux_min_addr = {6'd0, osc_start_addr[mux_chan]}; 262 mux_max_addr = {6'd0, osc_start_addr[mux_chan]} + 16'd1023; 263 end 264 265 3'b100, 3'b101, 3'b110, 3'b111: 266 begin 267 hst_reset[mux_chan] = mux_reset; 268 hst_addr[mux_chan] = mux_addr[11:0]; 269 mux_max_byte = 2'd2; 270 mux_min_addr = 16'd0; 271 mux_max_addr = 16'd4095; 275 272 end 276 273 endcase 277 274 end 275 276 always @* 277 begin 278 case ({mux_type,mux_byte}) 279 5'b000: mux_q = osc_q[mux_chan][7:0]; 280 5'b001: mux_q = osc_q[mux_chan][15:8]; 281 282 5'b100: mux_q = hst_q[mux_chan][7:0]; 283 5'b101: mux_q = hst_q[mux_chan][15:8]; 284 5'b110: mux_q = hst_q[mux_chan][23:16]; 285 286 default: mux_q = 8'd0; 287 endcase 288 end 289 278 290 279 291 always @(posedge CLK_50MHz) … … 301 313 usb_fifo_rx_rdreq <= 1'b1; 302 314 usb_fifo_tx_wrreq <= 1'b0; 303 hst_reset_mux <= 1'b0; 304 osc_reset_mux <= 1'b0; 315 mux_type <= 1'b0; 316 mux_chan <= 2'd0; 317 mux_byte <= 2'd0; 318 mux_reset <= 1'b0; 305 319 state1 <= 4'd2; 306 320 end … … 311 325 begin 312 326 case (usb_fifo_rx_data) 313 8'h40, 8'h41, 8'h42 :327 8'h40, 8'h41, 8'h42, 8'h43, 8'h50, 8'h51, 8'h52, 8'h53: 314 328 begin 315 329 usb_fifo_rx_rdreq <= 1'b0; 316 hst_reset_mux <= 1'b1; 317 select <= usb_fifo_rx_data[3:0]; 330 mux_type <= usb_fifo_rx_data[4]; 331 mux_chan <= usb_fifo_rx_data[1:0]; 332 mux_reset <= 1'b1; 318 333 state1 <= 4'd1; 319 334 end 320 8'h50, 8'h51, 8'h52: 335 336 8'h60, 8'h61, 8'h62, 8'h63, 8'h70, 8'h71, 8'h72, 8'h73: 321 337 begin 322 338 usb_fifo_rx_rdreq <= 1'b0; 323 hst_addr_mux <= 12'd0; 324 hst_byte_num <= 2'd0; 325 select <= usb_fifo_rx_data[3:0]; 339 mux_type <= usb_fifo_rx_data[4]; 340 mux_chan <= usb_fifo_rx_data[1:0]; 326 341 state1 <= 4'd3; 327 342 end 328 8'h60, 8'h61, 8'h62: 329 begin 330 usb_fifo_rx_rdreq <= 1'b0; 331 osc_reset_mux <= 1'b1; 332 select <= usb_fifo_rx_data[3:0]; 333 state1 <= 4'd1; 334 end 335 8'h70, 8'h71, 8'h72: 336 begin 337 usb_fifo_rx_rdreq <= 1'b0; 338 osc_addr_mux <= osc_start_addr_mux; 339 osc_counter <= 10'd0; 340 osc_byte_num <= 1'd0; 341 select <= usb_fifo_rx_data[3:0]; 342 state1 <= 4'd6; 343 end 343 344 344 8'h30: 345 345 begin … … 347 347 state1 <= 4'd1; 348 348 end 349 349 350 8'h31: 350 351 begin … … 356 357 end 357 358 end 358 359 // hst transfer 359 // mux transfer 360 360 3: 361 361 begin 362 usb_fifo_tx_data <= hst_q_mux[7:0]; 362 mux_addr <= mux_min_addr; 363 mux_byte <= 2'd0; 364 state1 <= 4'd4; 365 end 366 4: 367 begin 368 usb_fifo_tx_data <= mux_q; 363 369 usb_fifo_tx_wrreq <= 1'b1; 364 hst_byte_num<= 2'd1;365 state1 <= 4'd 4;366 end 367 4:370 mux_byte <= 2'd1; 371 state1 <= 4'd5; 372 end 373 5: 368 374 begin 369 375 if (~usb_fifo_tx_full) 370 376 begin 371 case (hst_byte_num) 372 2'd0: usb_fifo_tx_data <= hst_q_mux[7:0]; 373 2'd1: usb_fifo_tx_data <= hst_q_mux[15:8]; 374 2'd2: usb_fifo_tx_data <= hst_q_mux[23:16]; 375 2'd3: usb_fifo_tx_data <= hst_q_mux[31:24]; 376 endcase 377 if ((&hst_byte_num) & (&hst_addr_mux)) 377 usb_fifo_tx_data <= mux_q; 378 if ((mux_byte == mux_max_byte) && (mux_addr == mux_max_addr)) 378 379 begin 379 state1 <= 4'd 5;380 state1 <= 4'd6; 380 381 end 381 382 else 382 383 begin 383 if (&hst_byte_num) 384 begin 385 hst_addr_mux <= hst_addr_mux + 12'd1; 386 end 387 hst_byte_num <= hst_byte_num + 2'd1; 384 if (mux_byte == mux_max_byte) 385 begin 386 mux_addr <= mux_addr + 16'd1; 387 mux_byte <= 2'd0; 388 end 389 else 390 begin 391 mux_byte <= mux_byte + 2'd1; 392 end 388 393 end 389 394 end 390 395 end 391 5:396 6: 392 397 begin 393 398 if (~usb_fifo_tx_full) … … 397 402 end 398 403 end 399 400 // osc transfer 401 6: 402 begin 403 usb_fifo_tx_data <= osc_q_mux[7:0]; 404 usb_fifo_tx_wrreq <= 1'b1; 405 osc_byte_num <= 1'd1; 406 state1 <= 4'd7; 407 end 404 // tst transfer 408 405 7: 409 begin410 if (~usb_fifo_tx_full)411 begin412 case (osc_byte_num)413 1'd0: usb_fifo_tx_data <= osc_q_mux[7:0];414 1'd1: usb_fifo_tx_data <= osc_q_mux[15:8];415 endcase416 if ((&osc_byte_num) & (&osc_counter))417 begin418 state1 <= 4'd8;419 end420 else421 begin422 if (&osc_byte_num)423 begin424 osc_addr_mux <= osc_addr_mux + 10'd1;425 osc_counter <= osc_counter + 10'd1;426 end427 osc_byte_num <= osc_byte_num + 1'd1;428 end429 end430 end431 8:432 begin433 if (~usb_fifo_tx_full)434 begin435 usb_fifo_tx_wrreq <= 1'b0;436 state1 <= 4'd1;437 end438 end439 // tst transfer440 9:441 406 begin 442 407 usb_fifo_tx_data <= tst_counter; 443 408 usb_fifo_tx_wrreq <= 1'b1; 444 409 tst_counter <= tst_counter + 11'd1; 445 state1 <= 4'd 10;446 end 447 10:410 state1 <= 4'd8; 411 end 412 8: 448 413 begin 449 414 if (~usb_fifo_tx_full) … … 452 417 if (tst_counter == 11'd0) //(&osc_counter) 453 418 begin 454 state1 <= 4'd 11;419 state1 <= 4'd9; 455 420 end 456 421 else … … 460 425 end 461 426 end 462 11:427 9: 463 428 begin 464 429 if (~usb_fifo_tx_full) … … 475 440 endcase 476 441 end 477 442 /* 478 443 always @ (posedge adc_clk) 479 444 begin … … 515 480 endcase 516 481 end 517 482 */ 518 483 endmodule
Note:
See TracChangeset
for help on using the changeset viewer.