Changeset 84 for trunk/MultiChannelUSB/control.v
- Timestamp:
- Dec 21, 2009, 5:09:06 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MultiChannelUSB/control.v
r79 r84 28 28 inout wire [17:0] ram_data, 29 29 30 input wire ept_data_ready, 31 input wire [47:0] ept_data, 32 30 33 output wire i2c_wrreq, 31 34 output wire [15:0] i2c_data, … … 36 39 37 40 reg [23:0] led_counter; 38 reg [1 8:0] ram_counter;41 reg [19:0] ram_counter; 39 42 reg [10:0] tst_counter; 40 43 reg [15:0] int_addr, int_max_addr; … … 49 52 reg int_i2c_wrreq; 50 53 54 reg [47:0] int_ept_data; 55 51 56 reg int_cfg_reset; 52 57 reg [15:0] int_dst_data, int_dst_addr; … … 74 79 // assign ram_data = int_ram_we ? int_ram_data : 18'bz; 75 80 // assign ram_addr = {ram_counter[18:5],1'd0,ram_counter[4:0]}; 76 assign ram_addr = {1'd0, ram_counter[18:0]};81 assign ram_addr = ram_counter; 77 82 78 83 genvar j; … … 116 121 int_ram_we <= 1'b0; 117 122 int_ram_data <= 16'd0; 118 ram_counter <= 19'd0;123 ram_counter <= 20'd0; 119 124 idle_counter <= 5'd0; 120 125 byte_counter <= 2'd0; … … 183 188 begin 184 189 tst_counter <= 11'd0; 185 state <= 5'd 6;190 state <= 5'd7; 186 191 end 187 192 16'h0004: … … 189 194 int_ram_we <= 1'b1; 190 195 int_ram_data <= 18'd0; 191 ram_counter <= 19'd0;192 state <= 5'd 9;196 ram_counter <= 20'd0; 197 state <= 5'd10; 193 198 end 194 199 16'h0005: … … 196 201 int_i2c_data <= src; 197 202 int_i2c_wrreq <= 1'b1; 198 state <= 5'd15; 203 state <= 5'd16; 204 end 205 16'h0006: 206 begin 207 int_ram_we <= 1'b1; 208 int_ram_data <= 18'd0; 209 ram_counter <= 20'd0; 210 state <= 5'd17; 199 211 end 200 212 … … 226 238 5: 227 239 begin 240 state <= 5'd6; 241 end 242 243 6: 244 begin 228 245 if (~tx_full) 229 246 begin … … 251 268 252 269 // tst transfer 253 6:270 7: 254 271 begin 255 272 crc_reset <= 1'b0; … … 257 274 int_wrreq <= 1'b1; 258 275 tst_counter <= tst_counter + 11'd1; 259 state <= 5'd 7;260 end 261 7:276 state <= 5'd8; 277 end 278 8: 262 279 begin 263 280 if (~tx_full) … … 266 283 if (&tst_counter) 267 284 begin 268 state <= 5'd 8;285 state <= 5'd9; 269 286 end 270 287 else … … 274 291 end 275 292 end 276 8:293 9: 277 294 begin 278 295 if (~tx_full) … … 283 300 end 284 301 // ram transfer 285 9:302 10: 286 303 begin 287 304 crc_reset <= 1'b0; 288 state <= 5'd1 0;289 end 290 1 0:305 state <= 5'd11; 306 end 307 11: 291 308 begin 292 309 int_ram_data[8:1] <= ram_counter[7:0]; 293 310 // int_ram_data[8:1] <= 8'd0; 294 if (&ram_counter )295 begin 296 state <= 5'd1 1;311 if (&ram_counter[18:0]) 312 begin 313 state <= 5'd12; 297 314 end 298 315 else 299 316 begin 300 state <= 5'd 9;301 ram_counter <= ram_counter + 19'd1;302 end 303 end 304 1 1:317 state <= 5'd10; 318 ram_counter <= ram_counter + 20'd1; 319 end 320 end 321 12: 305 322 begin 306 323 int_ram_we <= 1'b0; 307 324 int_ram_data <= 18'd0; 308 ram_counter <= 19'd0;309 state <= 5'd1 2;310 end 311 1 2:325 ram_counter <= 20'd0; 326 state <= 5'd13; 327 end 328 13: 312 329 begin 313 330 int_wrreq <= 1'b0; 314 state <= 5'd13;315 end316 13:317 begin318 331 state <= 5'd14; 319 332 end 320 333 14: 334 begin 335 state <= 5'd15; 336 end 337 15: 338 begin 339 if (~tx_full) 340 begin 341 int_data <= int_ram_q[8:1]; 342 int_wrreq <= 1'b1; 343 if (&ram_counter[18:0]) 344 begin 345 state <= 5'd0; 346 end 347 else 348 begin 349 state <= 5'd13; 350 ram_counter <= ram_counter + 20'd1; 351 end 352 end 353 end 354 355 // i2c write 356 16: 357 begin 358 crc_reset <= 1'b0; 359 if (~i2c_full) 360 begin 361 int_i2c_wrreq <= 1'b0; 362 state <= 5'd0; 363 end 364 end 365 366 // long sample transfer 367 17: 368 begin 369 crc_reset <= 1'b0; 370 if (ept_data_ready) 371 begin 372 ram_counter <= ram_counter + 20'd1; 373 int_ept_data <= ept_data; 374 state <= 5'd18; 375 end 376 end 377 18: 378 begin 379 // int_ram_data[8:1] <= ram_counter[7:0]; 380 int_ram_data[8:1] <= int_ept_data[7:0]; 381 int_ram_data[17:10] <= int_ept_data[15:8]; 382 ram_counter <= ram_counter + 20'd1; 383 state <= 5'd19; 384 end 385 19: 386 begin 387 // int_ram_data[8:1] <= ram_counter[7:0]; 388 int_ram_data[8:1] <= int_ept_data[23:16]; 389 int_ram_data[17:10] <= int_ept_data[31:24]; 390 ram_counter <= ram_counter + 20'd1; 391 state <= 5'd20; 392 end 393 394 20: 395 begin 396 // int_ram_data[8:1] <= ram_counter[7:0]; 397 int_ram_data[8:1] <= int_ept_data[39:32]; 398 int_ram_data[17:10] <= int_ept_data[47:40]; 399 if (&ram_counter) 400 begin 401 int_ram_we <= 1'b0; 402 int_ram_data <= 18'd0; 403 ram_counter <= 19'd0; 404 state <= 5'd21; 405 end 406 else 407 begin 408 state <= 5'd17; 409 end 410 end 411 /* 412 21: 413 begin 414 int_wrreq <= 1'b0; 415 state <= 5'd22; 416 end 417 418 22: 419 begin 420 state <= 5'd23; 421 end 422 423 23: 321 424 begin 322 425 if (~tx_full) … … 330 433 else 331 434 begin 332 state <= 5'd12; 333 ram_counter <= ram_counter + 19'd1; 334 end 335 end 336 end 337 338 // i2c write 339 15: 340 begin 341 crc_reset <= 1'b0; 342 if (~i2c_full) 343 begin 344 int_i2c_wrreq <= 1'b0; 345 state <= 5'd0; 435 state <= 5'd21; 436 ram_counter <= ram_counter + 20'd1; 437 end 438 end 439 end 440 */ 441 21: 442 begin 443 int_wrreq <= 1'b0; 444 state <= 5'd22; 445 end 446 447 22: 448 begin 449 state <= 5'd23; 450 end 451 452 23: 453 begin 454 if (~tx_full) 455 begin 456 int_data <= int_ram_q[8:1]; 457 int_wrreq <= 1'b1; 458 state <= 5'd24; 459 end 460 end 461 462 24: 463 begin 464 int_data <= int_ram_q[17:10]; 465 state <= 5'd25; 466 end 467 468 25: 469 begin 470 if (~tx_full) 471 begin 472 int_wrreq <= 1'b0; 473 if (&ram_counter) 474 begin 475 state <= 5'd0; 476 end 477 else 478 begin 479 state <= 5'd21; 480 ram_counter <= ram_counter + 20'd1; 481 end 346 482 end 347 483 end
Note:
See TracChangeset
for help on using the changeset viewer.