2020-04-01 20:38:14 -06:00
|
|
|
import unittest
|
tests: move out of the main package.
Compared to tests in the repository root, tests in the package have
many downsides:
* Unless explicitly excluded in find_packages(), tests and their
support code effectively become a part of public API.
This, unfortunately, happened with FHDLTestCase, which was never
intended for downstream use.
* Even if explicitly excluded from the setuptools package, using
an editable install, or setting PYTHONPATH still allows accessing
the tests.
* Having a sub-package that is present in the source tree but not
exported (or, worse, exported only sometimes) is confusing.
* The name `nmigen.test` cannot be used for anything else, such as
testing utilities that *are* intended for downstream use.
2020-08-26 18:33:31 -06:00
|
|
|
|
|
|
|
from nmigen import Signal, Module, Elaboratable
|
|
|
|
|
2020-04-01 20:38:14 -06:00
|
|
|
from .support import SimCase
|
|
|
|
|
|
|
|
|
|
|
|
class RunSimulation(SimCase, unittest.TestCase):
|
|
|
|
""" test for https://github.com/nmigen/nmigen/issues/344 """
|
|
|
|
|
|
|
|
class TestBench(Elaboratable):
|
|
|
|
def __init__(self):
|
|
|
|
self.a = Signal()
|
|
|
|
|
|
|
|
def elaborate(self, platform):
|
|
|
|
m = Module()
|
|
|
|
m.d.sync += self.a.eq(~self.a)
|
|
|
|
return m
|
|
|
|
|
|
|
|
def test_run_simulation(self):
|
|
|
|
def gen():
|
|
|
|
yield
|
|
|
|
for i in range(10):
|
|
|
|
yield
|
|
|
|
a = (yield self.tb.a)
|
|
|
|
self.assertEqual(a, i % 2)
|
|
|
|
|
|
|
|
self.run_with(gen())
|