avrora.sim.util
Class MemoryCounter

java.lang.Object
  extended byavrora.sim.util.MemoryCounter
All Implemented Interfaces:
Simulator.Watch

public class MemoryCounter
extends java.lang.Object
implements Simulator.Watch

The MemoryCounter is the simplest example of memory profiling functionality. When inserted as a watch at a particular memory location, it will simply count the number of reads and writes to that memory location. It is analagous to the Counter probe which is used to count the execution frequency of a particular instruction.

See Also:
Simulator.Watch, Counter

Field Summary
 long rcount
          The rcount field stores the number of reads encountered for this memory location.
 long wcount
          The wcount field stores the number of writes encountered for this memory location.
 
Constructor Summary
MemoryCounter()
           
 
Method Summary
 void fireAfterRead(Instr i, int address, State state, int data_addr, byte value)
          The fireAfterRead() method is called after the data address is read by the program.
 void fireAfterWrite(Instr i, int address, State state, int data_addr, byte value)
          The fireAfterWrite() method is called after the data address is written by the program.
 void fireBeforeRead(Instr i, int address, State state, int data_addr, byte value)
          The fireBeforeRead() method is called before the data address is read by the program.
 void fireBeforeWrite(Instr i, int address, State state, int data_addr, byte value)
          The fireBeforeWrite() method is called before the data address is written by the program.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rcount

public long rcount
The rcount field stores the number of reads encountered for this memory location.


wcount

public long wcount
The wcount field stores the number of writes encountered for this memory location.

Constructor Detail

MemoryCounter

public MemoryCounter()
Method Detail

fireBeforeRead

public void fireBeforeRead(Instr i,
                           int address,
                           State state,
                           int data_addr,
                           byte value)
The fireBeforeRead() method is called before the data address is read by the program. In the implementation of MemoryCounter, it simply increments the count of reads by one.

Specified by:
fireBeforeRead in interface Simulator.Watch
Parameters:
i - the instruction being probed
address - the address at which this instruction resides
state - the state of the simulation
data_addr - the address of the data being referenced
value - the value of the memory location being read

fireBeforeWrite

public void fireBeforeWrite(Instr i,
                            int address,
                            State state,
                            int data_addr,
                            byte value)
The fireBeforeWrite() method is called before the data address is written by the program. In the implementation of MemoryCounter, it simply increments the count of writes by one.

Specified by:
fireBeforeWrite in interface Simulator.Watch
Parameters:
i - the instruction being probed
address - the address at which this instruction resides
state - the state of the simulation
data_addr - the address of the data being referenced
value - the value being written to the memory location

fireAfterRead

public void fireAfterRead(Instr i,
                          int address,
                          State state,
                          int data_addr,
                          byte value)
The fireAfterRead() method is called after the data address is read by the program. In the implementation of MemoryCounter, it does nothing.

Specified by:
fireAfterRead in interface Simulator.Watch
Parameters:
i - the instruction being probed
address - the address at which this instruction resides
state - the state of the simulation
data_addr - the address of the data being referenced
value - the value of the memory location being read

fireAfterWrite

public void fireAfterWrite(Instr i,
                           int address,
                           State state,
                           int data_addr,
                           byte value)
The fireAfterWrite() method is called after the data address is written by the program. In the implementation of MemoryCounter, it does nothing.

Specified by:
fireAfterWrite in interface Simulator.Watch
Parameters:
i - the instruction being probed
address - the address at which this instruction resides
state - the state of the simulation
data_addr - the address of the data being referenced
value - the value being written to the memory location