|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.cmpware.cmp.Memory
com.cmpware.cmp.Processor
public abstract class Processor
This implements the generic processor interface and mechanisms. Note that this model assumes fixed length instructions. For variable length instructions, or a simpler interface, see AutoModel.
Copyright (c) 2004, 2005, 2006 Cmpware, Inc. All Rights Reserved.
| Field Summary | |
|---|---|
protected byte[] |
bkpt
The breakpoint instruction |
protected int |
branchAddr
The branch address |
protected int |
branchDelay
The branch delay slot size |
protected boolean |
breakpointHit
The Breakpoint hit flag |
static java.lang.String |
copyright
Copyright string |
protected int |
currentBranchDelay
The current branch delay value |
protected int |
currentInstr
The current instruction |
protected int |
currentInstrCode
The current instruction code |
protected long |
cycleCount
The cycle count |
protected Elf |
elf
The most recently loaded ELF file |
protected float |
idlePower
The power consumption while the processor is idle (mW) |
protected int[] |
iMix
The instruction mix |
protected int |
instructionSize
The instruction size (in bytes) |
protected java.lang.String |
name
The processor name |
protected byte[] |
noop
The noop instruction |
protected java.lang.String[] |
opcodeName
The Opcode names |
protected int |
pc
The current Program Counter (cached from getPC()) |
protected int |
prevInstr
The previous instruction |
protected int |
prevInstrCode
The previous instruction code |
protected int[] |
r
The General Purpose register set |
protected java.lang.String[] |
regName
The General Purpose Register names |
protected float |
runningPower
The power consumption while the processor is running (mW) |
protected int[] |
sr
The special purpose register set |
protected java.lang.String[] |
sregName
The Special Purpose Register names |
protected boolean |
stall
The stall flag |
protected long |
stallCount
The Stall cycle count |
| Fields inherited from class com.cmpware.cmp.Memory |
|---|
BIG, LITTLE |
| Constructor Summary | |
|---|---|
Processor()
|
|
| Method Summary | |
|---|---|
void |
advancePC()
This method advances the Program Counter. |
void |
branch(int branchAddr)
This method should be called whenever an instruction branches. |
void |
branchNoDelay(int branchAddr)
This method should be called whenever an instruction branches and the delay slot is not executed. |
abstract java.lang.String |
dasm(byte[] instr)
This method disassembles an instruction. |
abstract int |
decode(int instr)
A unique code identifying the instruction is returned by this method. |
void |
defineBranchDelay(int d)
This method defines the size of the branch delay slot. |
void |
defineBreakpoint(byte[] bkpt)
This method defines the code used as a breakpoint. |
void |
defineInstructionSize(int instructionSize)
This method defines the instruction size, in bytes. |
void |
defineName(java.lang.String name)
This method defines a sinple string identifying the processor. |
void |
defineNoop(byte[] n)
This method defines the code used as a noop. |
void |
defineOpcodeNames(java.lang.String[] opcodeName)
This method defines the opcode names used by the processor. |
void |
defineRegisterNames(java.lang.String[] regName)
This method defines the general purpose register names used by the processor. |
void |
defineRegisters(int i)
This method defines the number of the general purpose registers used by the processor. |
void |
defineSpecialRegisterNames(java.lang.String[] sregName)
This method defines the special purpose register names used by the processor. |
void |
defineSpecialRegisters(int i)
This method defines the number of the special purpose registers used by the processor. |
abstract void |
execute(int instr)
This method is called after the fetch() and decode() and represents the execution phase of the instruction. |
void |
fetch()
This method fetches an instruction from memory and updates the currentInstr and prevInstr. |
static Processor |
get(java.lang.String processorName)
This static method is used to return a newly allocated Processor object from the processor name string. |
byte[] |
getBreakpoint()
This method returns the code used as a breakpoint. |
byte[] |
getBreakpointData(int addr)
This method returns the byte array that was replaced by the breakpoint. |
int[] |
getBreakpoints()
This method returns an array of Integer objects that give the addresses of all set breakpoints. |
long |
getCycleCount()
This method returns the current cycle count. |
int[] |
getDebugRegisters()
This method returns the current values of all of the general purpose registers as they are used by a debugger. |
Elf |
getElf()
This method returns the most recently loaded ELF file. |
float |
getIdlePower()
This method returns the power consumption in mW of the processor while idle (stalled). |
byte[] |
getInstruction(int addr)
This method fetches an instruction from memory. |
int[] |
getInstructionMix()
This method returns an array of integers giving the instruction mix. |
int |
getInstructionSize()
This method returns the instruction size in bytes. |
java.lang.String |
getName()
This method returns a simple string identifying the processor. |
byte[] |
getNoop()
This method returns the code used as a NOOP. |
java.lang.String[] |
getOpcodeNames()
This method returns the names of all of the opcodes. |
abstract int |
getPC()
This method returns the current Program Counter. |
int |
getRegister(int i)
This method returns a general purpose register. |
java.lang.String[] |
getRegisterNames()
This method returns the names of all of the General Purpose registers. |
int[] |
getRegisters()
This method returns the current values of all of the general purpose registers. |
float |
getRunningPower()
This method returns the power consumption in mW of the processor while running. |
int |
getSpecialRegister(int i)
This method returns a Special Purpose register. |
java.lang.String[] |
getSpecialRegisterNames()
This method returns the names of all of the special purpose registers. |
int[] |
getSpecialRegisters()
This method returns the current values of all of the special purpose registers. |
long |
getStallCount()
This method returns the current stall cycle count. |
boolean |
isBreakpoint(int addr)
This method returns true if the address contains a breakpoint and a false otherwise. |
boolean |
isStalled()
This method returns the current stall state of the processor. |
void |
load(Elf elf,
int offset)
This method loads the memory of the processor with data from the ELF file. |
void |
postLoad()
This method it used to perform any operations that may be required after a file is loaded. |
void |
removeAllBreakpoints()
This method removes all breakpoints. |
void |
removeBreakpoint(int addr)
This method removes a breakpoint. |
void |
reset()
This method resets the processor. |
void |
setBreakpoint(int addr)
This method sets a breakpoint. |
void |
setIdlePower(float idlePower)
This method sets the power consumption in mW of the processor while idle (stalled). |
abstract void |
setPC(int pc)
This method sets the current Program Counter. |
void |
setRegister(int i,
int a)
This method sets a general purpose register. |
void |
setRunningPower(float runningPower)
This method returns the power consumption in mW of the processor while running. |
void |
setSpecialRegister(int i,
int a)
This method sets a special purpose register. |
void |
stall()
This method is used to stall the processor. |
void |
statistics()
This method keeps various statistics about the most recently exercuted instruction. |
void |
step(long globalCycleCount)
This method steps the simulation one cycle. |
| 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 |
|---|
public static final java.lang.String copyright
protected boolean breakpointHit
protected java.lang.String name
protected int instructionSize
protected int branchDelay
protected int currentBranchDelay
protected int branchAddr
protected boolean stall
protected long cycleCount
protected long stallCount
protected int[] iMix
protected java.lang.String[] regName
protected java.lang.String[] sregName
protected java.lang.String[] opcodeName
protected byte[] bkpt
protected byte[] noop
protected int currentInstr
protected int prevInstr
protected int currentInstrCode
protected int prevInstrCode
protected int pc
protected float idlePower
protected float runningPower
protected int[] r
protected int[] sr
protected Elf elf
| Constructor Detail |
|---|
public Processor()
| Method Detail |
|---|
public abstract int decode(int instr)
throws IllegalOpcodeException,
MemoryAccessException
instr - The instruction to be decoded.
IllegalOpcodeException - if an illegal opcode
is encountered.
MemoryAccessException - A Memory Access
Exception is thrown is an illegal memory
access is attempted.
public abstract void execute(int instr)
throws MemoryAccessException,
IllegalRegisterException,
IllegalOpcodeException
instr - The instruction to be executed.
MemoryAccessException - A Memory Access
Exception is thrown is an illegal memory
access is attempted.
IllegalRegisterException - if an attempt is made
to access a register illegally.
IllegalOpcodeException - is added for models
which may combine decode and execute in the
same method (such as AutoModel).public abstract int getPC()
public abstract void setPC(int pc)
public abstract java.lang.String dasm(byte[] instr)
instr - The instruction to be disassembled.
public void defineName(java.lang.String name)
name - The processor name.public java.lang.String getName()
public void defineInstructionSize(int instructionSize)
instructionSize - The instruction size, in bytes.public int getInstructionSize()
public void defineRegisters(int i)
i - The number of general purpose registers.public void defineRegisterNames(java.lang.String[] regName)
regName - An array of strings representing the General
Purpose Register names.public java.lang.String[] getRegisterNames()
public int[] getRegisters()
public int[] getDebugRegisters()
public void setRegister(int i,
int a)
throws IllegalRegisterException
i - The index of the general purpose register
to set.a - The value to set the register to.
IllegalRegisterException - if an attempt is made
to access a register illegally.
public int getRegister(int i)
throws IllegalRegisterException
i - The index of the general purpose register
to get.
IllegalRegisterException - if an attempt is made
to access a register illegally.public void defineSpecialRegisters(int i)
i - The number of special purpose registers.public void defineSpecialRegisterNames(java.lang.String[] sregName)
sregName - An array of strings representing the
Special Purpose Register names.public java.lang.String[] getSpecialRegisterNames()
public int[] getSpecialRegisters()
public void setSpecialRegister(int i,
int a)
throws IllegalRegisterException
i - The index of the special purpose register
to set.a - The value to set the register to.
IllegalRegisterException - if an attempt is made
to access a register illegally.
public int getSpecialRegister(int i)
throws IllegalRegisterException
i - The index of the special purpose register
to get.
IllegalRegisterException - if an attempt is made
to access a register illegally.public void defineOpcodeNames(java.lang.String[] opcodeName)
opcodeName - An array of strings representing the
opcode names.public java.lang.String[] getOpcodeNames()
public void defineBreakpoint(byte[] bkpt)
bkpt - The breakpoint instruction.public byte[] getBreakpoint()
public void defineNoop(byte[] n)
n - The noop instruction.public byte[] getNoop()
public void defineBranchDelay(int d)
d - The size of the branch delay slot.public long getCycleCount()
public long getStallCount()
public int[] getInstructionMix()
public float getIdlePower()
public void setIdlePower(float idlePower)
public float getRunningPower()
public void setRunningPower(float runningPower)
public void fetch()
throws MemoryAccessException
a - Memory Access Exception is thrown if the
fetch is to an illegal memory address.
MemoryAccessException
public byte[] getInstruction(int addr)
throws MemoryAccessException
addr - The address at which to fetch the
instruction.
a - Memory Access Exception is thrown if the
fetch is to an illegal memory address.
MemoryAccessException
public void step(long globalCycleCount)
throws MemoryAccessException,
IllegalOpcodeException,
IllegalRegisterException,
BreakpointException
globalCycleCount - This is the clock cycle as
maintained by the multiprocessor. If the
processor itself has gotten ahead of this value
this method simply returns. The local cycle count
should never be less than the global cycle count.
A - Memory Access Exception is thrown is an
illegal memory access is attempted.
A - Memory Access Exception is thrown is an
illegal memory access is attempted.
MemoryAccessException - A Memory Access
Exception is thrown is an illegal memory
access is attempted.
IllegalOpcodeException - if an attempt is made
to execute an illegal opcode.
IllegalRegisterException - if an attempt is made
to access a register illegally.
BreakpointException - if a breakpoint is encountered
on this cycle.public void advancePC()
public void reset()
public void stall()
public boolean isStalled()
public void statistics()
public void branch(int branchAddr)
branchAddr - The branch address.public void branchNoDelay(int branchAddr)
branchAddr - The branch address.
public void setBreakpoint(int addr)
throws MemoryAccessException
addr - The address at which to set the breakpoint.
MemoryAccessException - if an attempt is bade to
set a breakpoint at an illegal memory address.public void removeBreakpoint(int addr)
addr - The address of the breakpoint.public int[] getBreakpoints()
public void removeAllBreakpoints()
public boolean isBreakpoint(int addr)
addr - The address of the breakpoint.
public byte[] getBreakpointData(int addr)
addr - The address of the breakpoint.
public void load(Elf elf,
int offset)
throws MemoryAccessException
elf - The ELF data to be loaded.offset - The address at which to load a non-ELF
(raw binary) file. This parameter is ignored
for data in proper ELF format.
MemoryAccessException - if an attempt is made to
illegally access memory.public Elf getElf()
public void postLoad()
public static Processor get(java.lang.String processorName)
throws ProcessorException
processorName - The name of the processor. This is the class
name of the Link class file under com.cmpware.cmp.models.
ProcessorException - if any problems we encountered
allocating the new Processorobject.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||