def register(self): ''' Register cb ''' pyvpi.registerCb(self) if self.register_in_gd: self.add_to_gd()
def __await__(self): cbdata = self.create_cbdata() cbdata.loop = asyncio.get_event_loop() cbdata.ct = asyncio.current_task(cbdata.loop ) pyvpi.registerCb(cbdata) print("start Edge wait "+repr(self)+'at time:%d\n'%Simtime.value) return cbdata.wait_ev.wait().__await__()
def __await__(self): cbdata = self.create_cbdata() cbdata.loop = asyncio.get_event_loop() cbdata.ct = asyncio.current_task(cbdata.loop ) pyvpi.registerCb(cbdata) # PENDING_CB.append(cbdata) # print("start wait "+repr(self)+'\n') return cbdata.wait_ev.wait().__await__()
def run_sim(t, unit=None): cbdata = pyvpi.CbData() cbdata.reason = cons.cbAfterDelay cbdata.callback = _pyinteractive_cb setAbsTime(cbdata, t, unit) pyvpi.registerCb(cbdata) pyvpi.printf("Register runtime = %d\n" % cbdata.time.time) time.sleep(0.1) pyinteractive_lock = sys.modules['__main__'].__dict__['pyinteractive_lock'] pyinteractive_lock.set() time.sleep(0.1)
def __await__(self): # pyvpi.printf("1\n") cbdata = self.create_cbdata() # pyvpi.printf("2\n") cbdata.loop = asyncio.get_running_loop() # pyvpi.printf("3\n") cbdata.ct = asyncio.current_task(cbdata.loop) # pyvpi.printf("4\n") pyvpi.registerCb(cbdata) # pyvpi.printf("register timer {}\n".format(self.name)) return cbdata.wait_ev.wait().__await__()
def test_normal() : """ """ global call pyvpi.printf("error start!\n") cb = pyvpi.CbData(cons.cbValueChange, trgobj = pyvpi.handleByName("test.o",0), value = pyvpi.Value(cons.vpiBinStrVal)) cb.user_data = 1 def callback(arg): pyvpi.printf("%s : " % arg.time.low) pyvpi.printf("%s : " % arg.value.value) pyvpi.printf("%s\n" % "callback is run...") if cb.user_data == 3 : pyvpi.removeCb(arg) cb.user_data += 1 cb.callback = callback pyvpi.registerCb(cb)
def test_normal(): """ """ global call pyvpi.printf("error start!\n") cb = pyvpi.CbData(cons.cbValueChange, trgobj=pyvpi.handleByName("test.o", 0), value=pyvpi.Value(cons.vpiBinStrVal)) cb.user_data = 1 def callback(arg): pyvpi.printf("%s : " % arg.time.low) pyvpi.printf("%s : " % arg.value.value) pyvpi.printf("%s\n" % "callback is run...") if cb.user_data == 3: pyvpi.removeCb(arg) cb.user_data += 1 cb.callback = callback pyvpi.registerCb(cb)
def register(self): pyvpi.registerCb(self)
def register(self): self.log("CB REG") pyvpi.registerCb(self)
from pyvpi import CbData,registerCb,removeCb,handleByName,Value,getValue,printf import pyvpi_cons as cons import traceback c = handleByName("top.c") a = handleByName("top.a") b = handleByName("top.b") def callback(self) : try : getValue(self.a,self.av) getValue(self.b,self.bv) printf("%s : %s(a) + %s(b) = %s(o)\n" % (self.time.time, self.av.value, self.bv.value, self.value.value.vec)) except Exception as e : printf("%s\n%s\n" % (e,traceback.print_exc())) cb = CbData(trgobj = c,callback = callback, value = Value(cons.vpiVectorVal)) cb.a = a cb.b = b cb.av = Value() cb.bv = Value() printf("%s\n" % (hasattr(cb,"a"))) registerCb(cb)
#! python import pyvpi import pyvpi_cons as cons import random import unittest import sys import socket import select host = "localhost" port = 9999 s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect((host,port)) trgobj=pyvpi.handleByName("test.clk",0) cb = pyvpi.CbData(trgobj=trgobj) val = pyvpi.Value() cb.reason = cons.cbValueChange cb.value = val cb.user_data = [s,0] def callback(arg) : cb.user_data[0].send("%s\n" % cb.user_data[1]) infds,outfds,errfds = select.select([cb.user_data[0],],[],[],0) if len(infds) > 0 : buf = cb.user_data[0].recv(8196) print buf cb.user_data[1] += 1 cb.callback = callback cb_h = pyvpi.registerCb(cb)
#! python from pyvpi import CbData,registerCb,removeCb,handleByName,Value,getValue,printf import pyvpi_cons as cons import traceback o = handleByName("test.o") a = handleByName("test.a") b = handleByName("test.b") def callback(self) : try : getValue(self.a,self.av) getValue(self.b,self.bv) printf("%s : %s(a) + %s(b) = %s(o)\n" % (self.time.time, self.av.value, self.bv.value, self.value.value.vec)) except Exception,e : printf("%s\n%s\n" % (e,traceback.print_exc())) cb = CbData(trgobj = o,callback = callback, value = Value(cons.vpiVectorVal)) cb.a = a cb.b = b cb.av = Value() cb.bv = Value() printf("%s\n" % (hasattr(cb,"a"))) registerCb(cb)
def myfunc(self, arg): self.func(arg) self.time.low = int(self.dxt % 2**32) self.time.high = int(self.dxt // 2**32) pyvpi.registerCb(self)
def __await__(self): cbdata = self.create_cbdata() cbdata.loop = asyncio.get_running_loop() cbdata.ct = asyncio.current_task(cbdata.loop) pyvpi.registerCb(cbdata) return cbdata.wait_ev.wait().__await__()