-
Notifications
You must be signed in to change notification settings - Fork 0
/
CICfilter.v.bak
36 lines (32 loc) · 941 Bytes
/
CICfilter.v.bak
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
module CIC_Filter (
input wire [15:0] AUD_IN,
output wire [15:0] AUD_OUT,
input wire LRCK
);
// Define the parameters for the filter
parameter R = 3; // Decimation factor
parameter M = 1; // Differential delay
// Internal signals
reg [15:0] integrator = 16'h0000;
reg [15:0] comb1 = 16'h0000;
reg [15:0] comb2 = 16'h0000;
reg [15:0] comb3 = 16'h0000;
always @(posedge LRCK) begin
// Comb Stage 1
comb1 <= comb2;
comb2 <= comb3;
comb3 <= AUD_IN - comb1;
// Integrator Stage
if (M == 1) begin
integrator <= integrator + comb3;
end else begin
integrator <= integrator >> M + comb3;
end
// Output Stage
if (R == 1) begin
AUD_OUT <= integrator;
end else begin
AUD_OUT <= integrator >> (R-1);
end
end
endmodule