-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from zeroasiccorp/ali/lumi
LUMI rtl and test changes
- Loading branch information
Showing
11 changed files
with
285 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ markers = [ | |
] | ||
testpaths = [ | ||
"tests", | ||
"umi/sumi/tests" | ||
"umi/sumi/tests", | ||
"umi/lumi/tests" | ||
] | ||
timeout = "300" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
import os | ||
import multiprocessing | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def test_wrapper(tmp_path): | ||
''' | ||
Fixture that automatically runs each test in a test-specific temporary | ||
directory to avoid clutter. | ||
''' | ||
try: | ||
multiprocessing.set_start_method('fork') | ||
except RuntimeError: | ||
pass | ||
|
||
topdir = os.getcwd() | ||
os.chdir(tmp_path) | ||
|
||
# Run the test. | ||
yield | ||
|
||
os.chdir(topdir) | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--seed", type=int, action="store", help="Provide a fixed seed") | ||
|
||
|
||
@pytest.fixture | ||
def random_seed(request): | ||
fixed_seed = request.config.getoption("--seed") | ||
if fixed_seed is not None: | ||
test_seed = fixed_seed | ||
else: | ||
test_seed = os.getpid() | ||
print(f'Random seed used: {test_seed}') | ||
yield test_seed | ||
print(f'Random seed used: {test_seed}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pytest | ||
from switchboard import SbDut | ||
from umi import lumi | ||
from fasteners import InterProcessLock | ||
|
||
|
||
def pytest_collection_modifyitems(items): | ||
for item in items: | ||
if "lumi_dut" in getattr(item, "fixturenames", ()): | ||
item.add_marker("switchboard") | ||
pass | ||
|
||
|
||
@pytest.fixture | ||
def build_dir(pytestconfig): | ||
return pytestconfig.cache.mkdir('lumi_build') | ||
|
||
|
||
@pytest.fixture | ||
def lumi_dut(build_dir, request): | ||
dut = SbDut('testbench', default_main=True, trace=False) | ||
|
||
dut.use(lumi) | ||
|
||
# Add testbench | ||
dut.input('lumi/testbench/testbench_lumi.sv', package='umi') | ||
|
||
# Verilator configuration | ||
dut.set('tool', 'verilator', 'task', 'compile', 'file', 'config', 'lumi/testbench/config.vlt', | ||
package='umi') | ||
|
||
# Build simulator | ||
dut.set('option', 'builddir', build_dir / lumi.__name__) | ||
with InterProcessLock(build_dir / f'{lumi.__name__}.lock'): | ||
# ensure build only happens once | ||
# https://github.com/pytest-dev/pytest-xdist/blob/v3.6.1/docs/how-to.rst#making-session-scoped-fixtures-execute-only-once | ||
dut.build(fast=True) | ||
|
||
yield dut | ||
|
||
dut.terminate() | ||
|
||
|
||
@pytest.fixture(params=("2d", "3d")) | ||
def chip_topo(request): | ||
return request.param |
Oops, something went wrong.