def test_iterate(): m = pyvpi.handleByName("test") iter = pyvpi.iterate(cons.vpiReg, m) reg = pyvpi.scan(iter) while (reg): pyvpi.printf("reg : %s\n" % pyvpi.getStr(cons.vpiName, reg)) reg = pyvpi.scan(iter)
def test_iterate(): m = pyvpi.handleByName("test") iter = pyvpi.iterate(cons.vpiReg,m) reg = pyvpi.scan(iter) while(reg) : pyvpi.printf("reg : %s\n" % pyvpi.getStr(cons.vpiName,reg)) reg = pyvpi.scan(iter)
def test(): """ c = a+b; """ a = pyvpi.handleByName("top.u_pyadaptor.a") b = pyvpi.handleByName("top.u_pyadaptor.b") c = pyvpi.handleByName("top.u_pyadaptor.c") p = pyvpi.handleByName("top.p") s = pyvpi.getStr(cons.vpiName, p) pyvpi.printf('p is {}\n'.format(s)) st = pyvpi.getStr(cons.vpiType, p) pyvpi.printf('p type = {}\n'.format(st)) it = pyvpi.iterate(cons.vpiMember, p) xt = pyvpi.scan(it) while (xt): st = pyvpi.getStr(cons.vpiFullName, xt) pyvpi.printf('P Member name = {} \n'.format(st)) xt = pyvpi.scan(it) ph = pyvpi.handle(cons.vpiTypespec, p) p_name = pyvpi.getStr(cons.vpiName, ph) pyvpi.printf('p type name = {}\n'.format(p_name)) val_a = pyvpi.Value(cons.vpiIntVal) val_b = pyvpi.Value(cons.vpiIntVal) val_c = pyvpi.Value(cons.vpiIntVal) pyvpi.getValue(a, val_a) pyvpi.getValue(b, val_b) pyvpi.getValue(c, val_c) try: val_c.value = val_a.value + val_b.value pyvpi.putValue(c, val_c) pyvpi.printf("py a:{} + b:{} = c:{}\n".format(val_a.value, val_b.value, val_c.value)) except: # skip if value is unknown pass
def test_pyeda(): #print "???" pyvpi.printf("1\n") pyvpi.handleByName("test") pyvpi.printf("2\n") a = pyvpi.handleByName("o") pyvpi.printf("3\n") pyvpi.printf( "module name : %s\n" % pyvpi.getStr(cons.vpiFullName, pyvpi.handle(cons.vpiModule, a))) pyvpi.printf("4\n") val = pyvpi.Value(cons.vpiVectorVal) vec = pyvpi.Vector(9, [(0, 0)]) val.value = vec #pyvpi.putValue(a,val) pyvpi.printf("%s %s\n" % (val.value.vec, val.value.size))
def test_pyeda() : #print "???" pyvpi.printf("1\n") pyvpi.handleByName("test") pyvpi.printf("2\n") a = pyvpi.handleByName("o") pyvpi.printf("3\n") pyvpi.printf("module name : %s\n" % pyvpi.getStr(cons.vpiFullName, pyvpi.handle(cons.vpiModule, a) ) ) pyvpi.printf("4\n") val = pyvpi.Value(cons.vpiVectorVal) vec = pyvpi.Vector(9,[(0,0)]) val.value = vec #pyvpi.putValue(a,val) pyvpi.printf("%s %s\n" % (val.value.vec,val.value.size))
#! python 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("test") 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))
def fullname(self): rt = pyvpi.getStr(cons.vpiFullName, self._handle) return rt
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))