Changeset 8295
- Timestamp:
- 04/29/08 21:52:31
- Files:
-
- gnuradio/trunk/mblock/src/lib/mb_message.cc (modified) (1 diff)
- gnuradio/trunk/pmt/src/lib/pmt.cc (modified) (1 diff)
- gnuradio/trunk/pmt/src/lib/pmt.h (modified) (1 diff)
- gnuradio/trunk/pmt/src/lib/pmt_pool.cc (modified) (4 diffs)
- gnuradio/trunk/pmt/src/lib/pmt_pool.h (modified) (2 diffs)
- gnuradio/trunk/pmt/src/lib/qa_pmt_prims.cc (modified) (1 diff)
- gnuradio/trunk/pmt/src/lib/qa_pmt_prims.h (modified) (2 diffs)
- gnuradio/trunk/usrp/fpga/Makefile.extra (modified) (2 diffs)
- gnuradio/trunk/usrp/fpga/inband_lib/chan_fifo_reader.v (modified) (5 diffs)
- gnuradio/trunk/usrp/fpga/inband_lib/channel_demux.v (modified) (2 diffs)
- gnuradio/trunk/usrp/fpga/inband_lib/channel_ram.v (modified) (1 diff)
- gnuradio/trunk/usrp/fpga/inband_lib/cmd_reader.v (modified) (1 diff)
- gnuradio/trunk/usrp/fpga/inband_lib/data_packet_fifo.v (deleted)
- gnuradio/trunk/usrp/fpga/inband_lib/packet_builder.v (modified) (6 diffs)
- gnuradio/trunk/usrp/fpga/inband_lib/register_io.v (modified) (3 diffs)
- gnuradio/trunk/usrp/fpga/inband_lib/rx_buffer_inband.v (modified) (2 diffs)
- gnuradio/trunk/usrp/fpga/inband_lib/tx_buffer_inband.v (modified) (1 diff)
- gnuradio/trunk/usrp/fpga/inband_lib/usb_fifo_reader.v (deleted)
- gnuradio/trunk/usrp/fpga/inband_lib/usb_fifo_writer.v (deleted)
- gnuradio/trunk/usrp/fpga/megacells/fifo_1kx16.bsf (modified) (1 diff)
- gnuradio/trunk/usrp/fpga/megacells/fifo_1kx16.v (modified) (3 diffs)
- gnuradio/trunk/usrp/fpga/megacells/fifo_1kx16_bb.v (modified) (2 diffs)
- gnuradio/trunk/usrp/fpga/rbf/Makefile.am (modified) (1 diff)
- gnuradio/trunk/usrp/fpga/rbf/rev2/inband_1rxhb_1tx.rbf (copied) (copied from gnuradio/branches/features/inband-usb/usrp/fpga/rbf/rev2/inband_1rxhb_1tx.rbf)
- gnuradio/trunk/usrp/fpga/rbf/rev2/inband_2rxhb_2tx.rbf (copied) (copied from gnuradio/branches/features/inband-usb/usrp/fpga/rbf/rev2/inband_2rxhb_2tx.rbf)
- gnuradio/trunk/usrp/fpga/rbf/rev4/inband_1rxhb_1tx.rbf (copied) (copied from gnuradio/branches/features/inband-usb/usrp/fpga/rbf/rev4/inband_1rxhb_1tx.rbf)
- gnuradio/trunk/usrp/fpga/rbf/rev4/inband_2rxhb_2tx.rbf (copied) (copied from gnuradio/branches/features/inband-usb/usrp/fpga/rbf/rev4/inband_2rxhb_2tx.rbf)
- gnuradio/trunk/usrp/fpga/toplevel/usrp_inband_usb/config.vh (modified) (1 diff)
- gnuradio/trunk/usrp/fpga/toplevel/usrp_inband_usb/usrp_inband_usb.qsf (modified) (3 diffs)
- gnuradio/trunk/usrp/fpga/toplevel/usrp_inband_usb/usrp_inband_usb.v (modified) (7 diffs)
- gnuradio/trunk/usrp/host/apps-inband (modified) (1 prop)
- gnuradio/trunk/usrp/host/apps-inband/Makefile.am (modified) (3 diffs)
- gnuradio/trunk/usrp/host/apps-inband/gmac.cc (deleted)
- gnuradio/trunk/usrp/host/apps-inband/gmac.h (deleted)
- gnuradio/trunk/usrp/host/apps-inband/gmac.mbh (deleted)
- gnuradio/trunk/usrp/host/apps-inband/gmac_symbols.h (deleted)
- gnuradio/trunk/usrp/host/apps-inband/test_gmac_tx.cc (deleted)
- gnuradio/trunk/usrp/host/apps-inband/test_usrp_inband_2rx.cc (copied) (copied from gnuradio/branches/features/inband-usb/usrp/host/apps-inband/test_usrp_inband_2rx.cc)
- gnuradio/trunk/usrp/host/apps-inband/test_usrp_inband_2tx.cc (copied) (copied from gnuradio/branches/features/inband-usb/usrp/host/apps-inband/test_usrp_inband_2tx.cc)
- gnuradio/trunk/usrp/host/apps-inband/test_usrp_inband_cs.cc (deleted)
- gnuradio/trunk/usrp/host/apps-inband/test_usrp_inband_overrun.cc (modified) (2 diffs)
- gnuradio/trunk/usrp/host/apps-inband/test_usrp_inband_registers.cc (modified) (1 diff)
- gnuradio/trunk/usrp/host/apps-inband/test_usrp_inband_rx.cc (modified) (6 diffs)
- gnuradio/trunk/usrp/host/apps-inband/test_usrp_inband_timestamps.cc (modified) (1 diff)
- gnuradio/trunk/usrp/host/apps-inband/test_usrp_inband_tx.cc (modified) (15 diffs)
- gnuradio/trunk/usrp/host/apps-inband/test_usrp_inband_underrun.cc (modified) (3 diffs)
- gnuradio/trunk/usrp/host/lib/inband/Makefile.am (modified) (2 diffs)
- gnuradio/trunk/usrp/host/lib/inband/fake_usrp.cc (deleted)
- gnuradio/trunk/usrp/host/lib/inband/fake_usrp.h (deleted)
- gnuradio/trunk/usrp/host/lib/inband/qa_inband_usrp_server.cc (modified) (10 diffs)
- gnuradio/trunk/usrp/host/lib/inband/qa_inband_usrp_server.h (modified) (2 diffs)
- gnuradio/trunk/usrp/host/lib/inband/test_usrp_inband.cc (deleted)
- gnuradio/trunk/usrp/host/lib/inband/usrp_inband_usb_packet.cc (modified) (16 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_inband_usb_packet.h (modified) (2 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_rx.cc (modified) (6 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_rx.h (modified) (2 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_rx_stub.cc (modified) (6 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_rx_stub.h (modified) (3 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_server.cc (modified) (31 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_server.h (modified) (2 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_server.mbh (modified) (1 diff)
- gnuradio/trunk/usrp/host/lib/inband/usrp_tx.cc (modified) (3 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_tx_stub.cc (modified) (3 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_usb_interface.cc (modified) (13 diffs)
- gnuradio/trunk/usrp/host/lib/inband/usrp_usb_interface.h (modified) (1 diff)
- gnuradio/trunk/usrp/host/lib/legacy/fusb_linux.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/trunk/mblock/src/lib/mb_message.cc
r6044 r8295 27 27 #include <pmt_pool.h> 28 28 29 static const int CACHE_LINE_SIZE = 64; // good guess30 31 29 static const int CACHE_LINE_SIZE = 64; // good guess 30 static const int MAX_MESSAGES = 1024; // KLUDGE max number of messages in sys 31 // 0 -> no limit 32 32 #if MB_MESSAGE_LOCAL_ALLOCATOR 33 33 34 static pmt_pool global_msg_pool(sizeof(mb_message), CACHE_LINE_SIZE); 34 static pmt_pool 35 global_msg_pool(sizeof(mb_message), CACHE_LINE_SIZE, 16*1024, MAX_MESSAGES); 35 36 36 37 void * gnuradio/trunk/pmt/src/lib/pmt.cc
r8292 r8295 964 964 965 965 pmt_t 966 pmt_list_add(pmt_t list, pmt_t item) 967 { 968 return pmt_reverse(pmt_cons(item, pmt_reverse(list))); 969 } 970 971 pmt_t 966 972 pmt_caar(pmt_t pair) 967 973 { gnuradio/trunk/pmt/src/lib/pmt.h
r6307 r8295 610 610 pmt_t pmt_list6(pmt_t x1, pmt_t x2, pmt_t x3, pmt_t x4, pmt_t x5, pmt_t x6); 611 611 612 /*! 613 * \brief Return \p list with \p item added to it. 614 */ 615 pmt_t pmt_list_add(pmt_t list, pmt_t item); 616 612 617 613 618 /* gnuradio/trunk/pmt/src/lib/pmt_pool.cc
r6044 r8295 33 33 } 34 34 35 pmt_pool::pmt_pool(size_t itemsize, size_t alignment, size_t allocation_size) 36 : d_itemsize(ROUNDUP(itemsize, alignment)), 35 pmt_pool::pmt_pool(size_t itemsize, size_t alignment, 36 size_t allocation_size, size_t max_items) 37 : d_cond(&d_mutex), 38 d_itemsize(ROUNDUP(itemsize, alignment)), 37 39 d_alignment(alignment), 38 40 d_allocation_size(std::max(allocation_size, 16 * itemsize)), 41 d_max_items(max_items), d_n_items(0), 39 42 d_freelist(0) 40 43 { … … 54 57 item *p; 55 58 59 if (d_max_items != 0){ 60 while (d_n_items >= d_max_items) 61 d_cond.wait(); 62 } 63 56 64 if (d_freelist){ // got something? 57 65 p = d_freelist; 58 66 d_freelist = p->d_next; 67 d_n_items++; 59 68 return p; 60 69 } … … 80 89 p = d_freelist; 81 90 d_freelist = p->d_next; 91 d_n_items++; 82 92 return p; 83 93 } … … 94 104 p->d_next = d_freelist; 95 105 d_freelist = p; 106 d_n_items--; 107 if (d_max_items != 0) 108 d_cond.signal(); 96 109 } gnuradio/trunk/pmt/src/lib/pmt_pool.h
r6044 r8295 39 39 40 40 omni_mutex d_mutex; 41 omni_condition d_cond; 41 42 42 43 size_t d_itemsize; 43 44 size_t d_alignment; 44 45 size_t d_allocation_size; 46 size_t d_max_items; 47 size_t d_n_items; 45 48 item *d_freelist; 46 49 std::vector<char *> d_allocations; … … 51 54 * \param alignment alignment in bytes of all objects to be allocated (must be power-of-2). 52 55 * \param allocation_size number of bytes to allocate at a time from the underlying allocator. 56 * \param max_items is the maximum number of items to allocate. If this number is exceeded, 57 * the allocate blocks. 0 implies no limit. 53 58 */ 54 pmt_pool(size_t itemsize, size_t alignment = 16, size_t allocation_size = 4096); 59 pmt_pool(size_t itemsize, size_t alignment = 16, 60 size_t allocation_size = 4096, size_t max_items = 0); 55 61 ~pmt_pool(); 56 62 gnuradio/trunk/pmt/src/lib/qa_pmt_prims.cc
r6307 r8295 302 302 } 303 303 304 void 305 qa_pmt_prims::test_lists() 306 { 307 pmt_t s0 = pmt_intern("s0"); 308 pmt_t s1 = pmt_intern("s1"); 309 pmt_t s2 = pmt_intern("s2"); 310 pmt_t s3 = pmt_intern("s3"); 311 312 pmt_t l1 = pmt_list4(s0, s1, s2, s3); 313 pmt_t l2 = pmt_list3(s0, s1, s2); 314 pmt_t l3 = pmt_list_add(l2, s3); 315 CPPUNIT_ASSERT(pmt_equal(l1, l3)); 316 } 317 304 318 // ------------------------------------------------------------------------ 305 319 gnuradio/trunk/pmt/src/lib/qa_pmt_prims.h
r6044 r8295 41 41 CPPUNIT_TEST(test_any); 42 42 CPPUNIT_TEST(test_io); 43 CPPUNIT_TEST(test_lists); 43 44 CPPUNIT_TEST(test_serialize); 44 45 CPPUNIT_TEST_SUITE_END(); … … 57 58 void test_any(); 58 59 void test_io(); 60 void test_lists(); 59 61 void test_serialize(); 60 62 }; gnuradio/trunk/usrp/fpga/Makefile.extra
r6777 r8295 5 5 inband_lib/channel_ram.v \ 6 6 inband_lib/cmd_reader.v \ 7 inband_lib/data_packet_fifo.v \8 7 inband_lib/packet_builder.v \ 9 8 inband_lib/register_io.v \ … … 11 10 inband_lib/tx_buffer_inband.v \ 12 11 inband_lib/tx_packer.v \ 13 inband_lib/usb_fifo_reader.v \14 inband_lib/usb_fifo_writer.v \15 12 inband_lib/usb_packet_fifo.v \ 16 13 megacells/accum32.bsf \ gnuradio/trunk/usrp/fpga/inband_lib/chan_fifo_reader.v
r6429 r8295 1 1 module chan_fifo_reader 2 ( reset, tx_clock, tx_strobe, adc_time, samples_format,2 (reset, tx_clock, tx_strobe, timestamp_clock, samples_format, 3 3 fifodata, pkt_waiting, rdreq, skip, tx_q, tx_i, 4 4 underrun, tx_empty, debug, rssi, threshhold, rssi_wait) ; 5 5 6 input wire reset ; 7 input wire tx_clock ; 8 input wire tx_strobe ; //signal to output tx_i and tx_q 9 input wire [31:0] adc_time ; //current time 10 input wire [3:0] samples_format ;// not useful at this point 11 input wire [31:0] fifodata ; //the data input 12 input wire pkt_waiting ; //signal the next packet is ready 13 output reg rdreq ; //actually an ack to the current fifodata 14 output reg skip ; //finish reading current packet 15 output reg [15:0] tx_q ; //top 16 bit output of fifodata 16 output reg [15:0] tx_i ; //bottom 16 bit output of fifodata 17 output reg underrun ; 18 output reg tx_empty ; //cause 0 to be the output 19 input wire [31:0] rssi; 20 input wire [31:0] threshhold; 21 input wire [31:0] rssi_wait; 22 23 output wire [14:0] debug; 24 assign debug = {reader_state, trash, skip, timestamp[4:0], adc_time[4:0]}; 25 // Should not be needed if adc clock rate < tx clock rate 26 // Used only to debug 27 `define JITTER 5 6 input wire reset ; 7 input wire tx_clock ; 8 input wire tx_strobe ; //signal to output tx_i and tx_q 9 input wire [31:0] timestamp_clock ; //current time 10 input wire [3:0] samples_format ;// not useful at this point 11 input wire [31:0] fifodata ; //the data input 12 input wire pkt_waiting ; //signal the next packet is ready 13 output reg rdreq ; //actually an ack to the current fifodata 14 output reg skip ; //finish reading current packet 15 output reg [15:0] tx_q ; //top 16 bit output of fifodata 16 output reg [15:0] tx_i ; //bottom 16 bit output of fifodata 17 output reg underrun ; 18 output reg tx_empty ; //cause 0 to be the output 19 input wire [31:0] rssi; 20 input wire [31:0] threshhold; 21 input wire [31:0] rssi_wait; 22 23 output wire [14:0] debug; 24 assign debug = {7'd0, rdreq, skip, reader_state, pkt_waiting, tx_strobe, tx_clock}; 25 26 //Samples format 27 // 16 bits interleaved complex samples 28 `define QI16 4'b0 28 29 29 //Samples format 30 // 16 bits interleaved complex samples 31 `define QI16 4'b0 32 33 // States 34 parameter IDLE = 3'd0; 35 parameter HEADER = 3'd1; 36 parameter TIMESTAMP = 3'd2; 37 parameter WAIT = 3'd3; 38 parameter WAITSTROBE = 3'd4; 39 parameter SEND = 3'd5; 40 41 // Header format 42 `define PAYLOAD 8:2 43 `define ENDOFBURST 27 44 `define STARTOFBURST 28 45 `define RSSI_FLAG 26 30 // States 31 parameter IDLE = 3'd0; 32 parameter HEADER = 3'd1; 33 parameter TIMESTAMP = 3'd2; 34 parameter WAIT = 3'd3; 35 parameter WAITSTROBE = 3'd4; 36 parameter SEND = 3'd5; 37 38 // Header format 39 `define PAYLOAD 8:2 40 `define ENDOFBURST 27 41 `define STARTOFBURST 28 42 `define RSSI_FLAG 26 46 43 47 44 48 /* State registers */49 reg [2:0] reader_state;50 /* Local registers */51 reg [6:0] payload_len;52 reg [6:0] read_len;53 reg [31:0] timestamp;54 reg burst;55 regtrash;56 regrssi_flag;57 reg[31:0] time_wait;45 /* State registers */ 46 reg [2:0] reader_state; 47 /* Local registers */ 48 reg [6:0] payload_len; 49 reg [6:0] read_len; 50 reg [31:0] timestamp; 51 reg burst; 52 reg trash; 53 reg rssi_flag; 54 reg [31:0] time_wait; 58 55 59 always @(posedge tx_clock)60 begin61 if (reset)62 begin63 reader_state <= IDLE;64 rdreq <= 0;65 skip <= 0;66 underrun <= 0;67 burst <= 0;68 tx_empty <= 1;69 tx_q <= 0;70 tx_i <= 0;71 trash <= 0;72 rssi_flag <= 0;73 time_wait <= 0;56 always @(posedge tx_clock) 57 begin 58 if (reset) 59 begin 60 reader_state <= IDLE; 61 rdreq <= 0; 62 skip <= 0; 63 underrun <= 0; 64 burst <= 0; 65 tx_empty <= 1; 66 tx_q <= 0; 67 tx_i <= 0; 68 trash <= 0; 69 rssi_flag <= 0; 70 time_wait <= 0; 74 71 end 75 72 else 76 begin73 begin 77 74 case (reader_state) 78 IDLE:75 IDLE: 79 76 begin 80 /* 81 * reset all the variables and wait for a tx_strobe 82 * it is assumed that the ram connected to this fifo_reader 83 * is a short hand fifo meaning that the header to the next packet 84 * is already available to this fifo_reader when pkt_waiting is on 85 */ 86 skip <=0; 87 time_wait <= 0; 88 if (pkt_waiting == 1) 89 begin 90 reader_state <= HEADER; 91 rdreq <= 1; 92 underrun <= 0; 93 end 94 if (burst == 1 && pkt_waiting == 0) 95 underrun <= 1; 96 97 if (tx_strobe == 1) 98 tx_empty <= 1 ; 77 /* 78 * reset all the variables and wait for a tx_strobe 79 * it is assumed that the ram connected to this fifo_reader 80 * is a short hand fifo meaning that the header to the next packet 81 * is already available to this fifo_reader when pkt_waiting is on 82 */ 83 skip <=0; 84 time_wait <= 0; 85 if (pkt_waiting == 1) 86 begin 87 reader_state <= HEADER; 88 rdreq <= 1; 89 underrun <= 0; 90 end 91 if (burst == 1 && pkt_waiting == 0) 92 underrun <= 1; 93 if (tx_strobe == 1) 94 tx_empty <= 1 ; 99 95 end 100 96 101 /* Process header */97 /* Process header */ 102 98 HEADER: 103 begin99 begin 104 100 if (tx_strobe == 1) 105 101 tx_empty <= 1 ; … … 115 111 burst <= 0; 116 112 117 if (trash == 1 && fifodata[`STARTOFBURST] == 0)118 begin119 skip <= 1;120 reader_state <= IDLE;121 rdreq <= 0;122 end123 else124 begin125 payload_len <= fifodata[`PAYLOAD] ;126 read_len <= 0;127 rdreq <= 1;128 reader_state <= TIMESTAMP;129 end130 end113 if (trash == 1 && fifodata[`STARTOFBURST] == 0) 114 begin 115 skip <= 1; 116 reader_state <= IDLE; 117 rdreq <= 0; 118 end 119 else 120 begin 121 payload_len <= fifodata[`PAYLOAD] ; 122 read_len <= 0; 123 rdreq <= 1; 124 reader_state <= TIMESTAMP; 125 end 126 end 131 127 132 128 TIMESTAMP: 133 begin129 begin 134 130 timestamp <= fifodata; 135 131 reader_state <= WAIT; … … 137 133 tx_empty <= 1 ; 138 134 rdreq <= 0; 139 end135 end 140 136 141 // Decide if we wait, send or discard samples137 // Decide if we wait, send or discard samples 142 138 WAIT: 143 begin139 begin 144 140 if (tx_strobe == 1) 145 141 tx_empty <= 1 ; 146 142 147 143 time_wait <= time_wait + 32'd1; 148 // Outdated149 if ((timestamp < adc_time) ||150 (time_wait >= rssi_wait && rssi_wait != 0 && rssi_flag))151 begin 152 trash <= 1;153 reader_state <= IDLE;154 skip <= 1;144 // Outdated 145 if ((timestamp < timestamp_clock) || 146 (time_wait >= rssi_wait && rssi_wait != 0 && rssi_flag)) 147 begin 148 trash <= 1; 149 reader_state <= IDLE; 150 skip <= 1; 155 151 end 156 152 // Let's send it 157 else if ((timestamp <= adc_time + `JITTER 158 && timestamp > adc_time) 153 else if (timestamp == timestamp_clock 159 154 || timestamp == 32'hFFFFFFFF) 160 begin 161 if (rssi <= threshhold || rssi_flag == 0) 162 begin 163 trash <= 0; 164 reader_state <= WAITSTROBE; 165 end 166 else 167 reader_state <= WAIT; 168 end 169 else 170 reader_state <= WAIT; 171 // Wait a little bit more 172 //else if (timestamp > adc_time + `JITTER) 173 // reader_state <= WAIT; 174 end 155 begin 156 if (rssi <= threshhold || rssi_flag == 0) 157 begin 158 trash <= 0; 159 reader_state <= WAITSTROBE; 160 end 161 else 162 reader_state <= WAIT; 163 end 164 else 165 reader_state <= WAIT; 166 end 175 167 176 168 // Wait for the transmit chain to be ready 177 169 WAITSTROBE: 178 begin170 begin 179 171 // If end of payload... 180 172 if (read_len == payload_len) … … 190 182 rdreq <= 1; 191 183 end 192 end184 end 193 185 194 // Send the samples to the tx_chain186 // Send the samples to the tx_chain 195 187 SEND: 196 begin188 begin 197 189 reader_state <= WAITSTROBE; 198 190 read_len <= read_len + 7'd1; … … 214 206 end 215 207 endcase 216 end208 end 217 209 218 210 default: 219 begin220 //error handling211 begin 212 //error handling 221 213 reader_state <= IDLE; 222 end214 end 223 215 endcase 224 216 end gnuradio/trunk/usrp/fpga/inband_lib/channel_demux.v
r6307 r8295 1 1 module channel_demux 2 #(parameter NUM_CHAN = 2 , parameter CHAN_WIDTH = 2) ( //usb Side3 input [31:0]usbdata_final,4 input WR_final,5 6 // TX Side 7 input reset,8 input txclk,9 output reg [CHAN_WIDTH:0] WR_channel,10 output reg [31:0] ram_data, 11 output reg [CHAN_WIDTH:0] WR_done_channel ); 12 /* Parse header and forward to ram */ 13 reg [2:0]reader_state;14 reg [4:0]channel ;15 reg [6:0]read_length ;2 #(parameter NUM_CHAN = 2) ( //usb Side 3 input [31:0]usbdata_final, 4 input WR_final, 5 // TX Side 6 input reset, 7 input txclk, 8 output reg [NUM_CHAN:0] WR_channel, 9 output reg [31:0] ram_data, 10 output reg [NUM_CHAN:0] WR_done_channel ); 11 /* Parse header and forward to ram */ 12 13 reg [2:0]reader_state; 14 reg [4:0]channel ; 15 reg [6:0]read_length ; 16 16 17 17 // States 18 parameter IDLE =3'd0;19 parameter HEADER =3'd1;20 parameter WAIT =3'd2;21 parameter FORWARD =3'd3;18 parameter IDLE = 3'd0; 19 parameter HEADER = 3'd1; 20 parameter WAIT = 3'd2; 21 parameter FORWARD = 3'd3; 22 22 23 23 `define CHANNEL 20:16 … … 28 28 29 29 always @(posedge txclk) 30 begin30 begin 31 31 if (reset) 32 32 begin gnuradio/trunk/usrp/fpga/inband_lib/channel_ram.v
r6429 r8295 1 1 module channel_ram 2 ( // System 3 input txclk, 4 input reset, 2 ( // System 3 input txclk, input reset, 4 // USB side 5 input [31:0] datain, input WR, input WR_done, output have_space, 6 // Reader side 7 output [31:0] dataout, input RD, input RD_done, output packet_waiting); 5 8 6 // USB side 7 input [31:0] datain, 8 input WR, 9 input WR_done, 10 output have_space, 9 reg [6:0] wr_addr, rd_addr; 10 reg [1:0] which_ram_wr, which_ram_rd; 11 reg [2:0] nb_packets; 12 13 reg [31:0] ram0 [0:127]; 14 reg [31:0] ram1 [0:127]; 15 reg [31:0] ram2 [0:127]; 16 reg [31:0] ram3 [0:127]; 17 18 reg [31:0] dataout0; 19 reg [31:0] dataout1; 20 reg [31:0] dataout2; 21 reg [31:0] dataout3; 22 23 wire wr_done_int; 24 wire rd_done_int; 25 wire [6:0] rd_addr_final; 26 wire [1:0] which_ram_rd_final; 27 28 // USB side 29 always @(posedge txclk) 30 if(WR & (which_ram_wr == 2'd0)) ram0[wr_addr] <= datain; 31 32 always @(posedge txclk) 33 if(WR & (which_ram_wr == 2'd1)) ram1[wr_addr] <= datain; 11 34 12 // Reader side 13 output [31:0] dataout, 14 input RD, 15 input RD_done, 16 output packet_waiting); 17 18 reg [6:0] wr_addr, rd_addr; 19 reg [1:0] which_ram_wr, which_ram_rd; 20 reg [2:0] nb_packets; 21 22 reg [31:0] ram0 [0:127]; 23 reg [31:0] ram1 [0:127]; 24 reg [31:0] ram2 [0:127]; 25 reg [31:0] ram3 [0:127]; 26 27 reg [31:0] dataout0; 28 reg [31:0] dataout1; 29 reg [31:0] dataout2; 30 reg [31:0] dataout3; 31 32 wire wr_done_int; 33 wire rd_done_int; 34 wire [6:0] rd_addr_final; 35 wire [1:0] which_ram_rd_final; 36 37 // USB side 38 always @(posedge txclk) 39 if(WR & (which_ram_wr == 2'd0)) ram0[wr_addr] <= datain; 40 41 always @(posedge txclk) 42 if(WR & (which_ram_wr == 2'd1)) ram1[wr_addr] <= datain; 35 always @(posedge txclk) 36 if(WR & (which_ram_wr == 2'd2)) ram2[wr_addr] <= datain; 43 37 44 always @(posedge txclk) 45 if(WR & (which_ram_wr == 2'd2)) ram2[wr_addr] <= datain; 46 47 always @(posedge txclk) 48 if(WR & (which_ram_wr == 2'd3)) ram3[wr_addr] <= datain; 38 always @(posedge txclk) 39 if(WR & (which_ram_wr == 2'd3)) ram3[wr_addr] <= datain; 49 40 50 41 assign wr_done_int = ((WR && (wr_addr == 7'd127)) || WR_done); 51 42 52 always @(posedge txclk)53 if(reset)54 wr_addr <= 0;55 else if (WR_done)56 wr_addr <= 0;57 else if (WR)58 wr_addr <= wr_addr + 7'd1;43 always @(posedge txclk) 44 if(reset) 45 wr_addr <= 0; 46 else if (WR_done) 47 wr_addr <= 0; 48 else if (WR) 49 wr_addr <= wr_addr + 7'd1; 59 50 60 always @(posedge txclk)61 if(reset)62 which_ram_wr <= 0;63 else if (wr_done_int)64 which_ram_wr <= which_ram_wr + 2'd1;51 always @(posedge txclk) 52 if(reset) 53 which_ram_wr <= 0; 54 else if (wr_done_int) 55 which_ram_wr <= which_ram_wr + 2'd1; 65 56 66 assign have_space = (nb_packets < 3'd3);57 assign have_space = (nb_packets < 3'd3); 67 58 68 // Reader side69 // short hand fifo70 // rd_addr_final is what rd_addr is going to be next clock cycle71 // which_ram_rd_final is what which_ram_rd is going to be next clock cycle72 always @(posedge txclk) dataout0 <= ram0[rd_addr_final];73 always @(posedge txclk) dataout1 <= ram1[rd_addr_final];74 always @(posedge txclk) dataout2 <= ram2[rd_addr_final];75 always @(posedge txclk) dataout3 <= ram3[rd_addr_final];59 // Reader side 60 // short hand fifo 61 // rd_addr_final is what rd_addr is going to be next clock cycle 62 // which_ram_rd_final is what which_ram_rd is going to be next clock cycle 63 always @(posedge txclk) dataout0 <= ram0[rd_addr_final]; 64 always @(posedge txclk) dataout1 <= ram1[rd_addr_final]; 65 always @(posedge txclk) dataout2 <= ram2[rd_addr_final]; 66 always @(posedge txclk) dataout3 <= ram3[rd_addr_final]; 76 67 77 assign dataout = (which_ram_rd_final[1]) ?78 (which_ram_rd_final[0] ? dataout3 : dataout2) :79 (which_ram_rd_final[0] ? dataout1 : dataout0);68 assign dataout = (which_ram_rd_final[1]) ? 69 (which_ram_rd_final[0] ? dataout3 : dataout2) : 70 (which_ram_rd_final[0] ? dataout1 : dataout0); 80 71 81 //RD_done is the only way to signal the end of one packet82 assign rd_done_int = RD_done;72 //RD_done is the only way to signal the end of one packet 73 assign rd_done_int = RD_done; 83 74 84
