de.cau.cs.kieler.krep.evalbench.comm
Class KepProtocol

java.lang.Object
  extended by de.cau.cs.kieler.krep.evalbench.comm.CommunicationProtocol
      extended by de.cau.cs.kieler.krep.evalbench.comm.KepProtocol
All Implemented Interfaces:
ICommunicationProtocol

public class KepProtocol
extends CommunicationProtocol

Implementation of the communication protocol interface that uses the KEP protocol. For details on the processors see Xin's or Malte's theses.

Rating yellow
(2010-02-05) review by cmot, msp

Field Summary
 
Fields inherited from interface de.cau.cs.kieler.krep.evalbench.comm.ICommunicationProtocol
P_KEP, P_KREP
 
Constructor Summary
KepProtocol(IConnection connectionProtocol)
          Constructs a new instance of the KEP protocol.
 
Method Summary
 void continuousRun()
          When executed the target is set to continuous mode.
 int[] getExecutionTrace()
          Requests an execution trace for the last tick command.
 String getTargetInfo()
          Requests target information from the target and translates the received return string.
 boolean loadProgram(IAssembler program, IProgressMonitor monitor)
          Loads a program onto the connected target.
 void reset()
          Resets the current program on the target.
 void stopContinuous()
          Stops continuous mode and returns to single tick mode.
 int tick(int maxSignals, LinkedList<Signal> inputs, LinkedList<Signal> outputs)
          Performs a program tick by sending the global input signal status, executing the tick command and reading the global output signal status.
 boolean verifyCommunication()
          Verifies communication by sending a command and receiving a return string.
 
Methods inherited from class de.cau.cs.kieler.krep.evalbench.comm.CommunicationProtocol
addCommunicationListener, getCommunicationListeners, getConnection, notifyComment, notifyReceive, notifySend, removeCommunicationListener, setCommunicationListeners, setConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KepProtocol

public KepProtocol(IConnection connectionProtocol)
Constructs a new instance of the KEP protocol.

Parameters:
connectionProtocol - underlying connection protocol to be used; this protocol instance is expected to be already initialized
Method Detail

continuousRun

public void continuousRun()
                   throws CommunicationException
When executed the target is set to continuous mode. Only external inputs and outputs are used in this mode.

Throws:
CommunicationException - when an exception occurs while sending the command

getExecutionTrace

public int[] getExecutionTrace()
                        throws CommunicationException
Requests an execution trace for the last tick command.

Returns:
list of addresses of executed instructions
Throws:
CommunicationException - when the received trace is invalid

getTargetInfo

public String getTargetInfo()
                     throws CommunicationException
Requests target information from the target and translates the received return string.

Returns:
readable target information
Throws:
CommunicationException - when the return string is invalid

loadProgram

public boolean loadProgram(IAssembler program,
                           IProgressMonitor monitor)
                    throws CommunicationException
Loads a program onto the connected target.

Parameters:
program - array of hex encoded instructions
monitor - progress-monitor, null if nothing shall be displayed
Returns:
true iff loading was successful
Throws:
CommunicationException - when the program string has an invalid length

reset

public void reset()
           throws CommunicationException
Resets the current program on the target.

Throws:
CommunicationException - when an invalid reply was received

stopContinuous

public void stopContinuous()
                    throws CommunicationException
Stops continuous mode and returns to single tick mode.

Throws:
CommunicationException - when an invalid reply was received

tick

public int tick(int maxSignals,
                LinkedList<Signal> inputs,
                LinkedList<Signal> outputs)
         throws CommunicationException
Performs a program tick by sending the global input signal status, executing the tick command and reading the global output signal status.

Parameters:
maxSignals - number of signals in the current program.
inputs - input signals
outputs - An empty list of output signals, the actual outputs are added by the tick function.
Returns:
number of instruction cycles to compute the tick
Throws:
CommunicationException - when an invalid reply was received

verifyCommunication

public boolean verifyCommunication()
                            throws CommunicationException
Verifies communication by sending a command and receiving a return string.

Returns:
true if the correct return string can be received from the processor.
Throws:
CommunicationException - when no return string could be read