com.cmpware.tools
Class AutoModelVLIW

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

public abstract class AutoModelVLIW
extends Processor

WARNING: This class contains experimental software for architectures with instructrion words greater than 32 bits. Contact Cmpware, Inc. for more information on the proper use of this class.

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

Author:
SAG

Nested Class Summary
static class AutoModelVLIW.Decode
          The Decode class describes a field / value pair used to decode an instruction.
static class AutoModelVLIW.Field
          This class defines an instruction field.
static class AutoModelVLIW.Format
          The format class describes an instruction format.
static interface AutoModelVLIW.Function
          This class defines the function of an operation.
static class AutoModelVLIW.Instruction
          The instruction class describes an instruction in the processor.
static class AutoModelVLIW.Symbol
          This class defines a symbol.
 
Field Summary
static java.lang.String copyright
          Copyright string
 
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
AutoModelVLIW()
           
 
Method Summary
 void asmFixup(java.lang.String[] tokens, AutoModelVLIW.Field[] fields, java.math.BigInteger[] values)
          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.
 java.lang.String dasm(java.math.BigInteger instrData, AutoModelVLIW.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 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.
 byte[] getInstruction(int addr)
          This method fetches an instruction from memory.
static java.lang.String[] getInstructionNames(AutoModelVLIW.Instruction[] instructions)
          This method takes in a instruction table and returns an array of strings.
abstract  AutoModelVLIW.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(AutoModelVLIW.Symbol[] symbols)
          This method takes in a symbol table and returns an array of strings.
 AutoModelVLIW.Instruction instrMatch(java.math.BigInteger instr, int bits)
          This method returns the instruction object from the instruction table associated with a given instruction.
static void main(AutoModelVLIW 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 setInstructions(AutoModelVLIW.Instruction[] instructions)
          This method is used to pass the instruction data tables to the AutoModel.
 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 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.
 
Methods inherited from class com.cmpware.cmp.Processor
advancePC, 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, reset, 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
Constructor Detail

AutoModelVLIW

public AutoModelVLIW()
Method Detail

main

public static void main(AutoModelVLIW am,
                        java.lang.String[] args)
This is the main program which is used to assemble / disassemble from the command line.

Parameters:
args - The command line args. Should be a flag ("-asm" of "-dasm") followed by an input filename and an output filename (three strings).

setInstructions

public void setInstructions(AutoModelVLIW.Instruction[] instructions)
This method is used to pass the instruction data tables to the AutoModel. It is not called as a constructor but should probably be called early in the subclass constructor.

Parameters:
instructions - the instruction data tables.

getInstructions

public abstract AutoModelVLIW.Instruction[] getInstructions()
This method returns an array of Instruction objects, defining all of the instructions in the instruction set.

Returns:
This method returns an array of Instruction objects, defining all of the operations in the instruction set.

decode

public int decode(int instr)
           throws IllegalOpcodeException
Description copied from class: Processor
A unique code identifying the instruction is returned by this method. In some processors with simple fixed-field opcodes this may be a very simple method to define. Other architectures with more complex decoding will require a more complex implementation.

Specified by:
decode in class Processor
Parameters:
instr - The instruction to be decoded.
Returns:
A unique code identifying the instruction is returned by this method.
Throws:
IllegalOpcodeException - if an illegal opcode is encountered.

execute

public void execute(int instr)
             throws MemoryAccessException,
                    IllegalRegisterException,
                    IllegalOpcodeException
Description copied from class: Processor
This method is called after the fetch() and decode() and represents the execution phase of the instruction. All update of processor state occurs in this method. This is where most of the processor definition will occur. See examples for suggestions on implementation of this method.

Specified by:
execute in class Processor
Parameters:
instr - The instruction to be executed.
Throws:
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).

setPC

public void setPC(int i)
Description copied from class: Processor
This method sets the current Program Counter.

Specified by:
setPC in class Processor

getPC

public int getPC()
Description copied from class: Processor
This method returns the current Program Counter.

Specified by:
getPC in class Processor
Returns:
This method returns the current Program Counter.

dasm

public java.lang.String dasm(byte[] instr)
Description copied from class: Processor
This method disassembles an instruction. Note that a byte array is provided as the interface. This is to make this method as generic as possible.

Specified by:
dasm in class Processor
Parameters:
instr - The instruction to be disassembled.
Returns:
This method returns the disassembled instruction.

fetch

public void fetch()
           throws MemoryAccessException
Description copied from class: Processor
This method fetches an instruction from memory and updates the currentInstr and prevInstr. Note that breakpoints are taken into account. If the previous instruction executed was a breakpoint, the actual instruction is fetched from the saved value in the breakpoint table.

Overrides:
fetch in class Processor
Throws:
MemoryAccessException

getInstruction

public byte[] getInstruction(int addr)
                      throws MemoryAccessException
Description copied from class: Processor
This method fetches an instruction from memory. Note that breakpoints are taken into account. If the instruction is a breakpoint, the actual instruction is fetched from the saved value in the breakpoint table. Note that this is generally for off-line use and not a replacement for the fetch() method.

Overrides:
getInstruction in class Processor
Parameters:
addr - The address at which to fetch the instruction.
Throws:
MemoryAccessException

dasm

public java.lang.String dasm(java.math.BigInteger instrData,
                             AutoModelVLIW.Instruction instr)
This method disassembles an instruction.

Parameters:
instrData - The instruction to be diassembled.
instr - The description of the instruction to be diassembled.
Returns:
This method returns a string representing the current instruction.

asmFixup

public void asmFixup(java.lang.String[] tokens,
                     AutoModelVLIW.Field[] fields,
                     java.math.BigInteger[] values)
This method permits one last chance to manipulate the instruction word before the bits are written out to a file in AsmTool. Overload this method to do any final fixups. Note that typically only the values[] array should be modified.

Parameters:
tokens - The original string tokens from the instruction.
fields - The fields associated with each token.
values - The numeric values for each field.

preExecute

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

Parameters:
instr - The instruction

postExecute

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

Parameters:
instr - The instruction

instrMatch

public AutoModelVLIW.Instruction instrMatch(java.math.BigInteger instr,
                                            int bits)
This method returns the instruction object from the instruction table associated with a given instruction.

Parameters:
instr - the instruction data.
bits - the number of bits in the instruction.
Returns:
This method returns the instruction object from the instruction table associated with a given instruction.

getInstructionSizes

public int[] getInstructionSizes()
This method returns an array of integers containing the different instruction sizes in the model. The values are in bits.

Returns:
This method returns an array of integers containing the different instruction sizes in the model. The values are in bits.

getSymbolNames

public static java.lang.String[] getSymbolNames(AutoModelVLIW.Symbol[] symbols)
This method takes in a symbol table and returns an array of strings. Note that for symbols which may map to two or more values, the last entry in the table for that value is the string returned. This is useful for getting an array of strings used in defineRegisterNames().

Parameters:
symbols - An array of Symbols.
Returns:
this method returns an array of strings representing the symbols.

getInstructionNames

public static java.lang.String[] getInstructionNames(AutoModelVLIW.Instruction[] instructions)
This method takes in a instruction table and returns an array of strings. This is useful for getting an array of strings used in defineOpcodeNames().

Parameters:
instructions - An array of Instructions.
Returns:
this method returns an array of strings representing the opcode names.

signExtend

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

Parameters:
a - The value to be sign extended.
bits - the number of bits in the input value.
Returns:
this method returns the value a, signed extended for a given number of bits.

bitsToBytes

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

Parameters:
a - The number of bits.
Returns:
This method returns the number of bytes necessary to hold the number of bits in the input parameter.

toHexString

public static java.lang.String toHexString(byte[] b)
This method converts a byte array to a hexaecimal string.

Parameters:
b - the byte array
Returns:
This method converts a byte array to a hexaecimal string.

toHexString

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

Parameters:
b - The byte array
offset - The offset into the byte array of the start of data.
byteCount - The number of bytes to be returned as a hexidecimal string.
Returns:
This method returns a string representation of a portion of a byte array in hexadecimal.