• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/genericProc/FE/specMem.h

00001 // Copyright 2007 Sandia Corporation. Under the terms
00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
00003 // Government retains certain rights in this software.
00004 // 
00005 // Copyright (c) 2005-2007, Sandia Corporation
00006 // All rights reserved.
00007 // Copyright (c) 2003-2005, University of Notre Dame
00008 // All rights reserved.
00009 // 
00010 // This file is part of the SST software package. For license
00011 // information, see the LICENSE file in the top level directory of the
00012 // distribution.
00013 
00014 
00015 #ifndef SPECMEM_H
00016 #define SPECMEM_H
00017 
00018 #include "global.h"
00019 #include <map>
00020 
00021 using namespace std;
00022 
00023 class memory_interface;
00024 
00025 //: Speculative memory implementation
00026 //
00027 // An object which contains data which is speculative and designed to
00028 // be dumped.
00029 //
00030 //!SEC:Framework
00031 class specMemory {
00032   typedef map<simAddress, uint8> specMap;
00033   map<simAddress, uint8> specData;
00034   memory_interface *mem;
00035 
00036   uint8 getSpecByte(const simAddress sa);
00037 
00038   void writeSpecByte(const simAddress sa, const uint8 Data) {
00039     specData[sa] = Data;
00040   }
00041 
00042   bool useSpec(const simAddress sa, specMap::iterator &i) {
00043     i = specData.find(sa);
00044     if (i != specData.end()) {
00045       return 1;
00046     } else {
00047       return 0;
00048     }
00049   }
00050 
00051 public:
00052   specMemory(memory_interface *m) : mem(m) {;}
00053 
00054   void squashSpec() {
00055     specData.clear();
00056   }
00057 
00058   uint8 readSpec8(const simAddress sa) {
00059     return getSpecByte(sa);
00060   }
00061 
00062   uint16 readSpec16(const simAddress sa) {
00063     uint16 r = (getSpecByte(sa) << 8);
00064     r += getSpecByte(sa+1);
00065     return r;
00066   }
00067 
00068   uint32 readSpec32(const simAddress sa) {
00069     uint32 r = (getSpecByte(sa) << 24);
00070     r += getSpecByte(sa+1) << 16;
00071     r += getSpecByte(sa+2) << 8;
00072     r += getSpecByte(sa+3);
00073     return r;
00074   }
00075 
00076   bool writeSpec8(const simAddress sa, const uint8 Data) {
00077     writeSpecByte(sa, Data);
00078     return 1;
00079   }
00080 
00081   bool writeSpec16(const simAddress sa, const uint16 Data) {
00082     writeSpecByte(sa, Data>>8);
00083     writeSpecByte(sa+1, Data & 0xff);
00084     return 1;
00085   }
00086 
00087   bool writeSpec32(const simAddress sa, const uint32 Data) {
00088     writeSpecByte(sa, Data>>24);
00089     writeSpecByte(sa+1, Data>>16 & 0xff);
00090     writeSpecByte(sa+2, Data>>8 & 0xff);
00091     writeSpecByte(sa+3, Data & 0xff);
00092     return 1;
00093   }
00094 };
00095 
00096 #endif

Generated on Fri Oct 22 2010 11:02:22 for SST by  doxygen 1.7.1