|
The parameter 'state' is defined in the Processor class and may be one of:
State | Meaning |
---|---|
STATE_CLEAR | - The processor has no program loaded |
STATE_LOADED | - A program and associated data is loaded |
STATE_RUNNING | - The processor is running the loaded program |
STATE_STOPPED | - The running program has been stopped |
STATE_HALTED | - The running program terminated unexpectedly |
Normally, a Plugin would respond to the STATE_STOPPED event to update any display at the end of a 'Step' or 'Over' button click, or when 'Stop' is clicked to stop a running simulation. The STATE_HALTED event may occur if a Plugin causes an exception, or a breakpoint is reached.
The message parameter to the processorStateChange method is a text description of the event that has ocurred, and is the same as the messages displayed in the log file when 'Step', 'Over' etc. are clicked. Note however, that this text cannot be relied upon, as internationalisation may change the exact values of message.
Clock Listeners can therefore perform tasks that are exactly synchronised with the processor clock - for instance, a listener could use the information to generate a serial input to the microcontroller. If a Plugin only needs to respond to output from the microcontroller, and can be coded to only change its state when the microcontroller changes its output, then a much more efficient PortListener should be used in the place of a Clock Listener. If however, the Clock Listener preforms functions completely independantly of the output from the microcontroller, a ClockListener should be used with the associated speed penalties.
|
The Prepare method is called when simulation is about to start. Note that the clock count may change between simulation runs, so the prepare method may need to restart any internal timers with the new value.
|
The Reset method is called when the processor is reset, and is equivalent to a power on reset for the device. Note that this method is not necessarily called when the clock listener is first created.
|
The clock event method is called after each instruction is simulated. Note
that the chained clock listener interface requires that at the start of
this method, the next listener in the chain is called. As the ChainedClockListener
is defined as an interface, the implementation is up to the author of the
plugin, but code much like that shown here should be used. This assumes
that a variable 'nextListener
' of type 'ClockListener
'
is declared in the Plugin class, and set by the following method:
|
When a ChainedClock listener is added to the MachineState so that it can respond to clock events, the MachineState will immediately call setNext to inform the listener of the next ClockListener in the chain. This should be stored by this method so that the clockEvent method above can call the next listener in the chain, and the getNext method below can return the next listener.
|
This method is used by the MachineState to handle chains of clockListeners, and should return the next listener in the chain - set by the setNext method above.
Before a clock listener can be notified of clock events, it must be added to the simulator's MachineState object. When a Plugin is closed, or no longer needs to respond to clock events, it should remove the clockListener from the MachineState. The following two methods are defined in MachineState to add and remove listeners:
|
To add a clock listener, and:
|
To remove it.
To develop using the PortMapper, it is necessary to understand how it behaves.
Again, the best example of this is the LCD Plugin and both that and how to
use the PortMapper from the user's perspective is explained on the first
Plugins Page - See 'Configuring Plugins'
and 'LCD Plugin'. The Config string is used
to create a new PortMapper, which then provides methods to examine which ports,
pins and signals are mapped between the Plugin and the microcontroller. The most
significant methods for the port mapper are 'prepare
', 'read
'
and 'writeToPort
'. 'Prepare
' and 'read
' are used
together, when a Plugin wishes to read information from the microcontroller.
'Prepare
' stores the microcontroller's outputs in the PortMapper so
that subsequent calls to 'read
' can read out individual bits, or
collections of bits. 'WriteToPort
' writes data from the Plugin to
the port's inputs.
As the PortMapper class is complex, and many of the methods are important, this manual will not attempt to list and describe them all. The Class and methods are all documented in the Javadocs for miSim DE, and this is an ideal place to start when developing Plugins.
![]() |
![]() |
![]() |