def __init__(self, dt, **kwargs): super().__init__() self.reason = cons.cbReadWriteSynch self.time = pyvpi.Time(cons.vpiSimTime) self.time.low = int(dt % 2**32) self.time.high = int(dt // 2**32) for name, val in kwargs.items(): setattr(self, name, val)
def __init__(self): super().__init__() self.name = 'sync' self.reason = cons.cbReadWriteSynch self.time = pyvpi.Time(cons.vpiSimTime) self.time.low = 0 self.time.high = 0 self.callback = self.__class__.func
def __init__(self, dt, **kwargs): super().__init__() self.reason = cons.cbAfterDelay self.time = pyvpi.Time(cons.vpiSimTime) self.dxt = dt / 10**(Simtime.unit) pyvpi.printf("dxt is %f \n" % self.dxt) self.time.low = int(self.dxt % 2**32) self.time.high = int(self.dxt // 2**32) for name, val in kwargs.items(): setattr(self, name, val)
def create_cbdata(self): cbdata = pyvpi.CbData() cbdata.reason = cons.cbReadWriteSynch cbdata.time = pyvpi.Time(cons.vpiSimTime) cbdata.time.low = 0 cbdata.time.high = 0 setAbsTime(cbdata, self.t, self.unit) cbdata.callback = TimerFunc cbdata.wait_ev = Wait_Event(Simtime.value) return cbdata
def test(): """ c = a+b; """ handle_a = pyvpi.handleByName("top.a") val_a = pyvpi.Value(cons.vpiIntVal) val_a.value = 5 pyvpi.putValue(handle_a, val_a) time = pyvpi.Time() pyvpi.getTime(time) print('py: hello world at %d'%time.time)
def __init__(self, t=0, unit=None): super().__init__() self.t = t self.unit = unit if t == 0 or unit is None: self.name = "Timer {}".format(self.t) else: self.name = "Timer {} {}".format(self.t, self.unit) self.reason = cons.cbAfterDelay self.time = pyvpi.Time(cons.vpiSimTime) self.time.low = 0 self.time.high = 0 self.setAbsTime(self.t, self.unit) self.wait_ev = asyncio.Event() self.callback = func
def test(): """ c = a+b; """ time = pyvpi.Time() pyvpi.getTime(time) pyvpi.printf('py: hello world at %d\n' % time.time) handle_a = pyvpi.handleByName("top.a") val_a = pyvpi.Value(cons.vpiIntVal) pyvpi.getValue(handle_a, val_a) print(val_a.format) try: val_a.value += 1 pyvpi.putValue(handle_a, val_a) print('py: a = %d' % val_a.value) except: # pass
def test_time(): time = pyvpi.Time()
def __init__(self): self._time = pyvpi.Time(cons.vpiScaledRealTime) self.unit = pyvpi.getTimeScale(cons.vpiTimePrecision) - 2**32
import pyvpi import pyvpi_cons as cons def getAllHandles(handle,type) : ans = [] iter = pyvpi.iterate(type,handle) while True : h = pyvpi.scan(iter) if not h : break ans.append(h) return ans mod = pyvpi.handleByName("top") pyvpi.printf("All regs are blew here :\n") for reg in getAllHandles(mod,cons.vpiReg) : pyvpi.printf("%s\n" % (pyvpi.getStr(cons.vpiName,reg))) pyvpi.printf("All nets are blew here :\n") for net in getAllHandles(mod,cons.vpiNet) : pyvpi.printf("%s\n" % (pyvpi.getStr(cons.vpiFullName,net))) time = pyvpi.Time() pyvpi.getTime(time) pyvpi.printf("%s\n" %(time.low))