Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## avrora.sim.util
Class MemoryCounter

    java.lang.Object
      avrora.sim.Simulator.Watch.Empty
          avrora.sim.util.MemoryCounter

All Implemented Interfaces:
  Simulator.Watch

public class MemoryCounter
extends Simulator.Watch.Empty

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`

Nested Class Summary

Nested classes inherited from class avrora.sim.Simulator.Watch
`Simulator.Watch.Empty`

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` | `fireBeforeRead(State state, int data_addr)` The `fireBeforeRead()` method is called before the data address is read by the program.
`void` | `fireBeforeWrite(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 avrora.sim.Simulator.Watch.Empty
`fireAfterRead, fireAfterWrite`

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(State state,
                               int data_addr)

  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`
  Overrides:
    `fireBeforeRead` in class `Simulator.Watch.Empty`
  Parameters:
    `state` - the state of the simulation
    `data_addr` - the address of the data being referenced

### fireBeforeWrite

    public void fireBeforeWrite(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`
  Overrides:
    `fireBeforeWrite` in class `Simulator.Watch.Empty`
  Parameters:
    `state` - the state of the simulation
    `data_addr` - the address of the data being referenced
    `value` - the value being written to the memory location

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD