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)
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)
def testNoCycleCount(self): name = 'nocycles' filename = self.folderpath + name + '.cc' self.genModel(name, filename, faults=['nocycles']) with self.assertRaises(ValueError): Model(filename)
def testNonVoidFct(self): name = 'nonvoid' filename = self.folderpath + name + '.cc' self.genModel(name, filename, faults=['nonvoid', 'return']) with self.assertRaises(ConsistencyError): Model(filename)
def testReturnInFctBody(self): name = 'retfct' filename = self.folderpath + name + '.cc' self.genModel(name, filename, faults=['return']) with self.assertRaises(ConsistencyError): Model(filename)
def testNoClosingBracket(self): name = 'noclose' filename = self.folderpath + name + '.cc' self.genModel(name, filename, faults=['noclose']) with self.assertRaises(ConsistencyError): Model(filename)
def testNoDefinitionModel(self): name = 'nodef' filename = self.folderpath + name + '.cc' self.genModel(name, filename, faults=['nodef']) with self.assertRaises(ConsistencyError): Model(filename)
def testNoRdNoRs1NoOp2Model(self): name = 'nordnors1noop2' filename = self.folderpath + name + '.cc' self.genModel(name, filename, faults=['nord', 'nors1', 'noop2']) with self.assertRaises(ConsistencyError): Model(filename)
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)
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}')
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)
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)
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)