Skip to content

Commit

Permalink
Added support for parallel threads with vopt
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsAsplund committed Sep 4, 2024
1 parent b1faae5 commit 1ce6bba
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 62 deletions.
21 changes: 15 additions & 6 deletions examples/vhdl/three_step_flow/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@
#
# Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

from argparse import Namespace
from pathlib import Path
from vunit import VUnit
from vunit import VUnit, VUnitCLI
from os import environ

cli = VUnitCLI()

environ["VUNIT_SIMULATOR"] = "modelsim"

vu = VUnit.from_argv()
vu.add_vhdl_builtins()

lib = vu.add_library("lib")
lib.add_source_files(Path(__file__).parent / "*.vhd")
lib1 = vu.add_library("lib1")
lib1.add_source_files(Path(__file__).parent / "sub_module" / "*.vhd")

lib2 = vu.add_library("lib2")
lib2.add_source_files(Path(__file__).parent / "*.vhd")

tb = lib.test_bench("tb_example")
test = tb.test("test 2")
tb = lib2.test_bench("tb_example")
test = tb.test("test")

for value in range(3):
for value in range(5):
test.add_config(name=f"{value}", generics=dict(value=value))

vu.set_sim_option("modelsim.three_step_flow", True)
Expand Down
35 changes: 35 additions & 0 deletions examples/vhdl/three_step_flow/sub_module/tb_a.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
-- You can obtain one at http://mozilla.org/MPL/2.0/.
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

library vunit_lib;
context vunit_lib.vunit_context;

entity tb_a is
generic (
runner_cfg : string);
end entity;

architecture tb of tb_a is
begin
main : process
function recurse(value : integer) return integer is
begin
if value <= 0 then
return 0;
elsif value mod 2 = 0 then
return 1 + recurse(value - 1);
else
return recurse(value - 1);
end if;
end;
begin
test_runner_setup(runner, runner_cfg);

info("Running tb_a: " & to_string(recurse(17)));

test_runner_cleanup(runner);
end process;
end architecture;
35 changes: 35 additions & 0 deletions examples/vhdl/three_step_flow/tb_b.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
-- You can obtain one at http://mozilla.org/MPL/2.0/.
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

library vunit_lib;
context vunit_lib.vunit_context;

entity tb_b is
generic (
runner_cfg : string);
end entity;

architecture tb of tb_b is
begin
main : process
function recurse(value : integer) return integer is
begin
if value <= 0 then
return 0;
elsif value mod 2 = 0 then
return 1 + recurse(value - 1);
else
return recurse(value - 1);
end if;
end;
begin
test_runner_setup(runner, runner_cfg);

info("Running tb_b: " & to_string(recurse(17)));

test_runner_cleanup(runner);
end process;
end architecture;
12 changes: 10 additions & 2 deletions examples/vhdl/three_step_flow/tb_example.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ end entity;
architecture tb of tb_example is
begin
main : process
function recurse(value : integer) return integer is
begin
if value <= 0 then
return 0;
else
return 1 + recurse(value - 1);
end if;
end;
begin
test_runner_setup(runner, runner_cfg);

while test_suite loop
if run("test 1") then
elsif run("test 2") then
if run("test") then
end if;

info("Running " & running_test_case & " with generic value = " & to_string(value));
info("Recurse = " & to_string(recurse(value)));
end loop;

test_runner_cleanup(runner);
Expand Down
2 changes: 1 addition & 1 deletion vunit/persistent_tcl_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def read_var(self, varname):
return consumer.var

def read_bool(self, varname):
result = self.read_var(varname)
result = self.read_var(varname).lower()
assert result in ("true", "false")
return result == "true"

Expand Down
Loading

0 comments on commit 1ce6bba

Please sign in to comment.