2017-05-18 7 views
1

ISH에서 LFSR을 구현하기 위해 Vhdl 코드 & 테스트 벤치 코드를 작성합니다. ISE에서이 경로의 LFSR 코드를 선택합니다. 언어 템플릿 - VHDL - 합성 구축해 - 코딩 예 --- 카운터 --- LFSRVHDL-LFSR 구현

내 문제는 시뮬 (ISIM)에, 난 항상 out_lfsr을위한 'U'기호에 직면하고 있습니다. 도와 주시겠습니까?

VHDL 코드 :

library IEEE; 
     use IEEE.std_logic_1164.all; 
use IEEE.numeric_std.all; 
use IEEE.std_logic_unsigned.all; 



entity lfsr is 

port(rst,clk,clk_en:in std_logic; 
out_lfsr: inout std_logic_vector(31 downto 0); 
init_value:in std_logic_vector(31 downto 0) 
); 

end lfsr; 

architecture Behavioral of lfsr is 


begin 

process(clk) 
begin 
    if (clk'event and clk ='1') then 
     if (rst = '1') then 
     out_lfsr <= init_value; 
     elsif clk_en='1' then 
     out_lfsr(31 downto 1) <= out_lfsr(30 downto 0) ; 
     out_lfsr(0) <= not(out_lfsr(31) XOR out_lfsr(21) XOR out_lfsr(0)); 
     end if; 
    end if; 
end process; 


end Behavioral; 

테스트 벤치 :

LIBRARY ieee; 
USE ieee.std_logic_1164.ALL; 



ENTITY tb_lfsr IS 
END tb_lfsr; 

ARCHITECTURE behavior OF tb_lfsr IS 

    -- Component Declaration for the Unit Under Test (UUT) 

    COMPONENT lfsr 
    PORT(
     rst : IN std_logic; 
     clk : IN std_logic; 
     clk_en : IN std_logic; 
     out_lfsr : INOUT std_logic_vector(31 downto 0); 
     init_value : IN std_logic_vector(31 downto 0) 
     ); 
    END COMPONENT; 


    --Inputs 
    signal rst : std_logic := '0'; 
    signal clk : std_logic := '0'; 
    signal clk_en : std_logic := '1'; 
    signal init_value : std_logic_vector(31 downto 0) := (others => '1'); 

    --Outputs 
    signal out_lfsr : std_logic_vector(31 downto 0):=(others => '0'); 

    -- Clock period definitions 
    constant clk_period : time := 10 ns; 

BEGIN 

    -- Instantiate the Unit Under Test (UUT) 
    uut: lfsr PORT MAP (
      rst => rst, 
      clk => clk, 
      clk_en => clk_en, 
      out_lfsr => out_lfsr, 
      init_value => init_value 
     ); 

    -- Clock process definitions 
    clk_process :process 
    begin 
     clk <= '0'; 
     wait for clk_period/2; 
     clk <= '1'; 
     wait for clk_period/2; 
    end process; 



END; 

답변

0

당신은 그것을 작동하게 다른이 블록을 다시 설정해야합니다. 리셋시 입력 값을 출력으로로드합니다.

reset_p: process begin 
    rst <= '1'; 
    wait for 10 * clk_period; 
    rst <= '0'; 
    wait; 
end process; 

나는 또한 항상 합성 적절한 아니므로, 입출력 사용하지만, 당신이 out_lfsr 값을 저장 내부 신호를 사용하지 않는 더 나은 것 같아요.

entity lfsr is 

port(
    rst,clk,clk_en:in std_logic; 
    out_lfsr: out std_logic_vector(31 downto 0); 
    init_value: in std_logic_vector(31 downto 0) 
); 

end lfsr; 

architecture Behavioral of lfsr is 

signal s_out_lfsr : std_logic_vector(31 downto 0); 
begin 

process(clk) 
begin 
    if (clk'event and clk ='1') then 
     if (rst = '1') then 
     s_out_lfsr <= init_value; 
     elsif clk_en='1' then 
     s_out_lfsr(31 downto 1) <= s_out_lfsr(30 downto 0) ; 
     s_out_lfsr(0) <= not(s_out_lfsr(31) XOR s_out_lfsr(21) XOR s_out_lfsr(0)); 
     end if; 
    end if; 
end process; 

out_lfsr <= s_out_lfsr; 

end Behavioral; 

코드 예제에 코드가있는 것처럼 확실하지 않습니다.

+0

고맙습니다. 작동합니다. :-) –