Exemplo n.º 1
0
 def register(self):
     '''
     Register cb
     '''
     pyvpi.registerCb(self)
     if self.register_in_gd:
         self.add_to_gd()
Exemplo n.º 2
0
 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__()
Exemplo n.º 3
0
 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__()
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
 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__()
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
 def register(self):
     pyvpi.registerCb(self)
Exemplo n.º 9
0
 def register(self):
     self.log("CB REG")
     pyvpi.registerCb(self)
Exemplo n.º 10
0
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)
Exemplo n.º 11
0
#! 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)
Exemplo n.º 12
0
Arquivo: 4.py Projeto: GeneKong/pyvpi
#! 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)

Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
 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__()