avrora.sim.util
Class BranchCounter

java.lang.Object
  extended byavrora.sim.Simulator.Probe.Empty
      extended byavrora.sim.util.BranchCounter
All Implemented Interfaces:
Simulator.Probe

public class BranchCounter
extends Simulator.Probe.Empty

The BranchCounter class is a profiling probe that can be inserted at a branch instruction to count the number of times the branch is taken and not taken. It demonstrates the ability to inspect the state of the program after the execution of a program. It determines whether the branch was taken by inspecting the program counter of the new state. If the program counter is not equal to the instruction following the branch, then the branch was taken.

See Also:
Counter

Nested Class Summary
 
Nested classes inherited from class avrora.sim.Simulator.Probe
Simulator.Probe.Empty
 
Field Summary
 int nottakenCount
          This field tracks the number of times the branch is not taken.
 int takenCount
          This field tracks the number of times the branch is taken.
 
Constructor Summary
BranchCounter()
           
 
Method Summary
 void fireAfter(State state, int pc)
          The fireAfter() method is called after the probed instruction executes.
 
Methods inherited from class avrora.sim.Simulator.Probe.Empty
fireBefore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

takenCount

public int takenCount
This field tracks the number of times the branch is taken. It is incremented in the fireAfter method if the branch was taken.


nottakenCount

public int nottakenCount
This field tracks the number of times the branch is not taken. It is incremented in the fireAfter method if the branch was not taken.

Constructor Detail

BranchCounter

public BranchCounter()
Method Detail

fireAfter

public void fireAfter(State state,
                      int pc)
The fireAfter() method is called after the probed instruction executes. In the implementation of the branch counter, the counter determines whether the branch was taken by inspecting the program counter of the new state. If the program counter is not equal to the instruction following the branch, then the branch was taken.

Specified by:
fireAfter in interface Simulator.Probe
Overrides:
fireAfter in class Simulator.Probe.Empty
Parameters:
state - the state of the simulation
pc - the address at which this instruction resides