com.cmpware.cmp.models
Class SPU

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

public class SPU
extends AutoModel

This is an AutoModel implementation of the Synergistic Processing Unit (SPU) used by the Cell broadband Engine. The information used to creat this model was taken from the IBM document: "The Synergistic Processing Unit Instruction Set Architecture", Version 1.1 (January 30, 2005).

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

Author:
SAG

Nested Class Summary
static class SPU.ADDR_OFFSET
          The Channel memory map address offsets
static class SPU.CHANNEL
          The Channel port numbers
 
Nested classes/interfaces inherited from class com.cmpware.tools.AutoModel
AutoModel.Asm, AutoModel.Decode, AutoModel.Field, AutoModel.Format, AutoModel.Function, AutoModel.Instruction, AutoModel.Symbol
 
Field Summary
protected static byte[] BREAKPOINT_INSTRUCTION
          The Breakpoint code
protected static int BYTES_PER_REG
          The number of bytes per register
protected  int[] channelAlias
          The channel alias address
protected static int[] computeMask
          The compute mask
static java.lang.String copyright
          Copyright string
protected  boolean externalEvent
          The Exernal Event flag
protected  boolean halt
          The Halt flag
protected  int imm10
          The 10-bit immediate data
protected  int imm26
          The 26-bit immediate data
protected static byte[] NOOP_INSTRUCTION
          The NOOP instruction
protected  int ra
          The value in the 'ra' register
protected  int rb
          The value in the 'rb' register
protected  int rc
          The value in the 'rc' register
protected  java.nio.ByteBuffer regBb
          The Byte Buffer wrapper of the register data
protected  byte[] regData
          The register data as a byte array
protected static int REGS
          The number of registers
protected  int[] regShadow
          The register shadow (to return to the IDE)
protected  int rt
          The value in the 'rt' register
protected  int rt2
          The value in the 'rt' register for RRR instructions
 
Fields inherited from class com.cmpware.tools.AutoModel
currentInstr, currentInstrType, instructionSizes, TRACE
 
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
SPU()
          The constructor
 
Method Summary
protected  java.lang.String channelName(int c)
          This method returns the string associated with a channel.
protected  int clz(byte b)
          This method returns the number of leading zeros in a byte.
protected  int clz(int a)
          This method returns the number of leading zeros in a 32 bit integer.
 int[] getDebugRegisters()
          This method returns the current values of all of the general purpose registers as they are used by a debugger.
 int getPC()
          This method returns the current Program Counter.
 int[] getRegisters()
          This method returns the current values of all of the general purpose registers.
static void main(java.lang.String[] args)
          This enables the stand-alone assembler and disassembler.
protected  int ones(byte b)
          This method returns the number of '1' bits in a byte.
 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.
protected  byte rByte(int reg, int i)
          This method returns a byte from the register file.
protected  int rByteu(int reg, int i)
          This method returns a byte from the register file represented as an unsigned in 32 bit integer format.
protected  double rDouble(int reg, int i)
          This method returns a double from the register file.
 void reset()
          This method resets the processor.
protected  float rFloat(int reg, int i)
          This method returns a float from the register file.
protected  short rHalf(int reg, int i)
          This method returns a half word from the register file.
protected  int rHalfu(int reg, int i)
          This method returns a half word from the register file represented as an unsigned in 32 bit integer format.
protected  int rInt(int reg, int i)
          This method returns an integer from the register file.
protected  long rIntu(int reg, int i)
          This method returns a half word from the register file represented as an unsigned in 64 bit long integer format.
protected  long rLong(int reg, int i)
          This method returns a long word from the register file.
protected  int rotate(int a, int i)
          This method left rotates an integer.
protected  short rotate(short a, int i)
          This method left rotates a half integer.
protected  void setByte(int reg, int i, byte a)
          This method sets a byte in the register file.
 void setChannelAlias(int c, int addr)
          This method is used to keep a list of the channel alias addresses.
protected  void setDouble(int reg, int i, double a)
          This method sets a double int the register file.
protected  void setFloat(int reg, int i, float a)
          This method sets a float int the register file.
protected  void setHalf(int reg, int i, short a)
          This method sets a half word in the register file.
protected  void setInt(int reg, int i, int a)
          This method sets an integer in the register file.
protected  void setLong(int reg, int i, long a)
          This method sets a long in the register file.
 void setPC(int pc)
          This method sets the current Program Counter.
 
Methods inherited from class com.cmpware.tools.AutoModel
advancePC, asmFixup, bitsToBytes, concatenate, dasm, dasm, dasmFixup, decode, defineInstructions, execute, fetch, fetch, getInstruction, getInstructions, getInstructionSizes, getSymbolNames, instrMatch, main, postExecute, signExtend, signExtend, toHexString, toHexString, toLong, traceOff, traceOn
 
Methods inherited from class com.cmpware.cmp.Processor
branch, branchNoDelay, defineBranchDelay, defineBreakpoint, defineInstructionSize, defineName, defineNoop, defineOpcodeNames, defineRegisterNames, defineRegisters, defineSpecialRegisterNames, defineSpecialRegisters, get, getBreakpoint, getBreakpointData, getBreakpoints, getCycleCount, getElf, getIdlePower, 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

BYTES_PER_REG

protected static final int BYTES_PER_REG
The number of bytes per register

See Also:
Constant Field Values

REGS

protected static final int REGS
The number of registers

See Also:
Constant Field Values

regData

protected byte[] regData
The register data as a byte array


regBb

protected java.nio.ByteBuffer regBb
The Byte Buffer wrapper of the register data


regShadow

protected int[] regShadow
The register shadow (to return to the IDE)


ra

protected int ra
The value in the 'ra' register


rb

protected int rb
The value in the 'rb' register


rc

protected int rc
The value in the 'rc' register


rt

protected int rt
The value in the 'rt' register


rt2

protected int rt2
The value in the 'rt' register for RRR instructions


imm10

protected int imm10
The 10-bit immediate data


imm26

protected int imm26
The 26-bit immediate data


halt

protected boolean halt
The Halt flag


externalEvent

protected boolean externalEvent
The Exernal Event flag


computeMask

protected static final int[] computeMask
The compute mask


NOOP_INSTRUCTION

protected static final byte[] NOOP_INSTRUCTION
The NOOP instruction


BREAKPOINT_INSTRUCTION

protected static final byte[] BREAKPOINT_INSTRUCTION
The Breakpoint code


channelAlias

protected int[] channelAlias
The channel alias address

Constructor Detail

SPU

public SPU()
The constructor

Method Detail

main

public static void main(java.lang.String[] args)
This enables the stand-alone assembler and disassembler. The command line should be either: java SPU -dasm or java SPU -asm

Parameters:
args - the command line arguments.

reset

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

Overrides:
reset in class Processor

getRegisters

public int[] getRegisters()
Description copied from class: Processor
This method returns the current values of all of the general purpose registers.

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

getDebugRegisters

public int[] getDebugRegisters()
Description copied from class: Processor
This method returns the current values of all of the general purpose registers as they are used by a debugger. This is added for machines that (for instance) have 128 bit registers of which the debugger only uses 32 bits. This is intended to be overloaded in these situations. This method is used exclusively by debuggers and debugger-like tools.

Overrides:
getDebugRegisters in class Processor
Returns:
This method returns the current values of all of the general purpose registers.

preExecute

public void preExecute(int instr)
Description copied from class: AutoModel
This method is called immediately before execution and may be overloaded to do things like save instruction field values to locals.

Overrides:
preExecute in class AutoModel
Parameters:
instr - The instruction

setPC

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

Overrides:
setPC in class AutoModel

getPC

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

Overrides:
getPC in class AutoModel
Returns:
This method returns the current Program Counter.

rByte

protected byte rByte(int reg,
                     int i)
This method returns a byte from the register file.

Parameters:
reg - the index of the 128-bit register
i - the byte index (should be 0 - 15)
Returns:
This method returns a byte from the register file.

rByteu

protected int rByteu(int reg,
                     int i)
This method returns a byte from the register file represented as an unsigned in 32 bit integer format.

Parameters:
reg - the index of the 128-bit register
i - the byte index (should be 0 - 15)
Returns:
This method returns a byte from the register file represented as an unsigned in 32 bit integer format.

rHalf

protected short rHalf(int reg,
                      int i)
This method returns a half word from the register file.

Parameters:
reg - the index of the 128-bit register
i - the half word index (should be 0 - 7)
Returns:
This method returns a half word from the register file.

rHalfu

protected int rHalfu(int reg,
                     int i)
This method returns a half word from the register file represented as an unsigned in 32 bit integer format.

Parameters:
reg - the index of the 128-bit register
i - the half word index (should be 0 - 7)
Returns:
This method returns a half word from the register file represented as an unsigned in 32 bit integer format.

rInt

protected int rInt(int reg,
                   int i)
This method returns an integer from the register file.

Parameters:
reg - the index of the 128-bit register
i - the integer word index (should be 0 - 3)
Returns:
This method returns an integer from the register file.

rLong

protected long rLong(int reg,
                     int i)
This method returns a long word from the register file.

Parameters:
reg - the index of the 128-bit register
i - the long word index (should be 0 - 1)
Returns:
This method returns a long word from the register file.

rIntu

protected long rIntu(int reg,
                     int i)
This method returns a half word from the register file represented as an unsigned in 64 bit long integer format.

Parameters:
reg - the index of the 128-bit register
i - the half word index (should be 0 - 7)
Returns:
This method returns an integer from the register file represented as an unsigned in 64 bit long integer format.

rFloat

protected float rFloat(int reg,
                       int i)
This method returns a float from the register file.

Parameters:
reg - the index of the 128-bit register
i - the float index (should be 0 - 3)
Returns:
This method returns a float from the register file.

rDouble

protected double rDouble(int reg,
                         int i)
This method returns a double from the register file.

Parameters:
reg - the index of the 128-bit register
i - the double index (should be 0 - 1)
Returns:
This method returns a double from the register file.

setByte

protected void setByte(int reg,
                       int i,
                       byte a)
This method sets a byte in the register file.

Parameters:
reg - the index of the 128-bit register
i - the byte index (should be 0 - 15)
a - the byte value.

setHalf

protected void setHalf(int reg,
                       int i,
                       short a)
This method sets a half word in the register file.

Parameters:
reg - the index of the 128-bit register
i - the half word index (should be 0 - 7)
a - the half word value.

setInt

protected void setInt(int reg,
                      int i,
                      int a)
This method sets an integer in the register file.

Parameters:
reg - the index of the 128-bit register
i - the integer index (should be 0 - 3)
a - the integer value.

setLong

protected void setLong(int reg,
                       int i,
                       long a)
This method sets a long in the register file.

Parameters:
reg - the index of the 128-bit register
i - the long index (should be 0 - 1)
a - the long value.

setFloat

protected void setFloat(int reg,
                        int i,
                        float a)
This method sets a float int the register file.

Parameters:
reg - the index of the 128-bit register
i - the float index (should be 0 - 4)
a - the float value.

setDouble

protected void setDouble(int reg,
                         int i,
                         double a)
This method sets a double int the register file.

Parameters:
reg - the index of the 128-bit register
i - the double index (should be 0 - 4)
a - the double value.

clz

protected int clz(byte b)
This method returns the number of leading zeros in a byte. This number ranges from 0 to 8.

Parameters:
b - the byte value.
Returns:
This method returns the number of leading zeros in a byte.

clz

protected int clz(int a)
This method returns the number of leading zeros in a 32 bit integer. This number ranges from 0 to 32.

Parameters:
a - the integer value.
Returns:
This method returns the number of leading zeros in a 32 bit integer.

ones

protected int ones(byte b)
This method returns the number of '1' bits in a byte.

Parameters:
b - the byte value.
Returns:
This method returns the number of '1' bits in a byte.

rotate

protected short rotate(short a,
                       int i)
This method left rotates a half integer.

Parameters:
a - the half value to be left rotated.
i - the amount to be left rotated.
Returns:
the half value 'a' left rotated by 'i' is returned.

rotate

protected int rotate(int a,
                     int i)
This method left rotates an integer.

Parameters:
a - the integer value to be left rotated.
i - the amount to be left rotated.
Returns:
the integer value 'a' left rotated by 'i' is returned.

setChannelAlias

public void setChannelAlias(int c,
                            int addr)
This method is used to keep a list of the channel alias addresses. For proper synchronization all mailboxes must go through the memory mapped IO (MMIO) mechanism, so we map the ports to adresses.

Parameters:
c - the channel number
addr - the address alias of the channel.

channelName

protected java.lang.String channelName(int c)
This method returns the string associated with a channel.

Parameters:
c - the channel number.
Returns:
This method returns the string associated with a channel.