com.cmpware.cmp.models
Class PowerPC

java.lang.Object
  extended by com.cmpware.cmp.Memory
      extended by com.cmpware.cmp.Processor
          extended by com.cmpware.tools.AutoModel
              extended by com.cmpware.cmp.models.PowerPC
All Implemented Interfaces:
ReadWriteInterface

public class PowerPC
extends AutoModel

This is an AutoModel implementation of the PowerPC processor. It implements all of the standard PowerPC Instruction Set Architecture. In particular, no extensions such as floating point, embedded or the non-portable extensions are implemented in this version, although they can be added fairly easily to this model. The large number of special registers and the unusual addressing are perhaps the biggest complication in the PowerPC model. Only the registers actually used in the implemented instructions are implemented, all others are ignored. This information is taken from the IBM document "PPC405Fx Embedded Processor Core: User's Manual (Preliminary)", IBM Document Number SA14-2764-00, January 28, 2005. Implementation notes: The document specifies Big Endian, but uses bit 0 as the MSB. Field numbers in this model will be (31-n) compared to the IBM document. BCA and BCL decodes swapped. Fixed 4/23/2008 Added missing MULHWU instruction 4/23/2008 AND instruction decoding incorrectly. Fixed 4/23/2008 AND, ANDC, ANDI, ANDIS and NAND implemented incorrectly. Fixed 4/24/2008. Added proper disassembly for ANDI, ANDIS, ORI, ORIS, XORI, XORIC. Fixed 4/24/2008. Added proper disassembly for AND, ANDC, NAND, NOR, OR, ORC, XOR. Fixed 4/24/2008. Fixed MFSPR and MTSPR instructions. Fixed 4/24/2008.

Copyright (c) 2006 Cmpware, Inc. All Rights Reserved.

Author:
SAG

Nested Class Summary
static class PowerPC.CR0
          This class defines the fields in the CR Special Register
static class PowerPC.MSR
          This class defines the fields in the MSR Special Register
static class PowerPC.SR
          This class defines the Special Register indicies
static class PowerPC.XER
          This class defines the fields in the XER Special Register
 
Nested classes/interfaces inherited from class com.cmpware.tools.AutoModel
AutoModel.Asm, AutoModel.Decode, AutoModel.Field, AutoModel.Format, AutoModel.Function, AutoModel.Instruction, AutoModel.Symbol
 
Field Summary
static java.lang.String copyright
          Copyright string
static PowerPC_fp fp
          The floating point instructions
static AutoModel.Symbol[] regSymbols
          The General Purpose Register Symbols
(package private)  boolean reserve
          The reserve semaphore for lwarx / stwcx instructions
static AutoModel.Symbol[] sregSymbols
          The Special Purpose Register Symbols
 
Fields inherited from class com.cmpware.tools.AutoModel
currentInstr, currentInstrType, instructionSizes, TRACE
 
Fields inherited from class com.cmpware.cmp.Processor
bkpt, branchAddr, branchDelay, breakpointHit, currentBranchDelay, currentInstrCode, cycleCount, elf, idlePower, iMix, instructionSize, name, noop, opcodeName, pc, prevInstr, prevInstrCode, r, regName, runningPower, sr, sregName, stall, stallCount
 
Fields inherited from class com.cmpware.cmp.Memory
BIG, LITTLE
 
Constructor Summary
PowerPC()
          The constructor
 
Method Summary
static int addCarry(int result, int src1, int src2)
          This method is used to determine if an add carry has occurred.
static int addOverflow(int result, int src1, int src2)
          This method is used to determine if an add overflow has occurred.
 int[] getRegisters()
          This method returns the current values of all of the general purpose registers.
static void main(java.lang.String[] args)
          This enables the stand-alone assembler and disassembler.
 void preExecute(int instr)
          This method is called immediately before execution and may be overloaded to do things like save instruction field values to locals.
 void reset()
          This method resets the processor.
static int rotateLeft(int a, int r)
          This method rotates the value a left by r.
static int sign(int a)
          This method returns the sign bit for 32 bit value.
static int subCarry(int result, int src1, int src2)
          This method is used to determine if a sub carry has occurred.
static int subOverflow(int result, int src1, int src2)
          This method is used to determine if a sub overflow has occurred.
 
Methods inherited from class com.cmpware.tools.AutoModel
advancePC, asmFixup, bitsToBytes, concatenate, dasm, dasm, dasmFixup, decode, defineInstructions, execute, fetch, fetch, getInstruction, getInstructions, getInstructionSizes, getPC, getSymbolNames, instrMatch, main, postExecute, setPC, signExtend, signExtend, toHexString, toHexString, toLong, traceOff, traceOn
 
Methods inherited from class com.cmpware.cmp.Processor
branch, branchNoDelay, defineBranchDelay, defineBreakpoint, defineInstructionSize, defineName, defineNoop, defineOpcodeNames, defineRegisterNames, defineRegisters, defineSpecialRegisterNames, defineSpecialRegisters, get, getBreakpoint, getBreakpointData, getBreakpoints, getCycleCount, getDebugRegisters, getElf, getIdlePower, getInstructionMix, getInstructionSize, getName, getNoop, getOpcodeNames, getRegister, getRegisterNames, getRunningPower, getSpecialRegister, getSpecialRegisterNames, getSpecialRegisters, getStallCount, isBreakpoint, isStalled, load, postLoad, removeAllBreakpoints, removeBreakpoint, setBreakpoint, setIdlePower, setRegister, setRunningPower, setSpecialRegister, stall, statistics, step
 
Methods inherited from class com.cmpware.cmp.Memory
addInput, addMemory, addOutput, getEndian, getLocalMemory, getMemoryManager, getMmio, getProfile, hexDump, hexDump, isReadable, isValidAddress, isWriteable, profile, read, read, read16, read24, read32, read64, removeMemory, resize, setEndian, size, toInt, toShort, write, write, write16, write24, write32, write64
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final java.lang.String copyright
Copyright string

See Also:
Constant Field Values

fp

public static final PowerPC_fp fp
The floating point instructions


reserve

boolean reserve
The reserve semaphore for lwarx / stwcx instructions


regSymbols

public static final AutoModel.Symbol[] regSymbols
The General Purpose Register Symbols


sregSymbols

public static final AutoModel.Symbol[] sregSymbols
The Special Purpose Register Symbols

Constructor Detail

PowerPC

public PowerPC()
The constructor

Method Detail

main

public static void main(java.lang.String[] args)
This enables the stand-alone assembler and disassembler. The command line should be either: java PowerPC -dasm or java PowerPC -asm

Parameters:
args - the command line arguments.

reset

public void reset()
This method resets the processor. Note that super.reset() must me called to completely intialize the processor.

Overrides:
reset in class Processor

getRegisters

public int[] getRegisters()
Description copied from class: Processor
This method returns the current values of all of the general purpose registers.

Overrides:
getRegisters in class Processor
Returns:
This method returns the current values of all of the general purpose registers.

preExecute

public void preExecute(int instr)
Description copied from class: AutoModel
This method is called immediately before execution and may be overloaded to do things like save instruction field values to locals.

Overrides:
preExecute in class AutoModel
Parameters:
instr - The instruction

addOverflow

public static int addOverflow(int result,
                              int src1,
                              int src2)
This method is used to determine if an add overflow has occurred. This is done by checking the signs of the source operands against the sign of the result.

Parameters:
result - The result of the operation on the src1 and src2 parameters.
src1 - The first source operand.
src2 - The second source operand.
Returns:
This method returns a true if an overflow was detected and false otherwise.

subOverflow

public static int subOverflow(int result,
                              int src1,
                              int src2)
This method is used to determine if a sub overflow has occurred. This is done by checking the signs of the source operands against the sign of the result.

Parameters:
result - The result of the operation on the src1 and src2 parameters.
src1 - The first source operand.
src2 - The second source operand.
Returns:
This method returns a true if an overflow was detected and a false otherwise.

addCarry

public static int addCarry(int result,
                           int src1,
                           int src2)
This method is used to determine if an add carry has occurred. This is done by checking the signs of the source operands against the sign of the result.

Parameters:
result - The result of the operation on the src1 and src2 parameters.
src1 - The first source operand.
src2 - The second source operand.
Returns:
This method returns a one if a carry was detected and a zero otherwise.

subCarry

public static int subCarry(int result,
                           int src1,
                           int src2)
This method is used to determine if a sub carry has occurred. This is done by checking the signs of the source operands against the sign of the result.

Parameters:
result - The result of the operation on the src1 and src2 parameters.
src1 - The first source operand.
src2 - The second source operand.
Returns:
This method returns a one if a carry was detected and a zero otherwise.

sign

public static int sign(int a)
This method returns the sign bit for 32 bit value.

Parameters:
a - The 32 bit value.
Returns:
This method returns the sign bit for 32 bit value.

rotateLeft

public static int rotateLeft(int a,
                             int r)
This method rotates the value a left by r. The value r should be between 0 and 31. The result is undefined for other values of r.

Parameters:
a - the value to be rotated left.
r - The number of bits to left rotate.
Returns:
this method returns the value a left rotated by r bits.