From 5f5fdd8ea8827e55cce380a1fffb309f9e02b758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Thu, 18 May 2023 18:32:45 +0200 Subject: [PATCH] fix: make ring_buffer synthetizable by making co_read interval constant (dependent only on one variable instead of two) --- src/data_link/ring_buffer.vhd | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/data_link/ring_buffer.vhd b/src/data_link/ring_buffer.vhd index c0cc7655c9acb243884ab8a0adb926bac15accfc..5e69be97b22d5763dfd21e27a6ded600b1375086 100644 --- a/src/data_link/ring_buffer.vhd +++ b/src/data_link/ring_buffer.vhd @@ -27,6 +27,7 @@ entity ring_buffer is end entity ring_buffer; architecture a1 of ring_buffer is + constant BIT_BUFFER_SIZE : integer := CHARACTER_SIZE*BUFFER_SIZE-1; signal buff : std_logic_vector(CHARACTER_SIZE*BUFFER_SIZE-1 downto 0); signal buff_triple : std_logic_vector(3*CHARACTER_SIZE*BUFFER_SIZE-1 downto 0); signal next_read : std_logic_vector(CHARACTER_SIZE*BUFFER_SIZE-1 downto 0); @@ -41,8 +42,8 @@ begin -- architecture a1 -- inputs : ci_clk, ci_reset -- outputs: read_position, write_position, buff read: process (ci_clk, ci_reset) is - variable read_from_position : integer; - variable read_to_position : integer; + variable read_from_position : integer range 0 to BIT_BUFFER_SIZE-1; + variable read_to_position : integer range 0 to BIT_BUFFER_SIZE-1; begin -- process read if ci_reset = '0' then -- asynchronous reset (active low) buff <= (others => '0'); @@ -58,10 +59,11 @@ begin -- architecture a1 read_from_position := (CHARACTER_SIZE*BUFFER_SIZE - 1 - (read_position + ci_adjust_position)*CHARACTER_SIZE) mod (CHARACTER_SIZE*BUFFER_SIZE); read_to_position := (CHARACTER_SIZE*BUFFER_SIZE - (read_position + ci_adjust_position + READ_SIZE)*CHARACTER_SIZE) mod (CHARACTER_SIZE*BUFFER_SIZE); - if read_from_position >= read_to_position then - co_read <= buff(read_from_position downto read_to_position); + if read_from_position >= read_to_position then + co_read(CHARACTER_SIZE*READ_SIZE - 1 downto 0) <= buff(read_from_position downto read_from_position + 1 - READ_SIZE*CHARACTER_SIZE); else - co_read <= buff(read_from_position downto 0) & buff(CHARACTER_SIZE*BUFFER_SIZE - 1 downto read_to_position); + co_read(CHARACTER_SIZE*READ_SIZE - 1 downto CHARACTER_SIZE*READ_SIZE - 1 - read_from_position) <= buff(read_from_position downto 0); + co_read(CHARACTER_SIZE*BUFFER_SIZE - 1 - read_to_position downto 0) <= buff(CHARACTER_SIZE*BUFFER_SIZE - 1 downto read_to_position); end if; else reg_size <= reg_size + 1;