com.cmpware.cmp.models
Class MIPS32

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.MIPS32
All Implemented Interfaces:
ReadWriteInterface
Direct Known Subclasses:
MIPS32EX

public class MIPS32
extends AutoModel

This is an AutoModel implementation of the MIPS32 processor.

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

Author:
SAG

Nested Class Summary
(package private) static class MIPS32.SREG
          This class defines the Special Register indicies
 
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
protected static AutoModel.Field f_imm16
           
protected static AutoModel.Field f_imm26
           
protected static AutoModel.Field f_rd
           
protected static AutoModel.Field f_rs
           
protected static AutoModel.Field f_rt
           
protected static AutoModel.Field f_sa
           
protected  int imm16
          The zero-extended 16-bit immediate data
protected static AutoModel.Format immediate
           
protected  int instrIndex
          The lower 28-bits of jump target address (shifted right 2)
protected static AutoModel.Format jump
           
protected static AutoModel.Field op
           
protected static AutoModel.Field op2
           
protected  int rd
          The value in the 'd' register
protected static AutoModel.Format regToReg
           
protected static AutoModel.Format regToReg2
           
protected  int rs
          The value in the 's' register
protected  int rt
          The value in the 't' register
protected  int sa
          The value in the 'sa' value
protected  int simm16
          The sign-extended 16-bit immediate data
 
Fields inherited from class com.cmpware.tools.AutoModel
copyright, 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
MIPS32()
          The constructor
 
Method Summary
protected static int addCarry(int src1, int src2, int result)
          This method is used to determine if an add carry has occurred.
protected static boolean isAddOverflow(int result, int src1, int src2)
          This method is used to determine if an add overflow has occurred.
protected static boolean isSubOverflow(int src1, int src2, int result)
          This method is used to determine if a sub overflow has occurred.
static void main(java.lang.String[] args)
          This enables the stand-alone assembler and disassembler.
 void postExecute(int instr)
          This method is called immediately after execution and may be overloaded to do things like save instruction field values to locals.
 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.
protected static AutoModel.Decode regimm(int a)
          This is just a simple helper function used in decoding 'Regimm' instructions.
 void reset()
          This method resets the processor.
protected static int sign(int a)
          This method returns the sign bit for 32 bit value.
protected static AutoModel.Decode simple(int a)
          This is a helper function used in decoding simple instructions.
protected static AutoModel.Decode special(int a)
          This is just a simple helper function used in decoding 'Special' instructions.
protected static AutoModel.Decode special2(int a)
          This is just a simple helper function used in decoding 'Special2' instructions.
protected static int subCarry(int src1, int src2, int result)
          This method is used to determine if a sub carry 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, 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, getRegisters, 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

rs

protected int rs
The value in the 's' register


rd

protected int rd
The value in the 'd' register


rt

protected int rt
The value in the 't' register


sa

protected int sa
The value in the 'sa' value


imm16

protected int imm16
The zero-extended 16-bit immediate data


simm16

protected int simm16
The sign-extended 16-bit immediate data


instrIndex

protected int instrIndex
The lower 28-bits of jump target address (shifted right 2)


op

protected static final AutoModel.Field op

f_sa

protected static final AutoModel.Field f_sa

f_rd

protected static final AutoModel.Field f_rd

f_rt

protected static final AutoModel.Field f_rt

f_rs

protected static final AutoModel.Field f_rs

f_imm16

protected static final AutoModel.Field f_imm16

op2

protected static final AutoModel.Field op2

f_imm26

protected static final AutoModel.Field f_imm26

regToReg

protected static final AutoModel.Format regToReg

regToReg2

protected static final AutoModel.Format regToReg2

immediate

protected static final AutoModel.Format immediate

jump

protected static final AutoModel.Format jump
Constructor Detail

MIPS32

public MIPS32()
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 MIPS32 -dasm or java MIPS32 -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

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

postExecute

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

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

isAddOverflow

protected static boolean isAddOverflow(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.

isSubOverflow

protected static boolean isSubOverflow(int src1,
                                       int src2,
                                       int result)
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:
src1 - The first source operand.
src2 - The second source operand.
result - The result of the operation on the src1 and src2 parameters.
Returns:
This method returns a true if an overflow was detected and a false otherwise.

addCarry

protected static int addCarry(int src1,
                              int src2,
                              int result)
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:
src1 - The first source operand.
src2 - The second source operand.
result - The result of the operation on the src1 and src2 parameters.
Returns:
This method returns a one if a carry was detected and a zero otherwise.

subCarry

protected static int subCarry(int src1,
                              int src2,
                              int result)
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:
src1 - The first source operand.
src2 - The second source operand.
result - The result of the operation on the src1 and src2 parameters.
Returns:
This method returns a one if a carry was detected and a zero otherwise.

sign

protected 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.

simple

protected static AutoModel.Decode simple(int a)
This is a helper function used in decoding simple instructions. It mostly makes the Instruction table easier to read.

Parameters:
a - The code for the op field.
Returns:
This method returns a decode array for a simple instruction.

special

protected static AutoModel.Decode special(int a)
This is just a simple helper function used in decoding 'Special' instructions. It mostly just makes the Instruction table easier to read.

Parameters:
a - The code for the op2 field.
Returns:
This method returns a decode array for a 'Special' instruction.

special2

protected static AutoModel.Decode special2(int a)
This is just a simple helper function used in decoding 'Special2' instructions. It mostly just makes the Instruction table easier to read.

Parameters:
a - The code for the op2 field.
Returns:
This method returns a decode array for a 'Special' instruction.

regimm

protected static AutoModel.Decode regimm(int a)
This is just a simple helper function used in decoding 'Regimm' instructions. It mostly just makes the Instruction table easier to read.

Parameters:
a - The code for the rt field.
Returns:
This method returns a decode array for a 'Special' instruction.