From 66ed1d846b6fb58193e87cd2f606c02a35c5d4a5 Mon Sep 17 00:00:00 2001 From: John Daktylidis Date: Sun, 23 Jul 2023 18:27:28 +0200 Subject: [PATCH] Modify conditional operators in moving_average.vhd for Quartus compatibility --- src/moving_average.vhd | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/moving_average.vhd b/src/moving_average.vhd index f17a7eb..66d848e 100644 --- a/src/moving_average.vhd +++ b/src/moving_average.vhd @@ -66,13 +66,22 @@ begin overflow <= '1'; end if; if (enable = '1') then - accumulator <= accumulator + unsigned("0" & data_in) - unsigned("0" & fifo_out) when (fifo_full = '1') else accumulator + unsigned("0" & data_in); + if (fifo_full = '1') then + accumulator <= accumulator + unsigned("0" & data_in) - unsigned("0" & fifo_out); + else + accumulator <= accumulator + unsigned("0" & data_in); + end if; end if; end if; end if; end process; - average <= std_logic_vector(((log2c(WINDOW_SIZE)-1 downto 0 => '0') & accumulator(DATA_WIDTH-1 downto log2c(WINDOW_SIZE))) + 1) - when (ENABLE_ROUNDING and accumulator(log2c(WINDOW_SIZE)-1) = '1') - else std_logic_vector(((log2c(WINDOW_SIZE)-1 downto 0 => '0') & accumulator(DATA_WIDTH-1 downto log2c(WINDOW_SIZE)))); + average_prc: process(all) + begin + if (ENABLE_ROUNDING and accumulator(log2c(WINDOW_SIZE)-1) = '1') then + average <= std_logic_vector(((log2c(WINDOW_SIZE)-1 downto 0 => '0') & accumulator(DATA_WIDTH-1 downto log2c(WINDOW_SIZE))) + 1); + else + average <= std_logic_vector(((log2c(WINDOW_SIZE)-1 downto 0 => '0') & accumulator(DATA_WIDTH-1 downto log2c(WINDOW_SIZE)))); + end if; + end process; end architecture;