@@ -0,0 +1,2555 @@
+#!/usr/bin/env python3%0A# -*- coding: utf-8 -*-%0A%0A%0Afrom hwt.hdl.constants import Time%0Afrom hwt.interfaces.std import VectSignal%0Afrom hwt.interfaces.utils import addClkRstn%0Afrom hwt.simulator.simTestCase import SimTestCase%0Afrom hwt.synthesizer.param import Param%0Afrom hwt.synthesizer.unit import Unit%0Afrom hwt.synthesizer.utils import toRtl%0Afrom hwtHls.hls import Hls%0Afrom hwtHls.platform.virtual import VirtualHlsPlatform%0A%0A%0Aclass HlsExprTree3_example(Unit):%0A    def _config(self):%0A        self.CLK_FREQ = Param(int(3e8))%0A%0A    def _declr(self):%0A        addClkRstn(self)%0A        self.a = VectSignal(32, signed=False)%0A        self.b = VectSignal(32, signed=False)%0A        self.c = VectSignal(32, signed=False)%0A        self.d = VectSignal(32, signed=False)%0A        %0A        self.x = VectSignal(32, signed=False)%0A        self.y = VectSignal(32, signed=False)%0A        self.z = VectSignal(32, signed=False)%0A        self.w = VectSignal(32, signed=False)%0A        %0A        self.f1 = VectSignal(64, signed=False)%0A        self.f2 = VectSignal(64, signed=False)%0A        self.f3 = VectSignal(64, signed=False)%0A%0A    def _impl(self):%0A        with Hls(self, freq=self.CLK_FREQ) as hls:%0A%0A            a, b, c, d = self.a, self.b, self.c, self.d%0A            x, y, z, w = self.x, self.y, self.z, self.w%0A            %0A            r, wr = hls.read, hls.write%0A            f1 = (r(a) + r(b) + r(c)) * r(d)%0A            xy = r(x) + r(y)%0A            f2 = xy * r(z)%0A            f3 = xy * r(w)%0A%0A            wr(f1, self.f1)%0A            wr(f2, self.f2)%0A            wr(f3, self.f3)%0A%0A%0Aclass HlsExprTree3_example_TC(SimTestCase):%0A    def test_simple(self):%0A        u = HlsExprTree3_example()%0A        self.prepareUnit(u, targetPlatform=VirtualHlsPlatform())%0A        u.a._ag.data.append(3)%0A        u.b._ag.data.append(4)%0A        u.c._ag.data.append(5)%0A        u.d._ag.data.append(6)%0A        u.x._ag.data.append(7)%0A        u.y._ag.data.append(8)%0A        u.z._ag.data.append(9)%0A        u.w._ag.data.append(10)        %0A%0A        self.doSim(40 * Time.ns)%0A%0A        self.assertValEqual(u.f1._ag.data%5B-1%5D, (3 + 4 + 5) * 6)%0A        self.assertValEqual(u.f2._ag.data%5B-1%5D, (7 + 8) * 9)%0A        self.assertValEqual(u.f3._ag.data%5B-1%5D, (7 + 8) * 10)%0A%0A%0Aif __name__ == %22__main__%22:%0A    import unittest%0A    u = HlsExprTree3_example()%0A    print(toRtl(u, targetPlatform=VirtualHlsPlatform()))%0A%0A    suite = unittest.TestSuite()%0A    # suite.addTest(FrameTmplTC('test_frameHeader'))%0A    suite.addTest(unittest.makeSuite(HlsExprTree3_example_TC))%0A    runner = unittest.TextTestRunner(verbosity=3)%0A    runner.run(suite)%0A

add new example + test