|
||||||||||
| 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
com.cmpware.fastmodel.FastModel
public abstract class FastModel
This abstract class is used to describe the instruction set for a processor. This is in turn used to drive other parts of the system, notably the AsmTool and DasmTool which produce a simple assembler and disassembler. This class also extends the Processor class for use in the AutoModel tool. This permits full Cmpware simulation models to be built using the instruction set data. This model supports instruction sizes of arbitrary length with maximum field sizes of 64 bits. Note: breakpoints now stop execution after the instruction has executed. Previous models stopped before the instruction executed. This should have minimal impact on functionality.
Copyright (c) 2008 Cmpware, Inc. All Rights Reserved.
| Field Summary | |
|---|---|
static java.lang.String |
copyright
Copyright string |
protected int[] |
instructionSizes
The different instruction sizes (in bits) |
| 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 | |
|---|---|
FastModel()
|
|
| Method Summary | |
|---|---|
void |
branch(int branchAddr)
This method should be called whenever an instruction branches. |
void |
branch(long branchAddr)
This is a version of the branch() method that takes a long (64-bit) address. |
void |
branchNoDelay(int branchAddr)
This method should be called whenever an instruction branches and the delay slot is not executed. |
void |
branchNoDelay(long branchAddr)
This is a versi0on of the branchNoDelay() method that takes a long (64-bit) address. |
java.lang.String |
dasm(java.math.BigInteger instrData,
Instruction instr)
This method disassembles an instruction. |
java.lang.String |
dasm(byte[] instr)
This method disassembles an instruction. |
int |
decode(int instr)
A unique code identifying the instruction is returned by this method. |
void |
defineInstructions(Instruction[] instructions)
This method is used to pass the instruction data tables to the AutoModel. |
void |
execute(int instr)
This method is called after the fetch() and decode() and represents the execution phase of the instruction. |
Instruction |
fetch(Instruction instr)
This method pre-fetches an instruction. |
int[] |
getBreakpoints()
This method returns an array of Integer objects that give the addresses of all set breakpoints. |
byte[] |
getInstruction(int addr)
This method fetches an instruction from memory. |
Instruction[] |
getInstructions()
This method returns an array of the current instructions used by this model. |
int[] |
getInstructionSizes()
This method returns an array of integers containing the different instruction sizes in the model. |
Instruction |
getNewInstruction(long addr)
This method gets and caches a new instruction. |
int |
getPC()
This method returns the current Program Counter. |
static java.lang.String[] |
getSymbolNames(Symbol[] symbols)
This method takes in a symbol table and returns an array of strings. |
Instruction |
instrMatch(java.math.BigInteger instr,
int bits)
This method returns the instruction object from the instruction table associated with a given instruction. |
boolean |
isBreakpoint(int addr)
This method returns true if the address contains a breakpoint and a false otherwise. |
boolean |
isBreakpoint(long addr)
This method returns true if the address contains a breakpoint and a false otherwise. |
static void |
main(FastModel fm,
java.lang.String[] args)
This is the main program which is used to assemble / disassemble from the command line. |
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 |
removeBreakpoint(long addr)
This method removes a breakpoint. |
void |
reset()
This method resets the processor. |
void |
setBreakpoint(int addr)
This method sets a breakpoint. |
void |
setBreakpoint(long addr)
This method sets a breakpoint. |
void |
setPC(int i)
This method sets the current Program Counter. |
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 int[] instructionSizes
| Constructor Detail |
|---|
public FastModel()
| Method Detail |
|---|
public static void main(FastModel fm,
java.lang.String[] args)
args - The command line args. Should be a flag
("-asm" of "-dasm") followed by an input filename
and an output filename (three strings).public void defineInstructions(Instruction[] instructions)
instructions - the instruction data tables.
public void step(long globalCycleCount)
throws MemoryAccessException,
IllegalOpcodeException,
IllegalRegisterException,
BreakpointException
Processor
step in class ProcessorglobalCycleCount - 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.
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 int decode(int instr)
throws IllegalOpcodeException,
MemoryAccessException
Processor
decode in class Processorinstr - 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 void execute(int instr)
throws MemoryAccessException,
IllegalRegisterException,
IllegalOpcodeException
Processor
execute in class Processorinstr - 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 void branch(int branchAddr)
Processor
branch in class ProcessorbranchAddr - The branch address.public void branch(long branchAddr)
branchAddr - the branch addresspublic void branchNoDelay(int branchAddr)
Processor
branchNoDelay in class ProcessorbranchAddr - The branch address.public void branchNoDelay(long branchAddr)
branchAddr - the branch addresspublic java.lang.String dasm(byte[] instr)
Processor
dasm in class Processorinstr - The instruction to be disassembled.
public void setPC(int i)
Processor
setPC in class Processorpublic int getPC()
Processor
getPC in class Processorpublic void reset()
Processor
reset in class Processorpublic void statistics()
Processor
statistics in class Processorpublic void postLoad()
Processor
postLoad in class Processor
public Instruction instrMatch(java.math.BigInteger instr,
int bits)
instr - the instruction data.bits - the number of bits in the instruction.
public Instruction getNewInstruction(long addr)
throws MemoryAccessException
addr - the address of the instruction.
MemoryAccessException - if an illegal memory acces
is attempted.public int[] getInstructionSizes()
public java.lang.String dasm(java.math.BigInteger instrData,
Instruction instr)
instrData - The instruction to be disassembled.instr - The description of the instruction to
be diassembled.
public void setBreakpoint(long 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 setBreakpoint(int addr)
throws MemoryAccessException
Processor
setBreakpoint in class Processoraddr - 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(long addr)
addr - The address of the breakpoint.public void removeBreakpoint(int addr)
Processor
removeBreakpoint in class Processoraddr - The address of the breakpoint.public int[] getBreakpoints()
Processor
getBreakpoints in class Processorpublic void removeAllBreakpoints()
removeAllBreakpoints in class Processorpublic boolean isBreakpoint(long addr)
addr - The address of the breakpoint.
public boolean isBreakpoint(int addr)
Processor
isBreakpoint in class Processoraddr - The address of the breakpoint.
public byte[] getInstruction(int addr)
throws MemoryAccessException
Processor
getInstruction in class Processoraddr - The address at which to fetch the
instruction.
MemoryAccessExceptionpublic static java.lang.String[] getSymbolNames(Symbol[] symbols)
symbols - An array of Symbols.
public Instruction fetch(Instruction instr)
throws MemoryAccessException
instr - The current instruction. May be null on start-up.
MemoryAccessException - if an attempt is bade to
set a breakpoint at an illegal memory address.public Instruction[] getInstructions()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||