com.cmpware.cmp.models
Class NIOS

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

public class NIOS
extends Processor

This describes the Altera NIOS 32-bit CPU.

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

Author:
SAG

Field Summary
static java.lang.String copyright
          Copyright string
 
Fields inherited from class com.cmpware.cmp.Processor
bkpt, branchAddr, branchDelay, breakpointHit, currentBranchDelay, currentInstr, currentInstrCode, cycleCount, elf, idlePower, iMix, instructionSize, name, noop, prevInstr, prevInstrCode, r, runningPower, sr, stall, stallCount
 
Fields inherited from class com.cmpware.cmp.Memory
BIG, LITTLE
 
Constructor Summary
NIOS()
          The constructor
 
Method Summary
 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.
 java.lang.String dumpRegisters()
          This method overloads the Processor.dumpRegisters() method.
 void execute(int instr)
          This method is called after the fetch() and decode() and represents the execution phase of the instruction.
 int getPC()
          This method returns the current Program Counter.
 int[] getRegisters()
          This method overrides the standard Processor getRegs() method.
 void reset()
          This method resets the NIOS processor.
 void setPC(int pc)
          This method sets the current Program Counter.
 
Methods inherited from class com.cmpware.cmp.Processor
advancePC, branch, branchNoDelay, defineBranchDelay, defineBreakpoint, defineInstructionSize, defineName, defineNoop, defineOpcodeNames, defineRegisterNames, defineRegisters, defineSpecialRegisterNames, defineSpecialRegisters, fetch, get, getBreakpoint, getBreakpointData, getBreakpoints, getCycleCount, getDebugRegisters, getElf, getIdlePower, getInstruction, getInstructionMix, getInstructionSize, getName, getNoop, getOpcodeNames, getRegister, getRegisterNames, 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

copyright

public static final java.lang.String copyright
Copyright string

See Also:
Constant Field Values
Constructor Detail

NIOS

public NIOS()
The constructor

Method Detail

execute

public void execute(int instr)
             throws MemoryAccessException,
                    IllegalRegisterException
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.

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.

reset

public void reset()
This method resets the NIOS processor. Note that super.reset() must me called to completely intialize the processor.

Overrides:
reset 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.

setPC

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

Specified by:
setPC in class Processor

getRegisters

public int[] getRegisters()
This method overrides the standard Processor getRegs() method. This is because rather than return all of the general purpose registers, we want to return only those visible in the current window. Note that we don't throw an exception because the method we are overloading doesn't (even though it might makes sense here).

Overrides:
getRegisters in class Processor
Returns:
This method returns all of the general purpose registers visible in the current window.

dumpRegisters

public java.lang.String dumpRegisters()
This method overloads the Processor.dumpRegisters() method. This is done because the register windowing in NIOS only allows a subset of the register file to be visible. Note that the implementation is the same as Processor.dumpRegisters(), but that the overloaded NIOS.getRegisters() is used instead of the standard Processor.getRegisters().

This method returns a string representing the General Purpose Registers and their current values. This string is formatted across multiple lines and should be suitable for display in a text-based monitor-style interface.

Returns:
This method returns a string representing the General Purpose Registers and their current values.

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.