mirror of
https://git.sr.ht/~kivikakk/niar
synced 2024-12-22 19:12:24 +00:00
template: clean up template project.
This commit is contained in:
parent
db7ca3b5d2
commit
4db4fc2509
2
template/.github/workflows/unit-tests.yml
vendored
2
template/.github/workflows/unit-tests.yml
vendored
|
@ -19,4 +19,4 @@ jobs:
|
||||||
- uses: kivikakk/niar/setup-action@main
|
- uses: kivikakk/niar/setup-action@main
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pytest -n auto tests
|
run: pytest
|
||||||
|
|
|
@ -45,7 +45,7 @@ int main(int argc, char **argv) {
|
||||||
// ledr should be low or high according to 'expected', where each element
|
// ledr should be low or high according to 'expected', where each element
|
||||||
// represents 1/4th of a second. ledg should always be high.
|
// represents 1/4th of a second. ledg should always be high.
|
||||||
//
|
//
|
||||||
// This mirrors TestTop in Python.
|
// This mirrors test_blinks in Python.
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ authors = [
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"amaranth >= 0.5, < 0.7",
|
"amaranth >= 0.5, < 0.7",
|
||||||
"amaranth-boards",
|
"amaranth-boards",
|
||||||
"niar >= 0.1",
|
"niar >= 0.1.1",
|
||||||
]
|
]
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
license = {text = "BSD-2-Clause"}
|
license = {text = "BSD-2-Clause"}
|
||||||
|
@ -16,3 +16,7 @@ license = {text = "BSD-2-Clause"}
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["pdm-backend"]
|
requires = ["pdm-backend"]
|
||||||
build-backend = "pdm.backend"
|
build-backend = "pdm.backend"
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
addopts = ["-n", "auto"]
|
||||||
|
testpaths = ["tests"]
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import unittest
|
|
||||||
|
|
||||||
from amaranth.hdl import Fragment
|
from amaranth.hdl import Fragment
|
||||||
from amaranth.sim import Simulator
|
from amaranth.sim import Simulator
|
||||||
|
|
||||||
from newproject.rtl import Blinker
|
from newproject.rtl import Blinker
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,20 +8,17 @@ class test:
|
||||||
default_clk_frequency = 8.0
|
default_clk_frequency = 8.0
|
||||||
|
|
||||||
|
|
||||||
class TestBlinker(unittest.TestCase):
|
def test_blinks():
|
||||||
platform = test()
|
dut = Blinker()
|
||||||
|
|
||||||
def test_blinks(self):
|
async def testbench(ctx):
|
||||||
dut = Blinker()
|
for ledr in [0, 1, 1, 0, 0, 1, 1, 0]:
|
||||||
|
for _ in range(2):
|
||||||
|
assert ctx.get(dut.ledr) == ledr
|
||||||
|
assert ctx.get(dut.ledg)
|
||||||
|
await ctx.tick()
|
||||||
|
|
||||||
async def testbench(ctx):
|
sim = Simulator(Fragment.get(dut, test()))
|
||||||
for ledr in [0, 1, 1, 0, 0, 1, 1, 0]:
|
sim.add_clock(1 / 8)
|
||||||
for _ in range(2):
|
sim.add_testbench(testbench)
|
||||||
assert ctx.get(dut.ledr) == ledr
|
sim.run()
|
||||||
assert ctx.get(dut.ledg)
|
|
||||||
await ctx.tick()
|
|
||||||
|
|
||||||
sim = Simulator(Fragment.get(dut, self.platform))
|
|
||||||
sim.add_clock(1 / 8)
|
|
||||||
sim.add_testbench(testbench)
|
|
||||||
sim.run()
|
|
||||||
|
|
Loading…
Reference in a new issue