def fromPy(cls, val, typeObj, vldMask=None):
        """
        :param val: None or dictionary {index:value} or iterrable of values
        :param vldMask: if is None validity is resolved from val
            if is 0 value is invalidated
            if is 1 value has to be valid
        """
        size = evalParam(typeObj.size)
        if isinstance(size, Value):
            size = int(size)

        elements = {}
        if vldMask == 0:
            val = None

        if val is None:
            pass
        elif isinstance(val, dict):
            for k, v in val.items():
                if not isinstance(k, int):
                    k = int(k)
                elements[k] = typeObj.elmType.fromPy(v)
        else:
            for k, v in enumerate(val):
                if isinstance(v, RtlSignalBase):  # is signal
                    assert v._dtype == typeObj.elmType
                    e = v
                else:
                    e = typeObj.elmType.fromPy(v)
                elements[k] = e

        _mask = int(bool(val))
        if vldMask is None:
            vldMask = _mask
        else:
            assert (vldMask == _mask)

        return cls(elements, typeObj, vldMask)
def fromPy(cls, val, typeObj, vldMask=None):
        """
        :param val: None or dictionary {index:value} or iterrable of values
        :param vldMask: if is None validity is resolved from val
            if is 0 value is invalidated
            if is 1 value has to be valid
        """
        size = evalParam(typeObj.size)
        if isinstance(size, Value):
            size = int(size)

        elements = {}
        if vldMask == 0:
            val = None

        if val is None:
            pass
        elif isinstance(val, dict):
            for k, v in val.items():
                if not isinstance(k, int):
                    k = int(k)
                elements[k] = typeObj.elmType.fromPy(v)
        else:
            for k, v in enumerate(val):
                if isinstance(v, RtlSignalBase):  # is signal
                    assert v._dtype == typeObj.elmType
                    e = v
                else:
                    e = typeObj.elmType.fromPy(v)
                elements[k] = e

        _mask = int(bool(val))
        if vldMask is None:
            vldMask = _mask
        else:
            assert (vldMask == _mask)

        return cls(elements, typeObj, vldMask)
def fromPy ( cls , val , typeObj , vldMask = None ) : size = evalParam ( typeObj . size ) if isinstance ( size , Value ) : size = int ( size ) elements = { } if vldMask == 0 : val = None if val is None : pass elif isinstance ( val , dict ) : for k , v in val . items ( ) : if not isinstance ( k , int ) : k = int ( k ) elements [ k ] = typeObj . elmType . fromPy ( v ) else : for k , v in enumerate ( val ) : if isinstance ( v , RtlSignalBase ) : # is signal assert v . _dtype == typeObj . elmType e = v else : e = typeObj . elmType . fromPy ( v ) elements [ k ] = e _mask = int ( bool ( val ) ) if vldMask is None : vldMask = _mask else : assert ( vldMask == _mask ) return cls ( elements , typeObj , vldMask )
:param val: None or dictionary {index:value} or iterrable of values
        :param vldMask: if is None validity is resolved from val
            if is 0 value is invalidated
            if is 1 value has to be valid
: param val : None or dictionary { index : value } or iterrable of values : param vldMask : if is None validity is resolved from val if is 0 value is invalidated if is 1 value has to be valid