Arrays VHDL初始化std_逻辑_向量的通用数组
我想在VHDL中为卷积实现一个环形缓冲区,并使其通用化。我的问题是如何在不引入更多信号或变量的情况下初始化内部数据 通常我可以通过Arrays VHDL初始化std_逻辑_向量的通用数组,arrays,generics,initialization,vhdl,Arrays,Generics,Initialization,Vhdl,我想在VHDL中为卷积实现一个环形缓冲区,并使其通用化。我的问题是如何在不引入更多信号或变量的情况下初始化内部数据 通常我可以通过 signal initialized_vector : std_logic_vector(15 downto 0) := (others => '0'); 但我不知道默认情况下如何在数组上执行此操作 这是我的密码: entity convolution_ringbuffer is generic ( BitDepth_signal :
signal initialized_vector : std_logic_vector(15 downto 0) := (others => '0');
但我不知道默认情况下如何在数组上执行此操作
这是我的密码:
entity convolution_ringbuffer is
generic (
BitDepth_signal : integer := 24;
BufferSize : integer := 10
);
port (
data_in : in std_logic_vector(BitDepth_signal-1 downto 0);
sclk : in std_logic;
enable : in std_logic;
data_out : out std_logic_vector(BitDepth_signal-1 downto 0)
);
end convolution_ringbuffer;
architecture behavioral of convolution_ringbuffer is
type internal_data is array(0 to BufferSize-1) of std_logic_vector(BitDepth_signal-1 downto 0);
signal data_internal : internal_data;
begin
process ( sclk )
variable current_position : integer range 0 to (BufferSize-1) := 0;
begin
if ( rising_edge(sclk) and enable = '1' ) then
data_internal(current_position) <= std_logic_vector(data_in);
if ( current_position < BufferSize-1 ) then
current_position := current_position + 1;
else
current_position := 0;
end if;
end if;
if ( falling_edge(sclk) ) then
data_out <= std_logic_vector(data_internal(current_position));
end if;
end process;
end behavioral;
实体卷积\u ringbuffer为
一般的(
比特深度_信号:整数=24;
缓冲区大小:整数:=10
);
港口(
数据输入:标准逻辑向量(位深度信号-1向下至0);
sclk:标准逻辑中;
启用:在std_逻辑中;
数据输出:输出标准逻辑向量(位深度信号-1向下至0)
);
端卷积缓冲区;
卷积环缓冲区的结构是
类型内部_数据是标准_逻辑_向量(位深度_信号-1向下至0)的数组(0至缓冲大小-1);
信号数据\内部:内部\数据;
开始
过程(sclk)
可变当前位置:整数范围0到(BufferSize-1):=0;
开始
如果(上升沿(sclk)和启用='1'),则
数据内部(当前位置)您可以执行与标准逻辑向量几乎相同的操作。你只需要考虑你还有一个维度:
signal data_internal : internal_data := (others=>(others=>'0'));
如果要存储更复杂的初始化数据,可以使用初始化函数:
function init return internal_data is
begin
--do something (e.g. read data from a file, perform some initialization calculation, ...)
end function init;
signal data_internal : internal_data := init;