Skip to content

Commit 4db4fc2

Browse files
committed
template: clean up template project.
1 parent db7ca3b commit 4db4fc2

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

template/.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
- uses: kivikakk/niar/setup-action@main
2020

2121
- name: Run tests
22-
run: pytest -n auto tests
22+
run: pytest

template/cxxrtl/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int main(int argc, char **argv) {
4545
// ledr should be low or high according to 'expected', where each element
4646
// represents 1/4th of a second. ledg should always be high.
4747
//
48-
// This mirrors TestTop in Python.
48+
// This mirrors test_blinks in Python.
4949
int rc = 0;
5050
bool done = false;
5151

template/pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ authors = [
88
dependencies = [
99
"amaranth >= 0.5, < 0.7",
1010
"amaranth-boards",
11-
"niar >= 0.1",
11+
"niar >= 0.1.1",
1212
]
1313
requires-python = ">=3.8"
1414
license = {text = "BSD-2-Clause"}
1515

1616
[build-system]
1717
requires = ["pdm-backend"]
1818
build-backend = "pdm.backend"
19+
20+
[tool.pytest.ini_options]
21+
addopts = ["-n", "auto"]
22+
testpaths = ["tests"]

template/tests/test_top.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import unittest
2-
31
from amaranth.hdl import Fragment
42
from amaranth.sim import Simulator
5-
63
from newproject.rtl import Blinker
74

85

@@ -11,20 +8,17 @@ class test:
118
default_clk_frequency = 8.0
129

1310

14-
class TestBlinker(unittest.TestCase):
15-
platform = test()
16-
17-
def test_blinks(self):
18-
dut = Blinker()
11+
def test_blinks():
12+
dut = Blinker()
1913

20-
async def testbench(ctx):
21-
for ledr in [0, 1, 1, 0, 0, 1, 1, 0]:
22-
for _ in range(2):
23-
assert ctx.get(dut.ledr) == ledr
24-
assert ctx.get(dut.ledg)
25-
await ctx.tick()
14+
async def testbench(ctx):
15+
for ledr in [0, 1, 1, 0, 0, 1, 1, 0]:
16+
for _ in range(2):
17+
assert ctx.get(dut.ledr) == ledr
18+
assert ctx.get(dut.ledg)
19+
await ctx.tick()
2620

27-
sim = Simulator(Fragment.get(dut, self.platform))
28-
sim.add_clock(1 / 8)
29-
sim.add_testbench(testbench)
30-
sim.run()
21+
sim = Simulator(Fragment.get(dut, test()))
22+
sim.add_clock(1 / 8)
23+
sim.add_testbench(testbench)
24+
sim.run()

0 commit comments

Comments
 (0)