Changeset 35 for trunk/MultiChannelUSB
- Timestamp:
- Sep 7, 2009, 1:01:04 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MultiChannelUSB/Paella.v
r34 r35 72 72 reg led_reg; 73 73 // assign LED = counter[24]; 74 // assign LED = ~usb_fifo_rx_empty;75 74 assign LED = led_reg; 76 // assign LED = usb_fifo_led;77 75 78 76 wire usb_wrreq, usb_rdreq, usb_rden, usb_pktend; 79 wire usb_fifo_aclr , usb_fifo_led;77 wire usb_fifo_aclr; 80 78 reg usb_fifo_tx_wrreq; 81 79 reg usb_fifo_rx_rdreq; … … 104 102 105 103 .tx_full(usb_fifo_tx_full), 106 // .tx_wrreq(usb_fifo_tx_wrreq),107 // .tx_wrreq((~usb_fifo_tx_full) & (state1 == 3'd5)),108 104 .tx_wrreq((~usb_fifo_tx_full) & usb_fifo_tx_wrreq), 109 105 .tx_data(usb_fifo_tx_data), 110 // .tx_data(osc_counter),111 106 112 107 .rx_empty(usb_fifo_rx_empty), 113 108 .rx_rdreq(usb_fifo_rx_rdreq), 114 .rx_q(usb_fifo_rx_data), 115 116 .led(usb_fifo_led) 109 .rx_q(usb_fifo_rx_data) 117 110 ); 118 111 119 reg [10:0] osc_counter; 112 reg [10:0] tst_counter; 113 114 reg [9:0] osc_counter; 120 115 reg osc_reset; 121 116 reg osc_byte_num; … … 129 124 wire [31:0] hst_q; 130 125 131 reg [ 2:0] state0, state1, state2;126 reg [3:0] state0, state1, state2; 132 127 reg adc_fifo_rdreq; 133 128 wire adc_fifo_rdempty; … … 194 189 adc_fifo_rdreq <= 1'b1; 195 190 adc_data_ready <= 1'b1; 196 state0 <= 3'd2;191 state0 <= 4'd2; 197 192 end 198 193 end … … 202 197 adc_fifo_rdreq <= 1'b0; 203 198 adc_data_ready <= 1'b0; 204 state0 <= 3'd1;199 state0 <= 4'd1; 205 200 end 206 201 207 202 default: 208 203 begin 209 state0 <= 3'd1;204 state0 <= 4'd1; 210 205 end 211 206 endcase 212 207 end 213 /* 208 214 209 always @(posedge CLK_50MHz) 215 210 begin 216 case 211 case(state1) 217 212 1: 218 213 begin … … 221 216 hst_reset <= 1'b0; 222 217 osc_reset <= 1'b0; 223 state1 <= 3'd2;218 state1 <= 4'd2; 224 219 end 225 220 … … 233 228 begin 234 229 hst_reset <= 1'b1; 235 state1 <= 3'd1;230 state1 <= 4'd1; 236 231 end 237 232 8'h31: 238 233 begin 239 led_reg <= 1'b1;240 234 hst_addr <= 12'd0; 241 235 hst_byte_num <= 2'd0; 242 state1 <= 3'd3;236 state1 <= 4'd3; 243 237 end 244 238 8'h32: 245 239 begin 240 led_reg <= 1'b1; 246 241 osc_reset <= 1'b1; 247 state1 <= 3'd1;242 state1 <= 4'd1; 248 243 end 249 244 8'h33: … … 253 248 osc_counter <= 10'd0; 254 249 osc_byte_num <= 1'd0; 255 state1 <= 3'd4; 256 end 257 250 state1 <= 4'd6; 251 end 252 8'h34: 253 begin 254 led_reg <= 1'b1; 255 state1 <= 4'd1; 256 end 257 8'h35: 258 begin 259 led_reg <= 1'b0; 260 tst_counter <= 11'd0; 261 state1 <= 4'd9; 262 end 258 263 endcase 259 264 end 260 265 end 261 266 267 // hst transfer 262 268 3: 263 269 begin 264 // hst transfer 265 usb_fifo_rx_rdreq <= 1'b0; 266 usb_fifo_tx_wrreq <= ~usb_fifo_tx_full; 270 usb_fifo_tx_data <= hst_q[7:0]; 271 usb_fifo_tx_wrreq <= 1'b1; 272 hst_byte_num <= 2'd1; 273 state1 <= 4'd4; 274 end 275 4: 276 begin 267 277 if (~usb_fifo_tx_full) 268 278 begin … … 273 283 2'd3: usb_fifo_tx_data <= hst_q[31:24]; 274 284 endcase 275 276 285 if ((&hst_byte_num) & (&hst_addr)) 277 286 begin 278 state1 <= 3'd1; 279 end 280 else if (&hst_byte_num) 281 begin 282 hst_addr <= hst_addr + 12'd1; 283 end 284 285 hst_byte_num <= hst_byte_num + 2'd1; 286 end 287 end 288 289 4: 290 begin 291 usb_fifo_rx_rdreq <= 1'b0; 292 usb_fifo_tx_wrreq <= 1'b0; 293 usb_fifo_tx_data <= osc_counter; 294 state1 <= 3'd5; 295 end 296 287 state1 <= 4'd5; 288 end 289 else 290 begin 291 if (&hst_byte_num) 292 begin 293 hst_addr <= hst_addr + 12'd1; 294 end 295 hst_byte_num <= hst_byte_num + 2'd1; 296 end 297 end 298 end 297 299 5: 298 300 begin 299 301 if (~usb_fifo_tx_full) 300 302 begin 301 usb_fifo_tx_wrreq <= 1'b1; 302 state1 <= 3'd6; 303 end 304 end 305 303 usb_fifo_tx_wrreq <= 1'b0; 304 state1 <= 4'd1; 305 end 306 end 307 308 // osc transfer 306 309 6: 307 310 begin 308 usb_fifo_tx_wrreq <= 1'b0; 309 if (&osc_counter) 310 begin 311 state1 <= 3'd1; 312 end 313 else 314 begin 315 osc_counter <= osc_counter + 11'd1; 316 state1 <= 3'd4; 317 end 318 end 319 320 4: 321 begin 322 // osc transfer 323 usb_fifo_rx_rdreq <= 1'b0; 324 usb_fifo_tx_wrreq <= ~usb_fifo_tx_full; 325 if(~usb_fifo_tx_full) 326 begin 327 usb_fifo_tx_data <= osc_counter; 328 osc_counter <= osc_counter + 11'd1; 329 if (&osc_counter) state1 <= 3'd1; 330 311 usb_fifo_tx_data <= osc_q[7:0]; 312 usb_fifo_tx_wrreq <= 1'b1; 313 osc_byte_num <= 1'd1; 314 state1 <= 4'd7; 315 end 316 7: 317 begin 318 if (~usb_fifo_tx_full) 319 begin 331 320 case (osc_byte_num) 332 321 1'd0: usb_fifo_tx_data <= osc_q[7:0]; 333 322 1'd1: usb_fifo_tx_data <= osc_q[15:8]; 334 323 endcase 335 336 if ((osc_byte_num) & (&osc_counter)) 337 begin 338 state1 <= 3'd1; 339 end 340 else if (osc_byte_num) 341 begin 342 osc_addr <= osc_addr + 10'd1; 343 osc_counter <= osc_counter + 10'd1; 344 end 345 346 osc_byte_num <= ~osc_byte_num; 347 348 end 349 end 350 324 if ((&osc_byte_num) & (&osc_counter)) 325 begin 326 state1 <= 4'd8; 327 end 328 else 329 begin 330 if (&osc_byte_num) 331 begin 332 osc_addr <= osc_addr + 10'd1; 333 osc_counter <= osc_counter + 10'd1; 334 end 335 osc_byte_num <= osc_byte_num + 1'd1; 336 end 337 end 338 end 339 8: 340 begin 341 if (~usb_fifo_tx_full) 342 begin 343 usb_fifo_tx_wrreq <= 1'b0; 344 state1 <= 4'd1; 345 end 346 end 347 // tst transfer 348 9: 349 begin 350 usb_fifo_tx_data <= tst_counter; 351 usb_fifo_tx_wrreq <= 1'b1; 352 tst_counter <= tst_counter + 11'd1; 353 state1 <= 4'd10; 354 end 355 10: 356 begin 357 if (~usb_fifo_tx_full) 358 begin 359 usb_fifo_tx_data <= tst_counter; 360 if (tst_counter == 11'd0) //(&osc_counter) 361 begin 362 state1 <= 4'd11; 363 end 364 else 365 begin 366 tst_counter <= tst_counter + 11'd1; 367 end 368 end 369 end 370 11: 371 begin 372 if (~usb_fifo_tx_full) 373 begin 374 usb_fifo_tx_wrreq <= 1'b0; 375 state1 <= 4'd1; 376 end 377 end 378 351 379 default: 352 380 begin 353 // default state is the first one 354 state1 <= 3'd1; 355 end 356 endcase 357 end 358 359 */ 360 always @(posedge CLK_50MHz) 361 begin 362 case(state1) 363 1: 364 begin 365 usb_fifo_rx_rdreq <= 1'b0; 366 usb_fifo_tx_wrreq <= 1'b0; 367 hst_reset <= 1'b0; 368 osc_reset <= 1'b0; 369 state1 <= 3'd2; 370 end 371 372 2: 373 begin 374 usb_fifo_rx_rdreq <= ~usb_fifo_rx_empty; 375 if (~usb_fifo_rx_empty) 376 begin 377 case (usb_fifo_rx_data) 378 8'h30: 379 begin 380 hst_reset <= 1'b1; 381 state1 <= 3'd1; 382 end 383 8'h31: 384 begin 385 hst_addr <= 12'd0; 386 hst_byte_num <= 2'd0; 387 state1 <= 3'd3; 388 end 389 8'h32: 390 begin 391 led_reg <= 1'b1; 392 osc_reset <= 1'b1; 393 state1 <= 3'd1; 394 end 395 8'h33: 396 begin 397 led_reg <= 1'b0; 398 osc_addr <= osc_start_addr; 399 osc_counter <= 11'd0; 400 osc_byte_num <= 1'd0; 401 state1 <= 3'd4; 402 end 403 404 endcase 405 end 406 end 407 4: 408 begin 409 usb_fifo_tx_data <= osc_counter; 410 usb_fifo_tx_wrreq <= 1'b1; 411 osc_counter <= osc_counter + 11'd1; 412 state1 <= 3'd5; 413 end 414 5: 415 begin 416 if (~usb_fifo_tx_full) 417 begin 418 usb_fifo_tx_data <= osc_counter; 419 if (osc_counter == 11'd0) //(&osc_counter) 420 begin 421 state1 <= 3'd6; 422 end 423 else 424 begin 425 osc_counter <= osc_counter + 11'd1; 426 end 427 end 428 end 429 6: 430 begin 431 if (~usb_fifo_tx_full) 432 begin 433 usb_fifo_tx_wrreq <= 1'b0; 434 state1 <= 3'd1; 435 end 436 end 437 438 439 default: state1 <= 3'd1; 381 state1 <= 4'd1; 382 end 440 383 endcase 441 384 end … … 447 390 begin 448 391 adc_data <= 12'd0; 449 state2 <= 3'd2;392 state2 <= 4'd2; 450 393 end 451 394 … … 453 396 begin 454 397 adc_data <= 12'd1024; 455 state2 <= 3'd3;398 state2 <= 4'd3; 456 399 end 457 400 … … 459 402 begin 460 403 adc_data <= 12'd2048; 461 state2 <= 3'd4;404 state2 <= 4'd4; 462 405 end 463 406 … … 465 408 begin 466 409 adc_data <= 12'd3072; 467 state2 <= 3'd5;410 state2 <= 4'd5; 468 411 end 469 412 … … 471 414 begin 472 415 adc_data <= 12'd4095; 473 state2 <= 3'd1;416 state2 <= 4'd1; 474 417 end 475 418 476 419 default: 477 420 begin 478 state2 <= 3'd1;421 state2 <= 4'd1; 479 422 end 480 423 endcase
Note:
See TracChangeset
for help on using the changeset viewer.