Beispiel #1
0
    def test_fsm0(self):
        word_bytes = 2
        f_len = (1, 1)
        streams = [
            HStream(Bits(8), frame_len=f_len, start_offsets=[1]),
        ]
        out_offset = 0
        sju = FrameAlignmentUtils(word_bytes, out_offset)
        input_B_dst = sju.resolve_input_bytes_destinations(streams)
        tt = input_B_dst_to_fsm(word_bytes, len(streams), input_B_dst)

        def st(d):
            return StateTransItem.from_dict(tt, d)

        ref = [
            [
                st({
                    'st': '0->0',
                    'in': [[{
                        'keep': [0, 1],
                        'relict': 0,
                        'last': 1
                    }]],
                    'in.keep_mask': [[[0, 0]]],
                    'in.rd': [1],
                    'out.keep': [1, 0],
                    'out.mux': [(0, 0, 1), None],
                    'out.last': 1
                })
            ],
        ]

        self.assertSequenceEqual(tt.state_trans, ref)
Beispiel #2
0
    def test_fsm_1x3B_on_2B_offset_1(self):
        word_bytes = 2
        streams = [
            HStream(Bits(8 * 3), (1, 1), [1]),
        ]
        out_offset = 0
        sju = FrameAlignmentUtils(word_bytes, out_offset)
        input_B_dst = sju.resolve_input_bytes_destinations(streams)
        tt = input_B_dst_to_fsm(word_bytes, len(streams), input_B_dst)

        def st(d):
            return StateTransItem.from_dict(tt, d)

        ref = [[
            st({
                'st':
                '0->0',
                'in': [[{
                    'keep': [0, 1],
                    'relict': 1,
                    'last': 1
                }, {
                    'keep': ['X', 'X'],
                    'relict': 'X',
                    'last': 'X'
                }]],
                'in.keep_mask': [[[0, 0], [1, 1]]],
                'in.rd': [1],
                'out.keep': [1, 0],
                'out.mux': [(0, 0, 1), None],
                'out.last':
                1
            }),
            st({
                'st':
                '0->0',
                'in': [[{
                    'keep': [0, 1],
                    'relict': 'X',
                    'last': 0
                }, {
                    'keep': [1, 1],
                    'relict': 'X',
                    'last': 1
                }]],
                'in.keep_mask': [[[0, 0], [0, 1]]],
                'in.rd': [1],
                'out.keep': [1, 1],
                'out.mux': [(0, 0, 1), (0, 1, 0)],
                'out.last':
                0
            })
        ]]
        self.assertSequenceEqual(tt.state_trans, ref)
Beispiel #3
0
 def _declr(self):
     assert self.USE_KEEP
     t = self.T
     assert isinstance(t, HStruct)
     word_bytes = self.word_bytes = self.DATA_WIDTH // 8
     input_cnt = self.input_cnt = len(t.fields)
     streams = [f.dtype for f in t.fields]
     fju = FrameAlignmentUtils(word_bytes, self.OUT_OFFSET)
     input_B_dst = fju.resolve_input_bytes_destinations(
         streams)
     self.state_trans_table = input_B_dst_to_fsm(
         word_bytes, input_cnt, input_B_dst)
     addClkRstn(self)
     with self._paramsShared():
         self.dataOut = AxiStream()._m()
         self.dataIn = HObjList(AxiStream() for _ in range(self.input_cnt))