hwt/synthesizer/rtlLevel/signalUtils/ops.py
def naryOp(self, operator, opCreateDelegate, *otherOps) -> RtlSignalBase:
        """
        Try lookup operator with this parameters in _usedOps
        if not found create new one and soter it in _usedOps

        :param operator: instance of OpDefinition
        :param opCreateDelegate: function (*ops) to create operator
        :param otherOps: other operands (ops = self + otherOps)

        :return: RtlSignal which is result of newly created operator
        """
        k = (operator, *otherOps)
        used = self._usedOps
        try:
            return used[k]
        except KeyError:
            pass

        o = opCreateDelegate(self, *otherOps)

        # input operads may be type converted,
        # search if this happend, and return always same result signal
        try:
            op_instanciated = (o.origin.operator == operator
                               and o.origin.operands[0] is self)
        except AttributeError:
            op_instanciated = False

        if op_instanciated:
            k_real = (operator, *o.origin.operands[1:])
            real_o = used.get(k_real, None)
            if real_o is not None:
                # destroy newly created operator and result, because it is same
                # as
                ctx = self.ctx
                if ctx is not None:
                    ctx.signals.remove(o)

                op = o.origin
                o.origin = None
                o.drivers.clear()
                for inp in op.operands:
                    if isinstance(inp, RtlSignalBase):
                        inp.endpoints.remove(op)

                o = real_o
            else:
                used[k_real] = o

        used[k] = o

        return o
def naryOp(self, operator, opCreateDelegate, *otherOps) -> RtlSignalBase:
        """
        Try lookup operator with this parameters in _usedOps
        if not found create new one and soter it in _usedOps

        :param operator: instance of OpDefinition
        :param opCreateDelegate: function (*ops) to create operator
        :param otherOps: other operands (ops = self + otherOps)

        :return: RtlSignal which is result of newly created operator
        """
        k = (operator, *otherOps)
        used = self._usedOps
        try:
            return used[k]
        except KeyError:
            pass

        o = opCreateDelegate(self, *otherOps)

        # input operads may be type converted,
        # search if this happend, and return always same result signal
        try:
            op_instanciated = (o.origin.operator == operator
                               and o.origin.operands[0] is self)
        except AttributeError:
            op_instanciated = False

        if op_instanciated:
            k_real = (operator, *o.origin.operands[1:])
            real_o = used.get(k_real, None)
            if real_o is not None:
                # destroy newly created operator and result, because it is same
                # as
                ctx = self.ctx
                if ctx is not None:
                    ctx.signals.remove(o)

                op = o.origin
                o.origin = None
                o.drivers.clear()
                for inp in op.operands:
                    if isinstance(inp, RtlSignalBase):
                        inp.endpoints.remove(op)

                o = real_o
            else:
                used[k_real] = o

        used[k] = o

        return o
Try lookup operator with this parameters in _usedOps
        if not found create new one and soter it in _usedOps

        :param operator: instance of OpDefinition
        :param opCreateDelegate: function (*ops) to create operator
        :param otherOps: other operands (ops = self + otherOps)

        :return: RtlSignal which is result of newly created operator