summaryrefslogtreecommitdiff
path: root/cocotb_try/cic3_pdm.v
diff options
context:
space:
mode:
authorJon Nordby <jononor@gmail.com>2025-04-26 19:08:39 +0200
committerJon Nordby <jononor@gmail.com>2025-04-26 21:33:29 +0200
commit56afef8ec52a3d3644fc8230e0d92004d3727c4b (patch)
tree2992717827bb59adcba40ad4dc76d193a2d3a00d /cocotb_try/cic3_pdm.v
parentb9d821cb5409a545431d7b34d8df0ad493c26a46 (diff)
cocotb: Run multiple PCM samples
1000 samples is quite slow, takes many seconds
Diffstat (limited to 'cocotb_try/cic3_pdm.v')
-rw-r--r--cocotb_try/cic3_pdm.v7
1 files changed, 5 insertions, 2 deletions
diff --git a/cocotb_try/cic3_pdm.v b/cocotb_try/cic3_pdm.v
index f572d64..1c8ba25 100644
--- a/cocotb_try/cic3_pdm.v
+++ b/cocotb_try/cic3_pdm.v
@@ -6,7 +6,9 @@ module cic3_pdm (
input wire rst, // active-high synchronous reset
input wire pdm_in, // 1-bit PDM data input
output wire signed [15:0] pcm_out, // Decimated PCM output
- output wire pcm_valid // High when pcm_out is valid
+ output wire pcm_valid, // High when pcm_out is valid
+ output reg pdm_out
+
);
parameter DECIMATION = 64; // Decimation factor
@@ -46,7 +48,7 @@ module cic3_pdm (
// Comb stage (runs every DECIMATION clocks)
always @(posedge clk) begin
pcm_valid_r <= 0;
- if (decim_counter == DECIMATION[5:0] - 1) begin
+ if (decim_counter == 63) begin
comb_0 <= integrator_2 - delay_0;
delay_0 <= integrator_2;
@@ -57,6 +59,7 @@ module cic3_pdm (
delay_2 <= comb_1;
// Bit-shift down to get 16-bit output (tune shift based on DECIMATION and stage count)
+ pdm_out <= pdm_in;
pcm_out_r <= comb_2[31:16];
pcm_valid_r <= 1;
end