mirror of
https://git.sr.ht/~kivikakk/niar
synced 2024-12-22 20:02:23 +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
|
||||
|
||||
- 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
|
||||
// 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;
|
||||
bool done = false;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ authors = [
|
|||
dependencies = [
|
||||
"amaranth >= 0.5, < 0.7",
|
||||
"amaranth-boards",
|
||||
"niar >= 0.1",
|
||||
"niar >= 0.1.1",
|
||||
]
|
||||
requires-python = ">=3.8"
|
||||
license = {text = "BSD-2-Clause"}
|
||||
|
@ -16,3 +16,7 @@ license = {text = "BSD-2-Clause"}
|
|||
[build-system]
|
||||
requires = ["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.sim import Simulator
|
||||
|
||||
from newproject.rtl import Blinker
|
||||
|
||||
|
||||
|
@ -11,20 +8,17 @@ class test:
|
|||
default_clk_frequency = 8.0
|
||||
|
||||
|
||||
class TestBlinker(unittest.TestCase):
|
||||
platform = test()
|
||||
def test_blinks():
|
||||
dut = Blinker()
|
||||
|
||||
def test_blinks(self):
|
||||
dut = Blinker()
|
||||
async def testbench(ctx):
|
||||
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):
|
||||
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()
|
||||
|
||||
sim = Simulator(Fragment.get(dut, self.platform))
|
||||
sim.add_clock(1 / 8)
|
||||
sim.add_testbench(testbench)
|
||||
sim.run()
|
||||
sim = Simulator(Fragment.get(dut, test()))
|
||||
sim.add_clock(1 / 8)
|
||||
sim.add_testbench(testbench)
|
||||
sim.run()
|
||||
|
|
Loading…
Reference in a new issue