|
||||||||||
| 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.tools.AutoModel
public abstract class AutoModel
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 up to 64 bits with maximum field sizes of 32 bits.
Copyright (c) 2006 Cmpware, Inc. All Rights Reserved.
| Nested Class Summary | |
|---|---|
static interface |
AutoModel.Asm
This class defines an assembler function. |
static class |
AutoModel.Decode
The Decode class describes a field / value pair used to decode an instruction. |
static class |
AutoModel.Field
This class defines an instruction field. |
static class |
AutoModel.Format
The format class describes an instruction format. |
static interface |
AutoModel.Function
This class defines the function of an operation. |
static class |
AutoModel.Instruction
The instruction class describes an instruction in the processor. |
static class |
AutoModel.Symbol
This class defines a symbol. |
| Field Summary | |
|---|---|
static java.lang.String |
copyright
Copyright string |
protected long |
currentInstr
The current instruction |
protected AutoModel.Instruction |
currentInstrType
The current instruction type |
protected int[] |
instructionSizes
The different instruction sizes (in bits) |
protected static boolean |
TRACE
Set this to true to get debug / trace printouts |
| 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 | |
|---|---|
AutoModel()
|
|
| Method Summary | |
|---|---|
void |
advancePC()
This method advances the Program Counter. |
void |
asmFixup(java.lang.String[] tokens,
AutoModel.Instruction instr)
This method permits one last chance to manipulate the instruction word before the bits are written out to a file in AsmTool. |
static int |
bitsToBytes(int a)
This routine converts a bit count to a byte count, where the byte count is the minimum number of bytes to hold this many bits. |
static java.lang.String[] |
concatenate(java.lang.String[] a,
java.lang.String[] b)
This method concatenates two arrays of strings. |
java.lang.String |
dasm(byte[] instr)
This method disassembles an instruction. |
java.lang.String |
dasm(long instrData,
AutoModel.Instruction instr)
This method disassembles an instruction. |
void |
dasmFixup(long instrData,
AutoModel.Instruction instr)
This method can be overloaded to fix up any problems or to do any clean-up in the disassembler. |
int |
decode(int instr)
A unique code identifying the instruction is returned by this method. |
void |
defineInstructions(AutoModel.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. |
void |
fetch()
This method fetches an instruction from memory and updates the currentInstr and prevInstr. |
long |
fetch(int addr,
int bytes)
This method returns a long (64-bit) value based on the data at 'bytes' bytes of memory at address 'addr'. |
byte[] |
getInstruction(int addr)
This method fetches an instruction from memory. |
AutoModel.Instruction[] |
getInstructions()
This method returns an array of Instruction objects, defining all of the instructions in the instruction set. |
int[] |
getInstructionSizes()
This method returns an array of integers containing the different instruction sizes in the model. |
int |
getPC()
This method returns the current Program Counter. |
static java.lang.String[] |
getSymbolNames(AutoModel.Symbol[] symbols)
This method takes in a symbol table and returns an array of strings. |
AutoModel.Instruction |
instrMatch(long instr,
int bits)
This method returns the instruction object from the instruction table associated with a given instruction. |
static void |
main(AutoModel am,
java.lang.String[] args)
This is the main program which is used to assemble / disassemble from the command line. |
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. |
void |
setPC(int i)
This method sets the current Program Counter. |
static int |
signExtend(int a,
int bits)
This method is used to take a value 'a' of bit length 'bits' and sign extend it, making it a proper signed integer value. |
static long |
signExtend(long a,
int bits)
This method is used to take a value 'a' of bit length 'bits' and sign extend it, making it a proper signed integer value. |
static java.lang.String |
toHexString(byte[] b)
This method converts a byte array to a hexaecimal string. |
static java.lang.String |
toHexString(byte[] b,
int offset,
int byteCount)
This method returns a string representation of a portion of a byte array in hexadecimal. |
static long |
toLong(byte[] b,
boolean endian)
This method converts a byte array to a long. |
void |
traceOff()
This method turns on tracing for model debug. |
void |
traceOn()
This method turns on tracing for model debug. |
| 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
protected AutoModel.Instruction currentInstrType
protected long currentInstr
protected static boolean TRACE
| Constructor Detail |
|---|
public AutoModel()
| Method Detail |
|---|
public static void main(AutoModel am,
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(AutoModel.Instruction[] instructions)
instructions - the instruction data tables.
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 setPC(int i)
Processor
setPC in class Processorpublic int getPC()
Processor
getPC in class Processorpublic java.lang.String dasm(byte[] instr)
Processor
dasm in class Processorinstr - The instruction to be disassembled.
public void fetch()
throws MemoryAccessException
Processor
fetch in class ProcessorMemoryAccessException
public byte[] getInstruction(int addr)
throws MemoryAccessException
Processor
getInstruction in class Processoraddr - The address at which to fetch the
instruction.
MemoryAccessExceptionpublic void advancePC()
Processor
advancePC in class Processorpublic AutoModel.Instruction[] getInstructions()
public java.lang.String dasm(long instrData,
AutoModel.Instruction instr)
instrData - The instruction to be diassembled.instr - The description of the instruction to
be diassembled.
public void asmFixup(java.lang.String[] tokens,
AutoModel.Instruction instr)
tokens - The original string tokens from the instruction.instr - The instruction.
public void dasmFixup(long instrData,
AutoModel.Instruction instr)
instrData - The instruction to be diassembled.instr - The description of the instruction to
be diassembled.
public void preExecute(int instr)
throws MemoryAccessException,
IllegalRegisterException,
IllegalOpcodeException
instr - The instruction
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 postExecute(int instr)
throws MemoryAccessException,
IllegalRegisterException,
IllegalOpcodeException
instr - The instruction
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 AutoModel.Instruction instrMatch(long instr,
int bits)
instr - the instruction data.bits - the number of bits in the instruction.
public int[] getInstructionSizes()
public long fetch(int addr,
int bytes)
throws MemoryAccessException
addr - The address of the fetch.bytes - The number of bytes in the fetch.
MemoryAccessException - when an attempt is
made to access an illegal memory address.public static java.lang.String[] getSymbolNames(AutoModel.Symbol[] symbols)
symbols - An array of Symbols.
public static int signExtend(int a,
int bits)
a - The value to be sign extended.bits - the number of bits in the input value.
public static long signExtend(long a,
int bits)
a - The value to be sign extended.bits - the number of bits in the input value.
public static int bitsToBytes(int a)
a - The number of bits.
public static java.lang.String toHexString(byte[] b)
b - the byte array
public static java.lang.String toHexString(byte[] b,
int offset,
int byteCount)
b - The byte arrayoffset - The offset into the byte array of
the start of data.byteCount - The number of bytes to be returned as
a hexidecimal string.
public static java.lang.String[] concatenate(java.lang.String[] a,
java.lang.String[] b)
a - the first array of strings.b - the second array of strings.
public static long toLong(byte[] b,
boolean endian)
b - The byte array. If this araray is longer
than eight bytes, the result is undefined.endian - The endian of the memory.
public void traceOn()
public void traceOff()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||