コード例 #1
0
ファイル: ARMMethods.py プロジェクト: naushad-rahman/trap-gen
# *******
# Here we define some helper methods, which are not directly part of the
# instructions, but which can be called by the instruction body
# *******
opCode = cxx_writer.writer_code.Code("""
shifted = toShift >> shift_amm;
//Controlling the sign extensions
if((toShift & 0x80000000) != 0){
    shifted |= (((unsigned int)0xFFFFFFFF) << (32 - shift_amm));
}
else{
    shifted &= (((unsigned int)0xFFFFFFFF) >> shift_amm);
}
return shifted;
""")
AShiftRight_method = trap.HelperMethod('ArithmeticShiftRight', opCode,
                                       'execute')
AShiftRight_method.setSignature(('BIT<32>'), [
    cxx_writer.writer_code.Parameter('shift_amm',
                                     cxx_writer.writer_code.uintType),
    ('toShift', 'BIT<32>')
])
AShiftRight_method.addVariable(('shifted', 'BIT<32>'))

opCode = cxx_writer.writer_code.Code("""
if((bitSeq & (1 << (bitSeq_length - 1))) != 0)
    bitSeq |= (((unsigned int)0xFFFFFFFF) << bitSeq_length);
return bitSeq;
""")
SignExtend_method = trap.HelperMethod('SignExtend', opCode, 'execute')
SignExtend_method.setSignature(
    ('BIT<32>'), [('bitSeq', 'BIT<32>'),
コード例 #2
0
#-------------------------------------------------------
# Miscellaneous operations which can be used and
# accessed by any instruction
#-------------------------------------------------------
# *******
# Here we define some helper methods, which are not directly part of the
# instructions, but which can be called by the instruction body
# *******

opCode = cxx_writer.writer_code.Code("""
if((bitSeq & (1 << (bitSeq_length - 1))) != 0)
    bitSeq |= (((unsigned int)0xFFFFFFFF) << bitSeq_length);
return bitSeq;
""")
SignExtend_method = trap.HelperMethod('SignExtend', opCode, 'execute')
SignExtend_method.setSignature(('BIT<32>'), [('bitSeq', 'BIT<32>'), cxx_writer.writer_code.Parameter('bitSeq_length', cxx_writer.writer_code.uintType)])

# PC increment
opCode = cxx_writer.writer_code.Code("""
if (TARGET == 0xffffffff) {
	PC = PC + 4;
	DSFLAG = 0x0;
} else {
	PC = TARGET;
	TARGET = 0xffffffff;
	DSFLAG = 0x1;
}
""")
IncrementPC = trap.HelperOperation('IncrementPC', opCode, inline = False)
コード例 #3
0
# Methods used (just by the cycle accurate processor) to check that a register window is valid
# when a decrement or an increment are performed
checkIncrementWin_code = """
unsigned int newCwp = ((unsigned int)(PSR[key_CWP] + 1)) % NUM_REG_WIN;
if(((0x01 << (newCwp)) & WIM) != 0){
    return false;
}
else{
    return true;
}
"""
opCode = cxx_writer.writer_code.Code(checkIncrementWin_code)
checkIncrementWin_method = trap.HelperMethod('checkIncrementWin',
                                             opCode,
                                             'decode',
                                             exception=False,
                                             const=True)
checkIncrementWin_method.setSignature(cxx_writer.writer_code.boolType)
checkDecrementWin_code = """
unsigned int newCwp = ((unsigned int)(PSR[key_CWP] - 1)) % NUM_REG_WIN;
if(((0x01 << (newCwp)) & WIM) != 0){
    return false;
}
else{
    return true;
}
"""
opCode = cxx_writer.writer_code.Code(checkDecrementWin_code)
checkDecrementWin_method = trap.HelperMethod('checkDecrementWin',
                                             opCode,