summaryrefslogtreecommitdiff
path: root/gr-sounder/src/fpga/lib/sounder_rx.v
diff options
context:
space:
mode:
Diffstat (limited to 'gr-sounder/src/fpga/lib/sounder_rx.v')
-rw-r--r--gr-sounder/src/fpga/lib/sounder_rx.v74
1 files changed, 31 insertions, 43 deletions
diff --git a/gr-sounder/src/fpga/lib/sounder_rx.v b/gr-sounder/src/fpga/lib/sounder_rx.v
index 338afd55e..18038a3a1 100644
--- a/gr-sounder/src/fpga/lib/sounder_rx.v
+++ b/gr-sounder/src/fpga/lib/sounder_rx.v
@@ -19,75 +19,63 @@
// Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301 USA
//
-module sounder_rx(clk_i,rst_i,ena_i,rx_strobe_i,tx_strobe_i,mask_i,degree_i,len_i,
- rx_in_i_i,rx_in_q_i,rx_i_o,rx_q_o,rx_strobe_o,
- loop_i);
+module sounder_rx(clk_i,rst_i,ena_i,sum_strobe_i,ref_strobe_i,
+ mask_i,degree_i,rx_in_i_i,rx_in_q_i,rx_i_o,rx_q_o);
input clk_i; // Master clock
input rst_i; // Subsystem reset
input ena_i; // Subsystem enable
- input rx_strobe_i; // Strobe every received sample
- input tx_strobe_i; // Strobe every transmitted sample
+ input sum_strobe_i; // Strobe on last sample per period
+ input ref_strobe_i; // PN code reference retarded one sample per period
input [15:0] mask_i; // PN code LFSR mask
input [4:0] degree_i; // PN code LFSR sequency degree
- input [15:0] len_i; // PN code LFSR sequence length
+
input [15:0] rx_in_i_i; // I channel on receive
input [15:0] rx_in_q_i; // Q channel on receive
output [15:0] rx_i_o; // I channel of impulse response
output [15:0] rx_q_o; // Q channel of impulse response
- output rx_strobe_o; // Impulse response value ready
-
- input loop_i; // Implement loopback
-
- wire strobe_in = loop_i ? tx_strobe_i : rx_strobe_i;
- wire [16:0] len = loop_i ? (len_i - 1) : ((len_i << 1) - 2);
-
- strobe #(17) phase_strobe(.clk_i(clk_i),.rst_i(rst_i),.ena_i(ena_i),
- .rate_i(len),.strobe_i(strobe_in),.strobe_o(rx_strobe_o),
- .count_o());
-
- wire pn_ref;
- wire ref_strobe = tx_strobe_i & ~rx_strobe_o; // Retard reference phase once per period
- lfsr ref_code
- ( .clk_i(clk_i),.rst_i(rst_i),.ena_i(ena_i),.strobe_i(ref_strobe),.mask_i(mask_i),.pn_o(pn_ref) );
- wire [5:0] offset = (5'd16-degree_i);
-
reg [31:0] sum_i, sum_q;
reg [31:0] total_i, total_q;
- wire [31:0] scaled_i = total_i << offset;
- wire [31:0] scaled_q = total_q << offset;
wire [31:0] i_ext, q_ext;
sign_extend #(16,32) i_extender(rx_in_i_i, i_ext);
sign_extend #(16,32) q_extender(rx_in_q_i, q_ext);
+ wire pn_ref;
+ lfsr ref_code
+ ( .clk_i(clk_i),.rst_i(rst_i),.ena_i(ena_i),.strobe_i(ref_strobe_i),.mask_i(mask_i),.pn_o(pn_ref) );
+
wire [31:0] prod_i = pn_ref ? i_ext : -i_ext;
wire [31:0] prod_q = pn_ref ? q_ext : -q_ext;
-
+
always @(posedge clk_i)
if (rst_i | ~ena_i)
begin
- sum_i <= 0;
- sum_q <= 0;
- total_i <= 0;
- total_q <= 0;
+ sum_i <= #5 0;
+ sum_q <= #5 0;
+ total_i <= #5 0;
+ total_q <= #5 0;
end
- else if (rx_strobe_o)
- begin
- total_i <= sum_i + prod_i;
- total_q <= sum_q + prod_q;
- sum_i <= 0;
- sum_q <= 0;
- end
- else if (strobe_in)
- begin
- sum_i = sum_i + prod_i;
- sum_q = sum_q + prod_q;
- end
-
+ else
+ if (sum_strobe_i)
+ begin
+ total_i <= #5 sum_i;
+ total_q <= #5 sum_q;
+ sum_i <= #5 prod_i;
+ sum_q <= #5 prod_q;
+ end
+ else
+ begin
+ sum_i <= #5 sum_i + prod_i;
+ sum_q <= #5 sum_q + prod_q;
+ end
+
+ wire [5:0] offset = (5'd16-degree_i);
+ wire [31:0] scaled_i = total_i << offset;
+ wire [31:0] scaled_q = total_q << offset;
assign rx_i_o = scaled_i[31:16];
assign rx_q_o = scaled_q[31:16];