Exemple #1
0
    def _declr(self):
        """"
        Parse template and decorate with interfaces
        """
        t = self._structT
        s_t = _get_only_stream(t)
        if s_t is None:
            self.sub_t = [_t for _, _t in separate_streams(t)]
            if len(self.sub_t) == 1:
                # we process all the fields in this component
                self.parseTemplate()
            # else each child will parse it's own part
            # and we join output frames together
        else:
            # only instantiate a component which aligns the stream
            # to correct output format
            self.sub_t = [
                s_t,
            ]

        addClkRstn(self)
        with self._paramsShared():
            self.dataOut = self.intfCls()._m()

        if isinstance(self._structT, HStruct):
            intfCls = StructIntf
        elif isinstance(self._structT, HUnion):
            intfCls = UnionSink
        else:
            raise TypeError(self._structT)

        self.dataIn = intfCls(self._structT, tuple(), self._mkFieldIntf)
Exemple #2
0
 def test_separate_streams_simple(self):
     t = HStruct(
         (HStream(Bits(8)), "data"),
         (Bits(32), "footer"),
     )
     sep = list(separate_streams(t))
     self.assertSequenceEqual(sep,
                              [(True, HStruct(
                                  (HStream(Bits(8)), "data"), )),
                               (False, HStruct((Bits(32), "footer"), ))])
Exemple #3
0
 def test_separate_streams_no_fotter2(self):
     t = HStruct((Bits(8), "data"), )
     sep = list(separate_streams(t))
     self.assertSequenceEqual(sep, [
         (False, t),
     ])