com.cmpware.ide
Class MpModel

java.lang.Object
  extended by com.cmpware.ide.MpModel
All Implemented Interfaces:
java.util.EventListener, org.eclipse.jface.util.IPropertyChangeListener

public class MpModel
extends java.lang.Object
implements org.eclipse.jface.util.IPropertyChangeListener

This class implements the Eclipse IDE model.

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

Author:
SAG

Nested Class Summary
(package private)  class MpModel.Go
          This class steps the simulation using the Display.syncExec() method to run in the Eclipse IDE thread.
(package private)  class MpModel.Step
          This inner class is used to step in a Timer, Because this is in a differnt thread, it will have to be run under Display syncExec().
 
Field Summary
static int ALLOCATE_EVENT
          An array re-allocate event
static int BREAKPOINT_EVENT
          A breakpoint event
static java.lang.String copyright
          Copyright string
static int MEMORY_CHANGE_EVENT
          A memory change event
static int PROCESSOR_SELECT_EVENT
          A processor selection event
static int PROFILE_CHANGE_EVENT
          A Profile Change event
static int PROFILE_CLEAR_EVENT
          A Profile Clear event
static int RESET_EVENT
          An array reset event
static int STEP_EVENT
          A clock step event
static int UNDEFINED_EVENT
          An undefined event
 
Constructor Summary
MpModel()
           
 
Method Summary
static void addStateChangeListener(IListener l)
          This method adds a state change listener to the model.
static void allocate()
          This method allocates the processor from information stored from the preference pages.
static Processor getCurrentProcessor()
          This method returns the current processor.
static Multiprocessor getMultiprocessor()
          Returns the model's multiprocessor object.
 void go()
          This method starts the simulation.
static void load(Elf elf)
          This method loads an ELF (or binary) file into the memory of the current processor and fires a state change event.
static void loadAll(Elf elf)
          This method loads an ELF (or binary) file into the memory of all of the processors and fires a state change event.
static void notifyStateChangeListeners(int eventType)
          This method is called whenever a state change event occurs.
 void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
           
static void reloadAll()
          This method reloads the most recently loaded ELF (or binary) file into the memory of all of the processors and fires a state change event.
static void removeStateChangeListener(IListener l)
          This method removes a state change listener to the model.
static void reset()
          This method resets the multiprocessor and notifies the state change listeners.
static void setCurrentProcessor(int row, int col)
          This method sets the current processor.
static int step(boolean msg)
          This method steps the multiprocessor by at least the number of cycles in the stepSize parameter.
static void stop(boolean msg)
          This method stops a running simulation.
 
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

UNDEFINED_EVENT

public static final int UNDEFINED_EVENT
An undefined event

See Also:
Constant Field Values

ALLOCATE_EVENT

public static final int ALLOCATE_EVENT
An array re-allocate event

See Also:
Constant Field Values

RESET_EVENT

public static final int RESET_EVENT
An array reset event

See Also:
Constant Field Values

STEP_EVENT

public static final int STEP_EVENT
A clock step event

See Also:
Constant Field Values

MEMORY_CHANGE_EVENT

public static final int MEMORY_CHANGE_EVENT
A memory change event

See Also:
Constant Field Values

PROCESSOR_SELECT_EVENT

public static final int PROCESSOR_SELECT_EVENT
A processor selection event

See Also:
Constant Field Values

BREAKPOINT_EVENT

public static final int BREAKPOINT_EVENT
A breakpoint event

See Also:
Constant Field Values

PROFILE_CLEAR_EVENT

public static final int PROFILE_CLEAR_EVENT
A Profile Clear event

See Also:
Constant Field Values

PROFILE_CHANGE_EVENT

public static final int PROFILE_CHANGE_EVENT
A Profile Change event

See Also:
Constant Field Values
Constructor Detail

MpModel

public MpModel()
Method Detail

step

public static int step(boolean msg)
This method steps the multiprocessor by at least the number of cycles in the stepSize parameter. The actual number of steps may be less if an error is encountered.

Parameters:
msg - Determines whether or not to print a status message. Sometimes you want to step quietly, other times you want to announce a step.
Returns:
The number of error / status messages is returned. Zero indicates a successful step.

reset

public static void reset()
This method resets the multiprocessor and notifies the state change listeners.


load

public static void load(Elf elf)
                 throws MemoryAccessException
This method loads an ELF (or binary) file into the memory of the current processor and fires a state change event.

Parameters:
elf - The ELF file to be loaded.
Throws:
MemoryAccessException - if an attempt is made to write to invalid processor memory.

loadAll

public static void loadAll(Elf elf)
                    throws MemoryAccessException
This method loads an ELF (or binary) file into the memory of all of the processors and fires a state change event.

Parameters:
elf - The ELF file to be loaded.
Throws:
MemoryAccessException - if an attempt is made to write to invalid processor memory.

reloadAll

public static void reloadAll()
                      throws MemoryAccessException
This method reloads the most recently loaded ELF (or binary) file into the memory of all of the processors and fires a state change event.

Throws:
MemoryAccessException - if an attempt is made to write to invalid processor memory.

getCurrentProcessor

public static Processor getCurrentProcessor()
This method returns the current processor.

Returns:
This method returns the current processor.

setCurrentProcessor

public static void setCurrentProcessor(int row,
                                       int col)
This method sets the current processor.

Parameters:
row - the processor row.
col - the processor column.

addStateChangeListener

public static void addStateChangeListener(IListener l)
This method adds a state change listener to the model.

Parameters:
l - The state change listener.

removeStateChangeListener

public static void removeStateChangeListener(IListener l)
This method removes a state change listener to the model.

Parameters:
l - The state change listener.

getMultiprocessor

public static Multiprocessor getMultiprocessor()
Returns the model's multiprocessor object.


propertyChange

public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
Specified by:
propertyChange in interface org.eclipse.jface.util.IPropertyChangeListener

allocate

public static void allocate()
                     throws ProcessorException,
                            NetworkException,
                            LinkException,
                            CustomArrayException,
                            SystemMemoryException
This method allocates the processor from information stored from the preference pages.

Throws:
ProcessorException
NetworkException
LinkException
CustomArrayException
SystemMemoryException

notifyStateChangeListeners

public static void notifyStateChangeListeners(int eventType)
This method is called whenever a state change event occurs. It updates all the state change listeners.

Parameters:
eventType - a code indicating the event type.

stop

public static void stop(boolean msg)
This method stops a running simulation.

Parameters:
msg - Determines whether or not to print a status message. Sometimes you want to stop quietly, other times you want to announce a halt.

go

public void go()
This method starts the simulation.