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 MemoryMatrixProfiler

    java.lang.Object
      avrora.sim.util.MemoryMatrixProfiler

public class MemoryMatrixProfiler
extends java.lang.Object

The `MemoryMatrixProfiler` class collects information about a program's usage of memory. For each instruction in the program, it tracks the memory locations read and written by that instruction. For example, a load instruction that uses an address in a register might load bytes from various locations in the data memory. This class maintains two internal two-dimensional matrices, one for read counts and one for write counts. The matrices are indexed by code address and data address.

Field Summary
`int` | `ramSize` The `ramSize` field stores the maximum RAM address that should be recorded.
`long[][]` | `rcount` The `rcount` field stores a two dimensional array that records the read count for each memory location for each instruction.
`long[][]` | `wcount` The `rcount` field stores a two dimensional array that records the write count for each memory location for each instruction.

Constructor Summary
`MemoryMatrixProfiler(Program p, int size)` The constructor for the `MemoryMatrixProfiler` class creates a new memory probe that can be inserted into the simulator to record the full memory access statistics of the program.

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.
`long` | `getReadCount(int address, int data_addr)` The `getReadCount()` method returns the number of times the specified instruction read the specified memory address.
`long` | `getWriteCount(int address, int data_addr)` The `getWriteCount()` method returns the number of times the specified instruction wrote the specified memory address.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### rcount

    public final long[][] rcount

  The `rcount` field stores a two dimensional array that records the read count for each memory location for each instruction. It is indexed by program address, and then by data address. This matrix is row-sparse in that rows of all zero (e.g. a non-memory instruction) are not stored. To access this matrix, use the `getReadCount()` method.

### wcount

    public final long[][] wcount

  The `rcount` field stores a two dimensional array that records the write count for each memory location for each instruction. It is indexed by program address, and then by data address. This matrix is row-sparse in that rows of all zero (e.g. a non-memory instruction) are not stored. To access this matrix, use the `getWriteCount()` method.

### ramSize

    public final int ramSize

  The `ramSize` field stores the maximum RAM address that should be recorded.

Constructor Detail

### MemoryMatrixProfiler

    public MemoryMatrixProfiler(Program p,
                                int size)

  The constructor for the `MemoryMatrixProfiler` class creates a new memory probe that can be inserted into the simulator to record the full memory access statistics of the program.

Parameters:
  `p` - the program to record statistics for
  `size` - the size of the RAM in bytes

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 `MemoryMatrixProfiler`, it simply increments the count of reads at the address of the instruction and memory location by one.

  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 `MemoryMatrixProfiler`, it simply increments the count of writes at the address of the instruction and memory location by one.

  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 `MemoryMatrixProfiler`, it does nothing.

  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 `MemoryMatrixProfiler`, it does nothing.

  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

### getReadCount

    public long getReadCount(int address,
                             int data_addr)

  The `getReadCount()` method returns the number of times the specified instruction read the specified memory address.

  Parameters:
    `address` - the program address of the instruction
    `data_addr` - the address of the byte of memory
  Returns:
    the number of times the specified instruction read the specified memory address.

### getWriteCount

    public long getWriteCount(int address,
                              int data_addr)

  The `getWriteCount()` method returns the number of times the specified instruction wrote the specified memory address.

  Parameters:
    `address` - the program address of the instruction
    `data_addr` - the address of the byte of memory
  Returns:
    the number of times the specified instruction wrote the specified memory address.

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