Attention
This documentation is a work in progress. Expect to see errors and unfinished things.
fiq_interp Source File
1`timescale 1ns / 1ns
2
3// Name: IQ interpolator
4//% Takes interleaved I-Q, produces interpolated,
5//% separate streams ready for upconversion
6module fiq_interp #(
7 parameter a_dw=16,
8 parameter i_dw=17,
9 parameter q_dw=17
10) (
11 input clk,
12 input signed [a_dw-1:0] a_data, // Interleaved I-Q Data
13 input a_gate, // Data valid gate
14 input a_trig, // 1 bit information telling data is I or Q
15 output signed [i_dw-1:0] i_data,
16 output i_gate,
17 output i_trig,
18 output signed [q_dw-1:0] q_data,
19 output q_gate,
20 output q_trig,
21 output time_err
22);
23
24wire iq_sync = a_trig;
25reg signed [a_dw-1:0] iq_in1=0, iq_in2=0;
26always @(posedge clk) begin
27 iq_in1 <= a_data;
28 iq_in2 <= iq_in1;
29end
30wire signed [a_dw-1:0] i_raw = iq_sync ? iq_in1 : a_data;
31wire signed [a_dw-1:0] q_raw = iq_sync ? iq_in2 : iq_in1;
32
33reg signed [a_dw-1:0] i_raw1=0, q_raw1=0;
34reg signed [a_dw :0] i2i=0, i2q=0;
35always @(posedge clk) begin
36 i_raw1 <= i_raw;
37 q_raw1 <= q_raw;
38 i2i <= i_raw + i_raw1;
39 i2q <= q_raw + q_raw1;
40end
41
42reg last_sync=0, time_err_r=0;
43always @(posedge clk) begin
44 last_sync <= iq_sync;
45 time_err_r <= ~a_gate | (iq_sync & ~last_sync);
46end
47
48assign i_data = i2i;
49assign i_gate = 1'b1;
50assign i_trig = 1'b1;
51assign q_data = i2q;
52assign q_gate = 1'b1;
53assign q_trig = 1'b1;
54assign time_err = time_err_r;
55
56endmodule