Attention
This documentation is a work in progress. Expect to see errors and unfinished things.
double_inte_smp Source File
1`timescale 1ns / 1ns
2
3/** DOUBLE_INTE_SMP
4 Variant of double_inte that can operate below the line rate by using an
5 input strobe. Incoming samples are only accumulated when strobe is high.
6
7 *** INCOMPATIBLE WITH OLD double_inte BECAUSE THIS ONE NO LONGER HAS AN
8 UNDOCUMENTED IMPLIED DIVIDE-BY-TWO
9**/
10
11module double_inte_smp #(
12 parameter dwi = 16, // data width in
13 parameter dwo = 28 // data width out. When used for decimation, output width should
14 // be dwi + N*log2(decimation rate), where N=2 is the order of this
15 // double integrator.
16) (
17 input clk,
18 input reset,
19 input stb_in,
20 input signed [dwi-1:0] in,
21 output signed [dwo-1:0] out
22);
23
24reg [1:0] reset_r=0;
25reg signed [dwo-1:0] int1=0, int2=0;
26
27always @(posedge clk) begin
28 reset_r <= {reset_r[0],reset};
29end
30
31always @(posedge clk) begin
32 if (|reset_r) begin
33 int1 <= 0;
34 int2 <= 0;
35 end else if (stb_in) begin
36 int1 <= int1 + in;
37 int2 <= int2 + int1;
38 end
39end
40
41assign out = int2;
42
43endmodule