コード例 #1
0
    def testWrongFunct3Model(self):
        # max funct3
        name = 'rightfunct3'
        self.funct3 = 0x07
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename)

        # parse model
        model = Model(filename)

        # check parsed models for expected values
        self.assertEqual(model.form, self.ccmodel.ftype)
        self.assertEqual(model.funct3, self.ccmodel.funct3)
        self.assertEqual(model.name, self.ccmodel.name)
        self.assertEqual(model.opc, self.ccmodel.opc)
        self.assertEqual(model.cycles, self.ccmodel.cycles)

        # now a wrong model
        name = 'wrongfunct3'
        self.funct3 = 0xaa
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, faults=['wrongfunct3'])

        with self.assertRaises(ValueError):
            Model(filename)
コード例 #2
0
    def testWrongFunct7Model(self):
        # max funct7
        name = 'rightfunct7'
        self.ftype = 'R'
        funct7 = 0x7f
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, funct7=funct7)

        # parse model
        model = Model(filename)

        # check parsed models for expected values
        self.assertEqual(model.form, self.ccmodel.ftype)
        self.assertEqual(model.funct3, self.ccmodel.funct3)
        self.assertEqual(model.funct7, self.ccmodel.funct7)
        self.assertEqual(model.name, self.ccmodel.name)
        self.assertEqual(model.opc, self.ccmodel.opc)
        self.assertEqual(model.cycles, self.ccmodel.cycles)

        # wrong funct7
        name = 'wrongfunct7'
        self.ftype = 'R'
        funct7 = 0xaa
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, funct7=funct7)

        with self.assertRaises(ValueError):
            Model(filename)
コード例 #3
0
    def testNoCycleCount(self):
        name = 'nocycles'
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, faults=['nocycles'])

        with self.assertRaises(ValueError):
            Model(filename)
コード例 #4
0
    def testNonVoidFct(self):
        name = 'nonvoid'
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, faults=['nonvoid', 'return'])

        with self.assertRaises(ConsistencyError):
            Model(filename)
コード例 #5
0
    def testReturnInFctBody(self):
        name = 'retfct'
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, faults=['return'])

        with self.assertRaises(ConsistencyError):
            Model(filename)
コード例 #6
0
    def testNoClosingBracket(self):
        name = 'noclose'
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, faults=['noclose'])

        with self.assertRaises(ConsistencyError):
            Model(filename)
コード例 #7
0
    def testNoDefinitionModel(self):
        name = 'nodef'
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, faults=['nodef'])

        with self.assertRaises(ConsistencyError):
            Model(filename)
コード例 #8
0
    def testNoRdNoRs1NoOp2Model(self):
        name = 'nordnors1noop2'
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, faults=['nord', 'nors1', 'noop2'])

        with self.assertRaises(ConsistencyError):
            Model(filename)
コード例 #9
0
    def testNoRs1Model(self):
        # no rs1 specified
        name = 'nors1'
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, faults=['nors1'])

        with self.assertRaises(ConsistencyError):
            Model(filename)
コード例 #10
0
    def testExtractDefinitionModel(self):
        name = 'extract'
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename)

        # parse model
        model = Model(filename)

        self.assertEqual(model.definition,
                         '{\n    // function definition\n}')
コード例 #11
0
    def testWrongOpcModel(self):
        # wrong opcode given
        name = 'wrongopc'
        self.opc = 0x10
        self.funct3 = 0x00
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, faults=['wrongopc'])

        # check whether the exceptions where thrown correctly
        with self.assertRaises(ValueError):
            Model(filename)
コード例 #12
0
    def testITypeModel(self):
        # map itype.cc
        name = 'itype'
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename)

        # parse model
        model = Model(filename)

        # check parsed models for expected values
        self.assertEqual(model.form, self.ccmodel.ftype)
        self.assertEqual(model.funct3, self.ccmodel.funct3)
        self.assertEqual(model.name, self.ccmodel.name)
        self.assertEqual(model.opc, self.ccmodel.opc)
        self.assertEqual(model.cycles, self.ccmodel.cycles)
コード例 #13
0
    def testRTypeModel(self):
        # map rtype.cc -- should be correct
        name = 'rtype'
        self.ftype = 'R'
        self.opc = 0x02
        funct7 = 0x01
        filename = self.folderpath + name + '.cc'

        self.genModel(name, filename, funct7)

        # parse model
        model = Model(filename)

        # check parsed models for expected values
        self.assertEqual(model.form, self.ccmodel.ftype)
        self.assertEqual(model.funct3, self.ccmodel.funct3)
        self.assertEqual(model.funct7, self.ccmodel.funct7)
        self.assertEqual(model.name, self.ccmodel.name)
        self.assertEqual(model.opc, self.ccmodel.opc)
        self.assertEqual(model.cycles, self.ccmodel.cycles)