Skip to content

Commit

Permalink
Remove phase from runner signal.
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsAsplund committed Jul 29, 2018
1 parent 98eb352 commit 1625961
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 42 deletions.
23 changes: 16 additions & 7 deletions vunit/vhdl/run/src/run.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ use work.core_pkg;
use std.textio.all;

package body run_pkg is
procedure notify(signal runner : inout runner_sync_t) is
begin
if runner.event /= runner_event then
runner.event <= runner_event;
wait until runner.event = runner_event;
runner.event <= idle_runner;
end if;
end procedure notify;

procedure test_runner_setup (
signal runner : inout runner_sync_t;
constant runner_cfg : in string := runner_cfg_default) is
Expand Down Expand Up @@ -48,7 +57,7 @@ package body run_pkg is
end if;

set_phase(runner_state, test_runner_setup);
runner.phase <= test_runner_setup;
notify(runner);
runner.exit_without_errors <= false;
wait for 0 ns;
trace(runner_trace_logger, "Entering test runner setup phase.");
Expand Down Expand Up @@ -84,7 +93,7 @@ package body run_pkg is
end if;
exit_gate(runner);
set_phase(runner_state, test_suite_setup);
runner.phase <= test_suite_setup;
notify(runner);
wait for 0 ns;
trace(runner_trace_logger, "Entering test suite setup phase.");
entry_gate(runner);
Expand All @@ -100,13 +109,13 @@ package body run_pkg is
failure_if(runner_trace_logger, external_failure, "External failure.");

set_phase(runner_state, test_runner_cleanup);
runner.phase <= test_runner_cleanup;
notify(runner);
wait for 0 ns;
trace(runner_trace_logger, "Entering test runner cleanup phase.");
entry_gate(runner);
exit_gate(runner);
set_phase(runner_state, test_runner_exit);
runner.phase <= test_runner_exit;
notify(runner);
wait for 0 ns;
trace(runner_trace_logger, "Entering test runner exit phase.");

Expand Down Expand Up @@ -383,9 +392,9 @@ package body run_pkg is
constant file_name : in string := "") is
begin
-- @TODO me
if runner.phase /= phase then
if get_phase(runner_state) /= phase then
log(runner_trace_logger, "Waiting for phase = " & replace(runner_phase_t'image(phase), "_", " ") & ".", trace, line_num, file_name);
wait until runner.phase = phase;
wait on runner until get_phase(runner_state) = phase;
log(runner_trace_logger, "Waking up. Phase is " & replace(runner_phase_t'image(phase), "_", " ") & ".", trace, line_num, file_name);
end if;
end;
Expand All @@ -397,7 +406,7 @@ package body run_pkg is
trace(runner_trace_logger, "Halting on " & replace(runner_phase_t'image(get_phase(runner_state)), "_", " ") & " phase entry gate.");
wait on runner.locks until not runner.locks(get_phase(runner_state)).entry_is_locked for max_locked_time;
end if;
runner.phase <= get_phase(runner_state);
notify(runner);
wait for 0 ns;
trace(runner_trace_logger, "Passed " & replace(runner_phase_t'image(get_phase(runner_state)), "_", " ") & " phase entry gate.");
end procedure entry_gate;
Expand Down
4 changes: 3 additions & 1 deletion vunit/vhdl/run/src/run_api.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ library ieee;
use ieee.std_logic_1164.all;

package run_pkg is
signal runner : runner_sync_t := (phase => test_runner_entry,
signal runner : runner_sync_t := (event => idle_runner,
locks => ((false, false),
(false, false),
(false, false),
Expand All @@ -28,6 +28,8 @@ package run_pkg is
constant runner_trace_logger : logger_t := get_logger("runner");
constant runner_state : runner_t := new_runner;

procedure notify(signal runner : inout runner_sync_t);

procedure test_runner_setup (
signal runner : inout runner_sync_t;
constant runner_cfg : in string := runner_cfg_default);
Expand Down
36 changes: 7 additions & 29 deletions vunit/vhdl/run/src/run_types.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ package run_types_pkg is
constant runner_cfg_default : string := "enabled_test_cases : __all__, output path : , active python runner : false";
subtype test_cases_t is string;

type runner_phase_unresolved_t is (test_runner_entry, test_runner_setup, test_suite_setup, test_case_setup, test_case, test_case_cleanup, test_suite_cleanup, test_runner_cleanup, test_runner_exit, multiple_drivers);
type runner_phase_unresolved_array_t is array (integer range <>) of runner_phase_unresolved_t;
function resolve_runner_phase (
constant values : runner_phase_unresolved_array_t)
return runner_phase_unresolved_t;
subtype runner_phase_t is resolve_runner_phase runner_phase_unresolved_t;
type runner_phase_t is (test_runner_entry, test_runner_setup, test_suite_setup, test_case_setup,
test_case, test_case_cleanup, test_suite_cleanup, test_runner_cleanup,
test_runner_exit, multiple_drivers);

type phase_locks_unresolved_t is record
entry_is_locked : boolean;
Expand All @@ -48,36 +45,17 @@ package run_types_pkg is
return boolean;
subtype runner_flag_t is resolve_runner_flag boolean;

constant runner_event : std_logic := '1';
constant idle_runner : std_logic := 'Z';

type runner_sync_t is record
phase : runner_phase_t;
event : std_logic;
locks : phase_locks_array_t(test_runner_setup to test_runner_cleanup);
exit_without_errors : runner_flag_t;
end record runner_sync_t;
end package;

package body run_types_pkg is
function resolve_runner_phase (
constant values : runner_phase_unresolved_array_t)
return runner_phase_unresolved_t is
variable n_set_values : natural := 0;
variable result : runner_phase_unresolved_t := test_runner_entry;
begin
for i in values'range loop
if values(i) = test_runner_exit then
return test_runner_exit;
elsif values(i) /= test_runner_entry then
result := values(i);
n_set_values := n_set_values + 1;
end if;
end loop;

if n_set_values > 1 then
result := multiple_drivers;
end if;

return result;
end;

function resolve_phase_locks (
constant values : phase_locks_unresolved_array_t)
return phase_locks_unresolved_t is
Expand Down
10 changes: 5 additions & 5 deletions vunit/vhdl/run/test/run_tests.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ begin
begin
wait until start_test_process;
t_start := now;
if runner.phase /= test_suite_setup then
wait until runner.phase = test_suite_setup for 20 ns;
if get_phase /= test_suite_setup then
wait on runner until get_phase = test_suite_setup for 20 ns;
end if;
check(now - t_start = 17 ns, "Expected wait on test_suite_setup phase to be 17 ns.");
t_start := now;
if runner.phase /= test_case_setup then
wait until runner.phase = test_case_setup for 20 ns;
if get_phase /= test_case_setup then
wait on runner until get_phase = test_case_setup for 20 ns;
end if;
check(now - t_start = 9 ns, "Expected wait on test_case_setup phase to be 9 ns.");
test_process_completed <= true;
Expand Down Expand Up @@ -149,7 +149,7 @@ begin
procedure test_case_setup is
begin
runner_init(runner_state);
runner.phase <= get_phase(runner_state);
notify(runner);
runner.exit_without_errors <= false;
end;

Expand Down

0 comments on commit 1625961

Please sign in to comment.