Re: how is it with gtkwave and tracing interfaces?

David Belohrad <[email protected]> Sun, 31 Jan 2016 13:59:34 +0100
Newsgroups gmane.comp.python.myhdl
Message-ID <[email protected]>
ok, try this one. Do you see rc.ClkxC and rc.ResetxRN under i_dut in gtkwave? I don't

# really disgusting way how to link relative
import sys
sys.path.append('/home/belohrad/git/didt/MyHDL/rhea')

from myhdl import *
import unittest
from functools import wraps
from rhea.system.clock import *
from rhea.system.reset import *

class RC(object):
    def __init__(self):
        self.ClkxC = Clock(0, frequency=160e6)
        self.ResetxRN = Reset(0, active = 0, async=True)


def register(rc, DxD, DxE, QxD):
    @always_seq(rc.ClkxC.posedge, rc.ResetxRN)
    def ilogic():
        if DxE:
            QxD.next = DxD
    return ilogic,

_trace = False

# decorator to trace problematic function
def trace(func):
    func.trace = True
    return func

#decorator with main bench initialization
def myhdltest(func):
    @wraps(func)
    def wrapper(self):

        def testbench():
            @instance
            def clockGen():
                yield self.rc.ClkxC.gen()

            @instance
            def reset():
                yield self.rc.ResetxRN.pulse( (10,12,18) )

            @instance
            def stimulus():
                yield func(self)
                raise StopSimulation

            i_dut = self.dut(*self.args)
            return i_dut, stimulus, reset, clockGen

        #tracedec = getattr(wrapper, 'trace', None)  # True or None
        #tracesel = getattr(self, 'trace', None)  # True or None
        #tracecmd = _trace  # True or False
        #trace = (x for x in (tracedec, tracesel, tracecmd) if x is not None).next()

        g = traceSignals(testbench) #if trace else self.dut(*self.args)
        Simulation(g).run()

    return wrapper


class testRegister(unittest.TestCase):

    def setUp(self):
        # prepare instance of the item

        self.DxD, self.QxD = [Signal(intbv(0)[8:]) for x in xrange(2)]
        self.DxE = Signal(bool(0))
        self.rc = RC()

        # test instance
        self.args = (self.rc, self.DxD, self.DxE, self.QxD)
        self.dut=register



    @trace
    @myhdltest
    def testRegister(self):

        # stimulus
        self.rc.ClkxC.next = 0
        self.DxD.next = 0
        self.DxE.next = 1
        yield join(self.rc.ClkxC.posedge, self.rc.ResetxRN.posedge)

        # reset stage finished
        self.DxD.next = 1
        for i in range(10):
            yield (self.rc.ClkxC.posedge)
            self.DxD.next = 0
        yield(delay(150))



unittest.main()


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140