diff options
author | Jon Nordby <jononor@gmail.com> | 2025-08-12 23:17:33 +0200 |
---|---|---|
committer | Jon Nordby <jononor@gmail.com> | 2025-08-12 23:17:33 +0200 |
commit | 24a74298e89958aa2c5d6c89a86306115d5a1271 (patch) | |
tree | 334dd72101ae3415e2a4733472a88f589a7cee37 /cocotb_try | |
parent | ab05f129ce2fd5eb3a8a7c06687a7144d3ec18f1 (diff) |
Diffstat (limited to 'cocotb_try')
-rw-r--r-- | cocotb_try/cic3_pdm.v | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/cocotb_try/cic3_pdm.v b/cocotb_try/cic3_pdm.v index 6573396..f34819f 100644 --- a/cocotb_try/cic3_pdm.v +++ b/cocotb_try/cic3_pdm.v @@ -53,8 +53,6 @@ module cic3_pdm ( // Comb stage (runs every DECIMATION clocks) always @(posedge clk or posedge rst) begin - pcm_valid_r <= 0; // make sure valid goes low after high pulse - if (rst) begin comb_0 <= 0; comb_1 <= 0; @@ -64,19 +62,23 @@ module cic3_pdm ( delay_2 <= 0; pcm_valid_r <= 0; pcm_out_r <= 0; - end else if (decim_counter == 63) begin - comb_0 <= integrator_2 - delay_0; - delay_0 <= integrator_2; - - comb_1 <= comb_0 - delay_1; - delay_1 <= comb_0; - - comb_2 <= comb_1 - delay_2; - delay_2 <= comb_1; - - // Bit-shift down to get 16-bit output (tune shift based on DECIMATION and stage count) - pcm_out_r <= comb_2[OUTPUT_SHIFT + 15 : OUTPUT_SHIFT]; - pcm_valid_r <= 1; + end else begin + if (decim_counter == 63) begin + comb_0 <= integrator_2 - delay_0; + delay_0 <= integrator_2; + + comb_1 <= comb_0 - delay_1; + delay_1 <= comb_0; + + comb_2 <= comb_1 - delay_2; + delay_2 <= comb_1; + + // Bit-shift down to get 16-bit output (tune shift based on DECIMATION and stage count) + pcm_out_r <= comb_2[OUTPUT_SHIFT + 15 : OUTPUT_SHIFT]; + pcm_valid_r <= 1; + end else begin + pcm_valid_r <= 0; // make sure valid goes low after high pulse + end end end |