2017-11-22 5 views
0

VHDL에 회선 내용을위한 링 버퍼를 구현하여 일반화하고 싶습니다. 내 문제는 추가 신호 또는 변수를 도입하지 않고 내부 데이터를 초기화하는 방법입니다.VHDL std_logic_vector의 일반 배열을 초기화하십시오.

보통 나는

signal initialized_vector : std_logic_vector(15 downto 0) := (others => '0'); 

하여 std_logic_vector을 초기화하기 수 그러나 나는 어떻게 기본적으로 배열에 그렇게하는 단서가 없다. 당신은 std_logic_vector 경우와 거의 동일 할 수

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; 

답변

0

:

여기 내 코드입니다. 당신이 저장하는 더 복잡한 초기화 데이터가있는 경우

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; 
+0

덕분에 많은 매력처럼 작동 – ThomasM

관련 문제