1 //`include "../../firmware/include/fpga_regs_common.v"
2 //`include "../../firmware/include/fpga_regs_standard.v"
3 module rx_buffer_inband
6 input reset, // DSP side reset (used here), do not reset registers
7 input reset_regs, //Only reset registers
10 output wire have_pkt_rdy,
11 output reg rx_overrun,
12 input wire [3:0] channels,
13 input wire [15:0] ch_0,
14 input wire [15:0] ch_1,
15 input wire [15:0] ch_2,
16 input wire [15:0] ch_3,
17 input wire [15:0] ch_4,
18 input wire [15:0] ch_5,
19 input wire [15:0] ch_6,
20 input wire [15:0] ch_7,
24 input [6:0] serial_addr,
25 input [31:0] serial_data,
27 output wire [15:0] debugbus,
29 //Connection with tx_inband
31 input [15:0] rx_databus,
33 output reg rx_WR_enabled,
35 input wire [31:0] rssi_0, input wire [31:0] rssi_1,
36 input wire [31:0] rssi_2, input wire [31:0] rssi_3,
37 input wire [1:0] tx_overrun, input wire [1:0] tx_underrun
40 parameter NUM_CHAN = 1;
45 always @(negedge usbclk)
47 read_count <= #1 9'd0;
48 else if(RD & ~read_count[8])
49 read_count <= #1 read_count + 9'd1;
51 read_count <= #1 RD ? read_count : 9'b0;
55 always @(posedge rxclk)
59 adctime <= adctime + 1;
68 fifo_4kx16_dc rx_usb_fifo (
72 .rdreq ( RD & ~read_count[8] ),
79 .wrusedw ( wrusedw ) );
81 assign have_pkt_rdy = (rdusedw >= 12'd256);
82 assign have_space = (wrusedw < 12'd760);
86 wire [15:0] chan_fifodata;
87 wire [9:0] chan_usedw;
88 wire [NUM_CHAN:0] chan_empty;
90 wire [NUM_CHAN:0] rx_full;
92 packet_builder #(NUM_CHAN) rx_pkt_builer (
97 .chan_rdreq ( chan_rdreq ),
98 .chan_fifodata ( chan_fifodata ),
99 .chan_empty ( chan_empty ),
100 .rd_select ( rd_select ),
101 .chan_usedw ( chan_usedw ),
103 .fifodata ( fifodata ),
104 .have_space ( have_space ),
105 .rssi_0(rssi_0), .rssi_1(rssi_1),
106 .rssi_2(rssi_2),.rssi_3(rssi_3), .debugbus(debug),
107 .overrun(tx_overrun), .underrun(tx_underrun));
110 always @(posedge rxclk)
115 else if(clear_status)
119 always @(posedge rxclk)
125 // TODO write this genericly
126 wire [15:0]ch[NUM_CHAN:0];
130 always @(posedge rxclk)
138 wire [15:0] dataout [0:NUM_CHAN];
139 wire [9:0] usedw [0:NUM_CHAN];
140 wire empty[0:NUM_CHAN];
142 generate for (i = 0 ; i < NUM_CHAN; i = i + 1)
143 begin : generate_channel_fifos
146 assign rdreq = (rd_select == i) & chan_rdreq;
147 //assign chan_empty[i] = usedw[i] < 10'd126;
148 fifo_1kx16 rx_chan_fifo (
153 .wrreq ( ~rx_full[i] & rxstrobe),
158 .almost_empty(chan_empty[i])
163 fifo_1kx16 rx_cmd_fifo (
166 .data ( rx_databus ),
167 .rdreq ( (rd_select == NUM_CHAN) & chan_rdreq ),
168 .wrreq ( rx_WR & rx_WR_enabled),
170 .full ( rx_full[NUM_CHAN] ),
171 .q ( dataout[NUM_CHAN]),
172 .usedw ( usedw[NUM_CHAN] )
174 assign chan_empty[NUM_CHAN] = cmd_empty | rx_WR_enabled;
175 assign chan_fifodata = dataout[rd_select];
176 assign chan_usedw = usedw[rd_select];
177 assign debugbus = {rxstrobe, chan_rdreq, debug,
178 rx_full[0], chan_empty[0], empty[0], have_space, RD, rxclk};