Attention

This documentation is a work in progress. Expect to see errors and unfinished things.

cic_interp Source File

 1`timescale 1ns / 1ns
 2
 3// First-order CIC interpolator
 4module cic_interp(
 5     input clk,
 6     input  [17:0] d_in,
 7     input strobe,
 8     output [17:0] d_out
 9);
10
11// span should be log2(update interval), right?
12
13// Coarse stepwise frequency changes are bad, as we discovered
14// experimentally in hardware at APEX.  But linear small-steps
15// like this should be fine.  The consequences get integrated
16// one more time (to get phase) before they show up on an "ADC".
17parameter span=6;
18
19// Differentiate
20reg signed [17:0] d_last=0, diff=0;
21always @(posedge clk) if (strobe) begin
22     d_last <= d_in;
23     diff <= d_in - d_last;
24end
25
26// Integrate
27reg signed [17+span:0] i1=0;
28always @(posedge clk) begin
29     i1 <= i1+diff;
30end
31assign d_out = i1[17+span:span];
32
33endmodule