2017-02-08 1 views
0

간단한 카운터 구현을 테스트 할 때 GHDL 시뮬레이션은 시뮬레이션을 종료하지 않습니다. 내 의도는 주 프로세스에 의해 변경된 공유 변수를 사용하여 두 프로세스를 동시에 중지하는 것입니다. 그러나 주요 프로세스는 시계 프로세스를 멈추지 않는 것입니다.wait 문을 사용한 VHDL 시뮬레이션 중지

내 카운터 구현은 다음과 같습니다

entity dff is 
port(
    direction, reset, clk, load : in std_logic; 
    din : in std_logic_vector(3 downto 0); 
    dout : out std_logic_vector(3 downto 0)); 
end dff; 

architecture behav of dff is 
    signal temp : std_logic_vector(3 downto 0); 
begin 
    process(clk, reset) 
begin 
    if (reset='1') then 
     temp <= "0000"; 
     elsif rising_edge(clk) then 
      if (load='1') then 
       temp <= din; 
      else 
       if (direction='0') then 
        temp <= std_logic_vector(unsigned(temp) + 1); 
       else 
        temp <= std_logic_vector(unsigned(temp) - 1); 
       end if; 
      end if; 
     end if; 
     dout <= temp; 
    end process; 
end behav; 

그리고 내 테스트 벤치 : 나는 더이처럼 클럭 생성기를 코딩 할

architecture behav of test_tb is 
    component dff port(
     direction, reset, clk, load : in std_logic; 
     din : in std_logic_vector(3 downto 0); 
     dout : out std_logic_vector(3 downto 0)); 
    end component; 
    signal direction, reset, clk, load : std_logic := '1'; 
    signal din, dout : std_logic_vector(3 downto 0) := x"7"; 
    shared variable simend : boolean := false; 
begin 

    clkk : process 
    begin 
     if simend=false then 
      clk <= not clk after 50 ns; 
     else 
      wait; 
     end if; 
    end process clkk; 

    uut : dff port map(
     direction, reset, clk, load, din, dout); 

    stim : process 
    begin 
     reset <= '0'; 
     wait for 1 us; 
     load <= '0'; 
     wait for 2 us; 
     direction <= '0'; 
     wait for 2 us; 
     load <= '1'; 
     wait for 1 us; 
     reset <= '1'; 
     wait for 0.5 us; 

     simend := true; 
     wait; 
    end process stim; 
end behav; 
+0

최근 ghdl 버전에서는 [--assert-level = ] (http://ghdl.readthedocs.io/en/latest/Simulation_and_runtime.html?highlight=severity) 및 --ieee- asserts = 표준 패키지에서 경고를 차단하여 단언 문에서 SEVERITY_LEVEL HALT에 대해 말을 멈추게합니다. 또한 지연을 50 ns의 대기 시간에서 분리 할 수 ​​있습니다. clk <= clk가 아님; simend = true이면 기다립니다. end if; 프로세스 문은 자연스럽게 반복됩니다. – user1155120

+0

클럭 킬러의 오버 헤드를 피하고 대신 @scary_jeff가 제안한대로 std.env.stop을 사용하는 것이 좋습니다. –

답변

0

:

clkk : process 
begin 
    while simend=false loop 
     clk <= not clk; 
     wait for 50 ns; 
    end loop; 
    wait; 
end process clkk; 

실행할 수 있습니다 당신의 clkkwait 문을 실행하지 않고 프로세스. (clk <= not clk after 50 ns 줄은 대기하거나 차단하지 않습니다. <=비 차단 지정입니다.) 따라서 절대 멈추지 않을 무한 루프가 있습니다. this example on EDA Playground을 실행하면 시뮬레이션 시간이 절대로 진전되지 않으며 EDA 놀이터에서의 최대 런타임은 1 분이므로 1 분 후에 시간 초과됩니다.

또한 simend에 공유 변수를 사용하지 않는 것이 좋습니다. 대신, 신호를 사용하지 않는 이유는 무엇입니까? VHDL-2000 이후에는 공유 변수가 이어야하고 보호 유형이되어야하므로 VHDL-2000 이후에는 코드가 압축되지 않습니다. VHDL-93 컴파일 옵션을 설정하지 않으면 EDA 놀이터에서 경고가 발생하는 것을 볼 수 있습니다. VHDL-93 용으로 컴파일하면 stop (또는 finish) 절차를 사용할 수 없습니다.

1

당신이 할 수있는 VHDL2008 호환 시뮬레이터가있는 경우 시뮬레이션을 종료하는 다른 방법 : 당신이 다음 stop를 호출하여 시뮬레이션을 종료 할 수 있습니다

use std.env.stop; 

:

stop; 

이 나에게 보인다 시뮬레이터 반복 제한에 도달하게하는 클럭 전환의 부족을 기다리는 것보다 더 우아 할 수 있습니다.

+0

최근 ghdl에서, 그것은'--std = 08' 플래그로 컴파일하고 정교함을 의미합니다. –

1

@scary_jeff에 동의합니다. std.env.stop은 좋은 대답입니다. 난 그냥 한 곳에서 그것을 호출하고, 내 취향은 패키지 참조를 생략 할 수도 있고, 단지 그것을 호출하는 것입니다 :

당신이 이전 시뮬레이터 붙어있는 경우에
std.env.stop; 

, 당신이 사용할 수있는

report "Just Kidding. Test Done." severity failure ; 

OTOH 여러 프로세스간에 시뮬레이션 종료를 조정하고 시뮬레이션 실행에 감시견 타이머를 추가해야하는 경우 Osvvm.TbUtilPkg.WaitForBarrier 프로 시저를 고려할 수 있습니다. 아래 그림과 같이 사용됩니다. WaitForBarrier (TestDone, 5ms)에 대한 첫 번째 호출은 그 전에 TestDone이 발생하지 않았을 때 5ms 안에 깨어나고 그 시간에 시뮬레이션을 중지합니다.

signal TestDone : integer_barrier := 1 ; 

ControlProc : process 
begin 
    -- initialize test 
    SetAlertLogName("Uart1_Rx") ; 
    . . . 
    WaitForBarrier(TestDone, 5 ms) ; -- control process uses timeout 
    AlertIf(now >= 5 ms, "Test finished due to Time Out") ; 
    ReportAlerts ; 
    std.env.stop ; 
end process ControlProc ; 

CpuProc : process 
begin 
    InitDut(. . .)_; 
    Toggle(CpuReady) ; 
    -- run numerous Cpu test transactions 
    . . . 
    WaitForBarrier(TestDone) ; 
    wait ; 
end process CpuProc ; 

UartTxProc : process 
Begin 
    WaitForToggle(CpuReady) ; 
    -- run numerous Uart Transmit test transactions 
    . . . 
    WaitForBarrier(TestDone) ; 
    wait ; 
end process UartTxProc ; 
. . . 

당신은 모두 osvvm.org에서와 GitHub의에 OSVVM 라이브러리를 찾을 수 있습니다. 또한이 패키지를 다운로드 할 때 완전한 사용자 안내서가 있습니다.

관련 문제