SRAM.h
// INCLUDE THE SMI MODEL BASE CLASS DECLARATION

#include "smi_model.h"

// DECLARE CLASSES USED IN THE INTERFACE

#include <string>
#include <map>
class SMI_TxMessage;
class SMI_RxMessage;

//************************
// CLASS DECLARATION: SRAM
//************************

class SRAM:
    public SMI_Model
{
public:
    // CONSTRUCTOR
    //
    // ARGUMENT: name
    //   SMI instance name.
    //
    // DESCRIPTION:
    //   Constructs new software model instance of an SRAM model. Registers the
    //   model with SMI with SMI model name "SRAM" and the SMI instance name
    //   passed by argument.

    SRAM(const string& name);

    // DESTRUCTOR

    virtual ~SRAM();

    // METHOD: queryWidth()
    //
    // RETURNS:
    //   Bit width of the memory.

    long queryWidth() { return d_width; };

    // METHOD: getData(address)
    //
    // ARGUMENT: address
    //   Address of the memory word to be read.
    //
    // RETURNS:
    //   The data stored in the memory at the given address.

    long getData(long address) { return d_memory[address]; };

    // METHOD: setData(address, data)
    //
    // ARGUMENT: address
    //   Address of the memory word to be written.
    // 
    // ARGUMENT: data
    //   Data to be written to the memory at the given address.

    void setData(long address, long data) { d_memory[address]=data; };

private:
    // CONSTANT: USED TO IDENTIFY THE MESSAGE TYPE

    static const int MEM_CONFIG;
    static const int MEM_WRITE;
    static const int MEM_READ;

    // DATA: SMI INSTANCE NAME OF THE MODEL

    const string d_name;

    // DATA: MEMORY STORAGE MAPPING =<32 BIT ADDRESS TO =<32 BIT DATA

    map<unsigned long, unsigned long> d_memory;

    // DATA: THE BIT WIDTH OF THE WORDS STORED BY THE MEMORY MODEL

    unsigned long d_width;

    // DATA: REPLY MESSAGE

    SMI_TxMessage* d_tx;

    // METHOD: process(rx)
    //
    // ARGUMENT: rx
    //   Incoming message.
    //
    // RETURNS:
    //   Reply message.
    //
    // DESCRIPTION:
    //   Implements memory model operations by processing incoming messages.

    SMI_TxMessage* process(const SMI_RxMessage& rx);

    // DISABLE DEFAULT CONSTRUCTORS

    SRAM();
    SRAM(const SRAM&);
};
© Copyright 2000-2001 Adrian Lewis