1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
//
// Copyright 2020 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//
// Description:
//
// Windowing module. Multiplies each input packet by the coefficients loaded
// into an internal memory.
//
// Parameters:
//
// WINDOW_SIZE : Sets the maximum window size to 2^WINDOW_SIZE samples.
// COEFF_WIDTH : The bit width of coefficients.
//
module window #(
parameter WINDOW_SIZE = 10,
parameter COEFF_WIDTH = 16
) (
input wire clk,
input wire rst,
// Window size to use
input wire [WINDOW_SIZE:0] window_size,
// Coefficient input
input wire [COEFF_WIDTH-1:0] m_axis_coeff_tdata,
input wire m_axis_coeff_tlast,
input wire m_axis_coeff_tvalid,
output wire m_axis_coeff_tready,
// Input data stream
input wire [31:0] i_tdata,
input wire i_tlast,
input wire i_tvalid,
output wire i_tready,
// Output data stream
output wire [31:0] o_tdata,
output wire o_tlast,
output wire o_tvalid,
input wire o_tready
);
// Sample data stream (from i_tdata)
wire [ 31:0] stream_tdata;
wire stream_tlast;
wire stream_tvalid;
wire stream_tready;
// RAM output data stream (saved coefficients)
wire [ 15:0] ram_tdata;
wire ram_tvalid;
wire ram_tready;
// Counter data stream (RAM address for coefficient lookup)
wire [WINDOW_SIZE-1:0] count_tdata;
wire count_tvalid;
wire count_tready;
// Flow control stream. This keeps the counter stream in sync with the
// sample data stream.
wire flow_tvalid;
wire flow_tready;
wire clear_counter;
// Restart the address counter whenever we load a new set of coefficients.
assign clear_counter = m_axis_coeff_tlast &
m_axis_coeff_tvalid &
m_axis_coeff_tready;
// Split the incoming data stream into two
split_stream_fifo #(
.WIDTH (32),
.ACTIVE_MASK (4'b0011)
) split_stream_fifo_i (
.clk (clk),
.reset (rst),
.clear (1'b0),
.i_tdata (i_tdata),
.i_tlast (i_tlast),
.i_tvalid (i_tvalid),
.i_tready (i_tready),
.o0_tdata (stream_tdata),
.o0_tlast (stream_tlast),
.o0_tvalid (stream_tvalid),
.o0_tready (stream_tready),
.o1_tdata (),
.o1_tlast (),
.o1_tvalid (flow_tvalid),
.o1_tready (flow_tready),
.o2_tdata (),
.o2_tlast (),
.o2_tvalid (),
.o2_tready (1'b0),
.o3_tdata (),
.o3_tlast (),
.o3_tvalid (),
.o3_tready (1'b0)
);
// Address generation
counter #(
.WIDTH (WINDOW_SIZE)
) counter_i (
.clk (clk),
.reset (rst),
.clear (clear_counter),
.max (window_size),
.i_tlast (1'b0),
.i_tvalid (flow_tvalid),
.i_tready (flow_tready),
.o_tdata (count_tdata),
.o_tlast (),
.o_tvalid (count_tvalid),
.o_tready (count_tready)
);
// RAM to store window coefficients
ram_to_fifo #(
.DWIDTH (COEFF_WIDTH),
.AWIDTH (WINDOW_SIZE)
) ram_to_fifo_i (
.clk (clk),
.reset (rst),
.clear (1'b0),
.config_tdata (m_axis_coeff_tdata),
.config_tlast (m_axis_coeff_tlast),
.config_tvalid (m_axis_coeff_tvalid),
.config_tready (m_axis_coeff_tready),
.i_tdata (count_tdata),
.i_tlast (1'b0),
.i_tvalid (count_tvalid),
.i_tready (count_tready),
.o_tdata (ram_tdata),
.o_tlast (),
.o_tvalid (ram_tvalid),
.o_tready (ram_tready)
);
// Real by complex multiplier. This multiplier is configured for signed
// fixed point with 15 fractional bits. For N fractional bits (a right-shift
// by N in the multiplication result), set:
// DROP_TOP_P = (WIDTH_REAL + WIDTH_CPLX - WIDTH_P + 5) - N
mult_rc #(
.WIDTH_REAL (COEFF_WIDTH),
.WIDTH_CPLX (16),
.WIDTH_P (16),
.DROP_TOP_P (6)
) mult_rc_i (
.clk (clk),
.reset (rst),
.real_tdata (ram_tdata),
.real_tlast (1'b0),
.real_tvalid (ram_tvalid),
.real_tready (ram_tready),
.cplx_tdata (stream_tdata),
.cplx_tlast (stream_tlast),
.cplx_tvalid (stream_tvalid),
.cplx_tready (stream_tready),
.p_tdata (o_tdata),
.p_tlast (o_tlast),
.p_tvalid (o_tvalid),
.p_tready (o_tready)
);
endmodule
|