Changeset 33 for trunk/MultiChannelUSB
- Timestamp:
- Sep 7, 2009, 12:03:59 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MultiChannelUSB/usb_fifo.v
r31 r33 11 11 input wire [7:0] tx_data, 12 12 output wire tx_full, rx_empty, 13 output wire [7:0] rx_ data,13 output wire [7:0] rx_q, 14 14 output wire led 15 15 ); 16 16 17 // bidirectional data bus 18 reg int_addr, int_wren, int_rden, int_wrreq, int_rdreq; 19 wire [7:0] int_datain = usb_data; 20 wire [7:0] int_dataout; 21 22 assign usb_data = int_wren ? int_dataout : 8'bz; 23 24 wire rx_full, tx_empty; 25 wire rx_ready, tx_ready; 17 wire int_rx_full, int_tx_empty; 18 wire int_rdreq, int_wrreq, int_pktend; 19 reg is_rx_addr_ok; 26 20 reg [8:0] byte_counter; 27 21 reg [4:0] idle_counter; 28 22 29 assign led = ~usb_empty; 23 wire [7:0] int_rx_data = usb_data; 24 wire [7:0] int_tx_q; 30 25 31 26 fifo32x8 fifo_tx_unit ( … … 36 31 .wrclk(clk), 37 32 .wrreq(tx_wrreq), 38 .q(int_ dataout),39 .rdempty( tx_empty),33 .q(int_tx_q), 34 .rdempty(int_tx_empty), 40 35 .wrfull(tx_full)); 41 36 42 37 fifo32x8 fifo_rx_unit ( 43 38 .aclr(aclr), 44 .data(int_ datain),39 .data(int_rx_data), 45 40 .rdclk(clk), 46 41 .rdreq(rx_rdreq), 47 42 .wrclk(usb_clk), 48 43 .wrreq(int_rdreq), 49 .q(rx_ data),44 .q(rx_q), 50 45 .rdempty(rx_empty), 51 .wrfull(rx_full)); 46 .wrfull(int_rx_full)); 47 48 assign rx_ready = (~usb_empty) & (~int_rx_full) & (~int_pktend); 49 assign tx_ready = (~rx_ready) & (~usb_full) & (~int_tx_empty) & (~int_pktend); 52 50 53 assign rx_ready = (~usb_empty) & (~rx_full); 54 assign tx_ready = (~usb_full) & (~tx_empty); 55 51 assign int_rdreq = (rx_ready) & (is_rx_addr_ok); 52 assign int_wrreq = (tx_ready) & (~is_rx_addr_ok); 53 54 assign int_pktend = (&idle_counter); 55 56 56 always @ (posedge usb_clk) 57 57 begin 58 casez ({rx_ready, tx_ready, int_addr, int_rden}) 59 4'b00??: // idle 60 begin 61 int_addr <= 1'b0; 62 int_rden <= 1'b0; 63 int_wren <= 1'b0; 64 int_rdreq <= 1'b0; 65 int_wrreq <= 1'b0; 66 end 67 4'b1?1?: // set read addr 68 begin 69 int_addr <= 1'b0; 70 int_rden <= 1'b0; 71 int_wren <= 1'b0; 72 int_rdreq <= 1'b0; 73 int_wrreq <= 1'b0; 74 end 75 4'b1?00: // enable reads 76 begin 77 int_addr <= 1'b0; 78 int_rden <= 1'b1; 79 int_wren <= 1'b0; 80 int_rdreq <= 1'b0; 81 int_wrreq <= 1'b0; 82 end 83 4'b1?01: // read 84 begin 85 int_addr <= 1'b0; 86 int_rden <= 1'b1; 87 int_wren <= 1'b0; 88 int_rdreq <= 1'b1; 89 int_wrreq <= 1'b0; 90 end 91 4'b0101: // disable reads 92 begin 93 int_addr <= 1'b0; 94 int_rden <= 1'b0; 95 int_wren <= 1'b0; 96 int_rdreq <= 1'b0; 97 int_wrreq <= 1'b0; 98 end 99 4'b0100: // set write addr 100 begin 101 int_addr <= 1'b1; 102 int_rden <= 1'b0; 103 int_wren <= 1'b1; 104 int_rdreq <= 1'b0; 105 int_wrreq <= 1'b0; 106 end 107 4'b011?: // write 108 begin 109 int_addr <= 1'b1; 110 int_rden <= 1'b0; 111 int_wren <= 1'b1; 112 int_rdreq <= 1'b0; 113 int_wrreq <= 1'b1; 114 end 115 endcase 116 /* 117 if (usb_pktend) 58 // respect 1 clock delay between fifo selection 59 // and data transfer operations 60 is_rx_addr_ok <= rx_ready; 61 62 // assert pktend if buffer contains unsent data 63 // and fifo_tx_unit stays empty for more than 30 clocks 64 if (int_pktend) 118 65 begin 119 66 byte_counter <= 9'd0; 120 67 idle_counter <= 5'd0; 121 68 end 122 else if ( usb_wrreq)69 else if (int_wrreq) 123 70 begin 124 71 byte_counter <= byte_counter + 9'd1; 125 72 idle_counter <= 5'd0; 126 73 end 127 else if ((|byte_counter) & ( tx_empty))74 else if ((|byte_counter) & (int_tx_empty) & (~rx_ready)) 128 75 begin 129 76 byte_counter <= byte_counter; 130 77 idle_counter <= idle_counter + 5'd1; 131 78 end 132 */ 79 133 80 end 134 81 135 assign usb_addr = {1'b1, int_addr}; 136 assign usb_rden = int_rden; 82 assign usb_pktend = int_pktend; 137 83 assign usb_rdreq = int_rdreq; 138 84 assign usb_wrreq = int_wrreq; 139 // assign usb_pktend = (&idle_counter); 140 assign usb_pktend = 1'b0; 85 assign usb_rden = int_rdreq; 86 assign usb_addr = {1'b1, ~rx_ready}; 87 assign usb_data = int_wrreq ? int_tx_q : 8'bz; 141 88 142 89 endmodule
Note:
See TracChangeset
for help on using the changeset viewer.