Exemplo n.º 1
0
    def writeOutput(self):
        sign = self.inputValues[self.inputZero]
        common.fromUnsignedWordToSignedWord(sign)
        sign = long(sign)
        assert (type(sign) == long)

        if sign < 0:
            sign = sign | 0xffff0000
        else:
            sign = sign | 0x00000000

        self.outputValues[self.outputName] = sign
Exemplo n.º 2
0
    def writeOutput(self):
        sign = self.inputValues[self.inputZero]
        common.fromUnsignedWordToSignedWord(sign)
        sign = long(sign)
        assert (type(sign) == long)

        # match the highest bit of the sign
        # and fill the upper bits with that bit
        if sign < 0:
            sign = sign | 0xffff0000
        else:
            sign = sign | 0x00000000

        self.outputValues[self.outputName] = sign
Exemplo n.º 3
0
 def printAll(self):
     '''
     Print the name and value in each register.
     '''
     
     # Note that we won't actually use all the registers listed here...
     registerNames = ['$zero', '$at', '$v0', '$v1', '$a0', '$a1', '$a2', '$a3',
                     '$t0', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7',
                     '$s0', '$s1', '$s2', '$s3', '$s4', '$s5', '$s6', '$s7',
                     '$t8', '$t9', '$k0', '$k1', '$gp', '$sp', '$fp', '$ra']
     
     print()
     print("Register file")
     print("================")
     for i in range(0, 32):
         print("%s \t=> %s (%s)" % (registerNames[i], common.fromUnsignedWordToSignedWord(self.register[i]), hex(int(self.register[i]))[:-1]))
     print("================")
     print()
     print()
Exemplo n.º 4
0
    def test_correct_behaviour(self):
        self.testinput.setOutputValue("signin", long(4))

        self.testSE.readInput()
        self.testSE.writeOutput()

        self.testoutput.readInput()

        output = self.testoutput.inputValues["signout"]
        self.assertEqual(output, 0b00000000000000000000000000000100)

        self.testinput.setOutputValue("signin", long(-4))

        self.testSE.readInput()
        self.testSE.writeOutput()

        self.testoutput.readInput()

        output = self.testoutput.inputValues["signout"]
        self.assertEqual(
            output,
            common.fromUnsignedWordToSignedWord(
                0b11111111111111111111111111111100))
Exemplo n.º 5
0
 def printAll(self):
     for key in sorted(self.memory.iterkeys()):
         print "%s\t=> %s\t(%s)" % (hex(long(key))[:-1], common.fromUnsignedWordToSignedWord(self.memory[key]), hex(long(self.memory[key]))[:-1])
Exemplo n.º 6
0
 def printAll(self):
     for key in sorted(self.memory.keys()):
         print("%s\t=> %s\t(%s)" % (hex(int(key)), common.fromUnsignedWordToSignedWord(self.memory[key]), hex(int(self.memory[key]))))