hwt/hdl/frameTmpl.py
def packData(self, data):
        """
        Pack data into list of BitsVal of specified dataWidth

        :param data: dict of values for struct fields {fieldName: value}

        :return: list of BitsVal which are representing values of words
        """
        typeOfWord = simBitsT(self.wordWidth, None)
        fieldToVal = self._fieldToTPart
        if fieldToVal is None:
            fieldToVal = self._fieldToTPart = self.fieldToDataDict(
                self.origin.dtype,
                data,
                {})

        for _, transParts in self.walkWords(showPadding=True):
            actualVldMask = 0
            actualVal = 0
            for tPart in transParts:
                high, low = tPart.getBusWordBitRange()
                fhigh, flow = tPart.getFieldBitRange()
                if not tPart.isPadding:
                    val = fieldToVal.get(tPart.tmpl.origin, None)
                else:
                    val = None

                if val is None:
                    newBits = 0
                    vld = 0
                else:
                    newBits = selectBitRange(val, flow, fhigh - flow)
                    vld = mask(high - low) << low

                actualVal = setBitRange(actualVal, low, high - low, newBits)
                actualVldMask = setBitRange(actualVal, low, high - low, vld)

            yield typeOfWord.getValueCls()(actualVal, typeOfWord,
                                           actualVldMask, -1)
def packData(self, data):
        typeOfWord = simBitsT(self.wordWidth, None)
        fieldToVal = self._fieldToTPart
        if fieldToVal is None:
            fieldToVal = self._fieldToTPart = self.fieldToDataDict(
                self.origin.dtype,
                data,
                {})

        for _, transParts in self.walkWords(showPadding=True):
            actualVldMask = 0
            actualVal = 0
            for tPart in transParts:
                high, low = tPart.getBusWordBitRange()
                fhigh, flow = tPart.getFieldBitRange()
                if not tPart.isPadding:
                    val = fieldToVal.get(tPart.tmpl.origin, None)
                else:
                    val = None

                if val is None:
                    newBits = 0
                    vld = 0
                else:
                    newBits = selectBitRange(val, flow, fhigh - flow)
                    vld = mask(high - low) << low

                actualVal = setBitRange(actualVal, low, high - low, newBits)
                actualVldMask = setBitRange(actualVal, low, high - low, vld)

            yield typeOfWord.getValueCls()(actualVal, typeOfWord,
                                           actualVldMask, -1)
def packData ( self , data ) : typeOfWord = simBitsT ( self . wordWidth , None ) fieldToVal = self . _fieldToTPart if fieldToVal is None : fieldToVal = self . _fieldToTPart = self . fieldToDataDict ( self . origin . dtype , data , { } ) for _ , transParts in self . walkWords ( showPadding = True ) : actualVldMask = 0 actualVal = 0 for tPart in transParts : high , low = tPart . getBusWordBitRange ( ) fhigh , flow = tPart . getFieldBitRange ( ) if not tPart . isPadding : val = fieldToVal . get ( tPart . tmpl . origin , None ) else : val = None if val is None : newBits = 0 vld = 0 else : newBits = selectBitRange ( val , flow , fhigh - flow ) vld = mask ( high - low ) << low actualVal = setBitRange ( actualVal , low , high - low , newBits ) actualVldMask = setBitRange ( actualVal , low , high - low , vld ) yield typeOfWord . getValueCls ( ) ( actualVal , typeOfWord , actualVldMask , - 1 )
Pack data into list of BitsVal of specified dataWidth

        :param data: dict of values for struct fields {fieldName: value}

        :return: list of BitsVal which are representing values of words
Pack data into list of BitsVal of specified dataWidth