def __init__(self, *args): assert len(args) >= 2 self._args = args self._sigargs = sigargs = [] nrbits = 0 val = 0 for a in args: if isinstance(a, intbv): w = a._nrbits v = a._val elif isinstance(a, _Signal): sigargs.append(a) w = a._nrbits if isinstance(a._val, intbv): v = a._val._val else: v = a._val elif isinstance(a, bool): w = 1 v = a elif isinstance(a, str): w = len(a) v = long(a, 2) else: raise TypeError("ConcatSignal: inappropriate argument type: %s" \ % type(a)) nrbits += w val = val << w | v & (long(1) << w) - 1 self._initval = val ini = intbv(val)[nrbits:] _ShadowSignal.__init__(self, ini) gen = self.genfunc() self._waiter = _SignalTupleWaiter(gen)
def _makeWaiters(arglist): waiters = [] ids = set() cosim = None for arg in arglist: if isinstance(arg, GeneratorType): waiters.append(_inferWaiter(arg)) elif isinstance(arg, _Instantiator): waiters.append(arg.waiter) elif isinstance(arg, Cosimulation): if cosim is not None: raise SimulationError(_error.MultipleCosim) cosim = arg waiters.append(_SignalTupleWaiter(cosim._waiter())) elif isinstance(arg, _Waiter): waiters.append(arg) elif arg == True: pass else: raise SimulationError(_error.ArgType, str(type(arg))) if id(arg) in ids: raise SimulationError(_error.DuplicatedArg) ids.add(id(arg)) # add waiters for shadow signals for sig in _signals: if hasattr(sig, '_waiter'): waiters.append(sig._waiter) return waiters, cosim
def __init__(self, *args): assert len(args) >= 2 self._args = args self._sigargs = sigargs = [] nrbits = 0 val = 0 for a in args: if isinstance(a, intbv): w = a._nrbits v = a._val elif isinstance(a, _Signal): sigargs.append(a) w = a._nrbits if isinstance(a._val, intbv): v = a._val._val else: v = a._val elif isinstance(a, bool): w = 1 v = a elif isinstance(a, str): w = len(a) v = long(a, 2) else: raise TypeError("ConcatSignal: inappropriate argument type: %s" \ % type(a)) nrbits += w val = val << w | v & (long(1) << w)-1 self._initval = val ini = intbv(val)[nrbits:] _ShadowSignal.__init__(self, ini) gen = self.genfunc() self._waiter = _SignalTupleWaiter(gen)
def __init__(self, val): self._drivers = [] # construct normally to set type / size info right _ShadowSignal.__init__(self, val) self._orival = deepcopy(val) # keep for drivers # reset signal values to None self._next = self._val = self._init = None self._waiter = _SignalTupleWaiter(self._resolve())
def __init__(self, *args): assert len(args) >= 2 self._args = args ### XXX error checks nrbits = 0 for a in args: nrbits += len(a) ini = intbv(0)[nrbits:] hi = nrbits for a in args: lo = hi - len(a) ini[hi:lo] = a hi = lo _ShadowSignal.__init__(self, ini) gen = self.genfunc() self._waiter = _SignalTupleWaiter(gen)
def __init__(self, *args): assert len(args) >= 2 self._args = args self._sigargs = sigargs = [] nrbits = 0 val = 0 for a in args: # print( 'ConcatSignal', repr( a )) if isinstance(a, intbv): w = a._nrbits v = a._val elif isinstance(a, _Signal): # a._read = True sigargs.append(a) w = a._nrbits if isinstance(a._val, intbv): v = a._val._val else: v = a._val a._read = True elif isinstance(a, bool): w = 1 v = a elif isinstance(a, str): # remove underscores aa = a.replace('_', '') w = len(aa) v = long(aa, 2) else: raise TypeError( "ConcatSignal: inappropriate argument type: %s" % type(a)) nrbits += w val = val << w | v & (long(1) << w) - 1 self._initval = val ini = intbv(val)[nrbits:] _ShadowSignal.__init__(self, ini) self._driven = 'wire' gen = self.genfunc() self._waiter = _SignalTupleWaiter(gen)