com.cmpware.cmp.memory
Class SharedMemory

java.lang.Object
  extended by com.cmpware.cmp.memory.LocalMemory
      extended by com.cmpware.cmp.memory.SharedMemory
All Implemented Interfaces:
MemoryInterface, ReadWriteInterface

public class SharedMemory
extends LocalMemory

This class implements Shared Memory. This memory is just like local memory, except that writes are not performed immediately, but on the simulation commit() cycle. Note that the original version of this class assumed only one call from this class per simulation cycle. Recent versions take multiple writes per simulation cycle.

Copyright (c) 2004, 2005 Cmpware, Inc. All Rights Reserved.

Author:
SAG

Field Summary
static java.lang.String copyright
          Copyright string
 
Fields inherited from class com.cmpware.cmp.memory.LocalMemory
BIG, LITTLE
 
Constructor Summary
SharedMemory()
          Constructor
SharedMemory(byte[] b)
          Constructor
SharedMemory(int size)
          Constructor
 
Method Summary
static void commit()
          This method commits all writes at the end of the simulation cycle.
 void write(int addr, byte a)
          This method copies a byte from 'a' into the memory at address 'addr'.
 void write16(int addr, short a)
          This method writes the 16-bit value 'a' to the requested memory address.
 void write32(int addr, int a)
          This method writes the 32-bit value 'a' to the requested memory address.
 void write64(int addr, long a)
          This method writes the 64-bit value 'a' to the requested memory address.
 void writeCommit()
          This method is called at the end of the simulation cycle and updates the shared memory with any pending writes.
 
Methods inherited from class com.cmpware.cmp.memory.LocalMemory
clearProfile, get, getBaseAddress, getEndian, getMaxProfile, getProfile, getProfile, getProfileGranularity, isReadable, isValidAddress, isWriteable, profile, read, read16, read24, read32, read64, resize, setBaseAddress, setEndian, size, write24
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final java.lang.String copyright
Copyright string

See Also:
Constant Field Values
Constructor Detail

SharedMemory

public SharedMemory()
Constructor


SharedMemory

public SharedMemory(int size)
Constructor

Parameters:
size - The size of the memory in bytes

SharedMemory

public SharedMemory(byte[] b)
Constructor

Parameters:
b - The byte array used as the memory store.
Method Detail

write

public void write(int addr,
                  byte a)
           throws MemoryAccessException
Description copied from interface: ReadWriteInterface
This method copies a byte from 'a' into the memory at address 'addr'.

Specified by:
write in interface ReadWriteInterface
Overrides:
write in class LocalMemory
Parameters:
addr - The memory address.
a - The data to be written to the memory.
Throws:
MemoryAccessException - if an illegal memory address is encountered.

write16

public void write16(int addr,
                    short a)
             throws MemoryAccessException
Description copied from interface: ReadWriteInterface
This method writes the 16-bit value 'a' to the requested memory address.

Specified by:
write16 in interface ReadWriteInterface
Overrides:
write16 in class LocalMemory
Parameters:
addr - The memory address.
a - The value to be written.
Throws:
MemoryAccessException - if an illegal memory address is encountered.

write32

public void write32(int addr,
                    int a)
             throws MemoryAccessException
Description copied from interface: ReadWriteInterface
This method writes the 32-bit value 'a' to the requested memory address.

Specified by:
write32 in interface ReadWriteInterface
Overrides:
write32 in class LocalMemory
Parameters:
addr - The memory address.
a - The value to be written.
Throws:
MemoryAccessException - if an illegal memory address is encountered.

write64

public void write64(int addr,
                    long a)
             throws MemoryAccessException
Description copied from interface: ReadWriteInterface
This method writes the 64-bit value 'a' to the requested memory address.

Specified by:
write64 in interface ReadWriteInterface
Overrides:
write64 in class LocalMemory
Parameters:
addr - The memory address.
a - The value to be written.
Throws:
MemoryAccessException - if an illegal memory address is encountered.

writeCommit

public void writeCommit()
                 throws MemoryAccessException
This method is called at the end of the simulation cycle and updates the shared memory with any pending writes.

Throws:
MemoryAccessException

commit

public static void commit()
                   throws MemoryAccessException
This method commits all writes at the end of the simulation cycle. Note this this method is static and will commit *all* memory writes from all users of this class.

Throws:
MemoryAccessException