public abstract class TargetBoard
extends java.lang.Object
Constructor and Description |
---|
TargetBoard()
If this constructor is used, the
target board's hardware settings will be saved in a file named edsim51shSettings.ser.
|
TargetBoard(java.lang.String hardwareSettingsFileName)
This constructor allows the programmer
to name the target board's hardware settings file.
|
Modifier and Type | Method and Description |
---|---|
void |
clearPortPin(int portNumber,
int pinNumber)
Clear a port pin (ie: to logic 0),
given the port number and the pin number.
A call to this method is always successful. |
void |
clearPortPin(int portNumber,
int pinNumber, int hardwareId)
Clear a port pin (ie: to logic 0),
given the port number and the pin number.
THIS FUNCTION MUST BE USED IF MORE THAN ONE PERIPHERAL IS CONNECTED TO THE PORT PIN. A call to this method is always successful. |
int |
getBatchElapsedTime()
This method returns the length of time
(in microseconds) the current batch of 8051 instructions has been
executing, as determined by the 8051 system clock.
A batch size is determined by the Update Frequency menu at the top of the simulator GUI. The batch elapsed time is updated after each 8051 instruction execution. |
double |
getCpuMachineCycleLength()
This method returns the length, in
microseconds, of the 8051 machine cycle.
|
java.lang.String |
getHardwareSetting(java.lang.String id)
This method returns a target board
setting from file.
|
int |
getInstructionCycles()
This method returns the most recent
8051 instruction's number of cycles.
|
int |
getInstructionElapsedTime()
This method returns the length of time
(in microseconds) the most recent 8051 instruction took to execute, as
determined by the 8051 system clock.
|
long |
getInstructionElapsedTimeInNanos()
This method returns the length of time
(in nanoseconds) the most recent 8051 instruction took to execute, as
determined by the 8051 system clock.
|
long |
getProgramElapsedTime()
This method returns the length of time
(in microseconds) the current 8051 program has been executing, as
determined by the 8051 running with system clock.
The program elapsed time is updated after each 8051 instruction execution. |
void |
init(javax.swing.JPanel gui,
java.lang.String title, java.lang.String version)
An instance of TargetBoard should
contain a JPanel containing the target board's graphics, its title and
its version number.
|
int |
readPortLatch(int portNumber,
int pinNumber)
Read a port latch, given the port
number and the pin number.
This allows the target board programmer to examine the state of any given latch at any time. Note: this method reads the port latch, not the port pin. |
int |
readPortPin(int portNumber,
int pinNumber)
Returns the state of a port pin (1 or
0), given the port number and the pin number.
|
void |
reset()
This method does nothing.
|
void |
setHardwareSetting(java.lang.String id,
java.lang.String setting)
This method saves a target board
setting in a file.
|
boolean |
setPortPin(int portNumber,
int pinNumber)
Set a port pin (ie: to logic 1), given
the port number and the pin number.
Returns true if the port pin was set, false if not. Note: There is no guarantee that calling this method for a given port pin will result in the pin being set. |
boolean |
setPortPin(int portNumber,
int pinNumber, int hardwareId)
Set a port pin (ie: to logic 1), given
the port number and the pin number.
THIS FUNCTION MUST BE USED IF MORE THAN ONE PERIPHERAL IS CONNECTED TO THE PORT PIN. Returns true if the port pin was set, false if not. Note: There is no guarantee that calling this method for a given port pin will result in the pin being set. |
void |
setPortPinDescription(int portNumber,
int pinNumber, java.lang.String description)
This method takes a port number and a
pin number together with a String containing the port pin's description.
|
void |
setPortPinDescription(int portNumber,
int pinNumber, java.lang.String description,
java.lang.String toolTip)
This method takes a port number and a
pin number together with a String containing the port pin's description
and another String containing the pin's tooltip.
|
abstract void |
setTargetBoardGraphicsSize(boolean small)
This method is called in response to
the zoom button in the simulator's GUI being clicked.
With the simulator's default size (ie: small), it may be difficult to see on high resolution monitors. |
abstract void |
updatePortPins()
The programmer must provide an
implementation of this abstract method.
|
abstract void |
updateTargetBoardGraphics()
This method is called by the simulator
after each batch of 8051 instructions has been executed.
When the user steps through 8051 code, this method is called after each instruction has been executed. |
public TargetBoard()
public TargetBoard(java.lang.String hardwareSettingsFileName)
hardwareSettingsFileName
- The hardware
settings file name.public void init(javax.swing.JPanel gui,
java.lang.String title,
java.lang.String version)
gui
- The target board's graphical user
interface. This GUI will be placed in the simulator's target board
panel.title
- The title pane at the top of the
simulator's GUI displays EdSim51SH version *.*.*version
- The target board's version
number is appended to the title in the simulator's GUI.public double getCpuMachineCycleLength()
public void setPortPinDescription(int portNumber,
int pinNumber,
java.lang.String description)
portNumber
- A number between 0 and 3,
corresponding to P0, P1, P2 and P3 on the 8051. The value in portNumber
is ANDed with 3 (11 in binary) to force it to a value between 0 and 3.pinNumber
- A number between 0 and 7,
corresponding to the pin numbers of a given port. The value in
pinNumber is ANDed with 7 (111 in binary) to force it to a value
between 0 and 7.description
- A description of the
peripheral this pin is connected to. The first 32 characters in the
description will be displayed in the simulator's top right panel. If the
description is more than 32 characters long it is truncated to 32
characters.public void setPortPinDescription(int portNumber,
int pinNumber,
java.lang.String description,
java.lang.String toolTip)
portNumber
- A number between 0 and 3,
corresponding to P0, P1, P2 and P3 on the 8051. The value in portNumber
is ANDed with 3 (11 in binary) to force it to a value between 0 and 3.pinNumber
- A number between 0 and 7,
corresponding to the pin numbers of a given port. The value in
pinNumber is ANDed with 7 (111 in binary) to force it to a value
between 0 and 7.description
- A description of the
peripheral this pin is connected to. The first 32 characters in the
description will be displayed in the simulator's top right panel. If the
description is more than 32 characters long it is truncated to 32
characters.toolTip
- A tooltip for the pin can also
be set. The tooltip text will then appear when the user lets the mouse
pointer hover over the pin's description. Setting the tooltip is
optional. If the target board programmer would rather not set the
tooltip, the other version of setPortPinDescription()
should be used (see above).public boolean setPortPin(int portNumber,
int pinNumber,
int hardwareId)
portNumber
- A number between 0 and 3,
corresponding to P0, P1, P2 and P3 on the 8051. The value in portNumber
is ANDed with 3 (11 in binary) to force it to a value between 0 and 3.pinNumber
- A number between 0 and 7,
corresponding to the pin numbers of a given port. The value in
pinNumber is ANDed with 7 (111 in binary) to force it to a value
between 0 and 7.hardwareId
- The hardware ID is required
if more than one peripheral is connected to the port pin. The system
needs to keep track of which piece of hardware is holding the port pin
low. Each peripheral connected to an individual port pin must have a
unique id - any integer greater than zero.public boolean setPortPin(int portNumber,
int pinNumber)
portNumber
- A number between 0 and 3,
corresponding to P0, P1, P2 and P3 on the 8051. The value in portNumber
is ANDed with 3 (11 in binary) to force it to a value between 0 and 3.pinNumber
- A number between 0 and 7,
corresponding to the pin numbers of a given port. The value in
pinNumber is ANDed with 7 (111 in binary) to force it to a value
between 0 and 7.public void clearPortPin(int portNumber,
int pinNumber,
int hardwareId)
portNumber
- A number between 0 and 3,
corresponding to P0, P1, P2 and P3 on the 8051. The value in portNumber
is ANDed with 3 (11 in binary) to force it to a value between 0 and 3.pinNumber
- A number between 0 and 7,
corresponding to the pin numbers of a given port. The value in
pinNumber is ANDed with 7 (111 in binary) to force it to a value
between 0 and 7.hardwareId
- The hardware ID is required
if more than one peripheral is connected to the port pin. The system
needs to keep track of which piece of hardware is holding the port pin
low. Each peripheral connected to an individual port pin must have a
unique id - any integer greater than zero.public void clearPortPin(int portNumber,
int pinNumber)
portNumber
- A number between 0 and 3,
corresponding to P0, P1, P2 and P3 on the 8051. The value in portNumber
is ANDed with 3 (11 in binary) to force it to a value between 0 and 3.pinNumber
- A number between 0 and 7,
corresponding to the pin numbers of a given port. The value in
pinNumber is ANDed with 7 (111 in binary) to force it to a value
between 0 and 7.public int readPortPin(int portNumber,
int pinNumber)
portNumber
- A number between 0 and 3,
corresponding to P0, P1, P2 and P3 on the 8051. The value in portNumber
is ANDed with 3 (11 in binary) to force it to a value between 0 and 3.pinNumber
- A number between 0 and 7,
corresponding to the pin numbers of a given port. The value in
pinNumber is ANDed with 7 (111 in binary) to force it to a value
between 0 and 7.public int readPortLatch(int portNumber,
int pinNumber)
portNumber
- A number between 0 and 3,
corresponding to P0, P1, P2 and P3 on the 8051. The value in portNumber
is ANDed with 3 (11 in binary) to force it to a value between 0 and 3.pinNumber
- A number between 0 and 7,
corresponding to the pin numbers of a given port. The value in
pinNumber is ANDed with 7 (111 in binary) to force it to a value
between 0 and 7.public int getInstructionCycles()
public int getInstructionElapsedTime()
public long getInstructionElapsedTimeInNanos()
public int getBatchElapsedTime()
public long getProgramElapsedTime()
public void setHardwareSetting(java.lang.String id,
java.lang.String setting)
id
- the setting's id. If this id
already exists, then its data is overwritten. If it does not exist, it
is created.setting
- the setting's datapublic java.lang.String getHardwareSetting(java.lang.String id)
id
- the setting's idpublic void reset()
public abstract void updatePortPins()
public abstract void updateTargetBoardGraphics()
public abstract void setTargetBoardGraphicsSize(boolean small)
small
- If true: resize the target board
GUI to 'small'