def write(self, val, sig): """ Write value to signal or interface. """ if isinstance(sig, InterfaceBase): sig = sig._sigInside if isinstance(val, Value): v = val.clone() else: # assert type(sig._dtype) is not Bits, "Bits type is slow and should be automatically replaced by SimBitsT (on: %s)" % (sig._getFullName()) v = sig._dtype.fromPy(val) v.updateTime = self.now v = v._convert(sig._dtype) sig.simUpdateVal(self, lambda curentV: (valueHasChanged(curentV, v), v)) if not sig.simSensProcs and self.applyValEv is not None: # in some cases simulation process can wait on all values applied # signal value was changed but there are no sensitive processes to it # because of this applyValues is never planed and but should be self.scheduleApplyValues()
def updater(currentVal): if len(indexes) > 1: raise NotImplementedError() _nextItemVal = nextItemVal.clone() if invalidate: _nextItemVal.vldMask = 0 index = indexes[0] change = valueHasChanged(currentVal._getitem__val(index), _nextItemVal) currentVal._setitem__val(index, _nextItemVal) return (change, currentVal)
def write(self, val, sig: SimSignal) -> None: """ Write value to signal or interface. """ # get target RtlSignal try: simSensProcs = sig.simSensProcs except AttributeError: sig = sig._sigInside simSensProcs = sig.simSensProcs # type cast of input value t = sig._dtype if isinstance(val, Value): v = val.clone() v = v._auto_cast(t) else: v = t.fromPy(val) # can not update value in signal directly due singnal proxies sig.simUpdateVal(self, lambda curentV: (valueHasChanged(curentV, v), v)) if not self._applyValPlaned: if not (simSensProcs or sig.simRisingSensProcs or sig.simFallingSensProcs): # signal value was changed but there are no sensitive processes # to it because of this _applyValues is never planed # and should be self._scheduleApplyValues() elif (sig._writeCallbacks or sig._writeCallbacksToEn): # signal write did not caused any change on any other signal # but there are still simulation agets waiting on # updateComplete event self._scheduleApplyValues()
def updater(currentVal): _nextVal = nextVal.clone() if invalidate: _nextVal.vldMask = 0 return (valueHasChanged(currentVal, _nextVal), _nextVal)