Source code for hwtLib.examples.simpleHwModuleWithNonDirectIntConncetion
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from hwt.constants import Time
from hwt.hwIOs.std import HwIOSignal
from hwt.hwModule import HwModule
from hwt.pyUtils.typingFuture import override
from hwt.simulator.simTestCase import SimTestCase
[docs]
class SimpleHwModuleWithNonDirectIntConncetion(HwModule):
"""
Example of fact that interfaces does not have to be only extern
the can be used even for connection inside unit
.. hwt-autodoc::
"""
@override
def hwDeclr(self):
self.a = HwIOSignal()
self.c = HwIOSignal()._m()
@override
def hwImpl(self):
self.b = HwIOSignal()
self.b(self.a)
self.c(self.b)
[docs]
class SimpleModuleWithNonDirectIntConncetionTC(SimTestCase):
[docs]
@classmethod
@override
def setUpClass(cls):
cls.dut = SimpleHwModuleWithNonDirectIntConncetion()
cls.compileSim(cls.dut)
[docs]
def test_passData(self):
d = [0, 1, 0, 1, 0]
dut = self.dut
dut.a._ag.data.extend(d)
self.runSim(50 * Time.ns)
self.assertValSequenceEqual(dut.c._ag.data, d)
if __name__ == "__main__":
import unittest
testLoader = unittest.TestLoader()
# suite = unittest.TestSuite([SimpleModuleWithNonDirectIntConncetionTC("test_passData")])
suite = testLoader.loadTestsFromTestCase(SimpleModuleWithNonDirectIntConncetionTC)
runner = unittest.TextTestRunner(verbosity=3)
runner.run(suite)
from hwt.synth import to_rtl_str
print(to_rtl_str(SimpleHwModuleWithNonDirectIntConncetion()))