OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [include/] [MpHash.h] - Diff between revs 63 and 462

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 63 Rev 462
Line 29... Line 29...
#ifndef MP_HASH__H
#ifndef MP_HASH__H
#define MP_HASH__H
#define MP_HASH__H
 
 
#include <stdint.h>
#include <stdint.h>
 
 
 
 
//! Default size of the matchpoint hash table. Largest prime < 2^10
//! Default size of the matchpoint hash table. Largest prime < 2^10
#define DEFAULT_MP_HASH_SIZE  1021
#define DEFAULT_MP_HASH_SIZE  1021
 
 
 
 
//! Enumeration of different types of matchpoint.
//! Enumeration of different types of matchpoint.
 
 
//! These have explicit values matching the second digit of 'z' and 'Z'
//! These have explicit values matching the second digit of 'z' and 'Z'
//! packets.
//! packets.
enum MpType {
enum MpType {
Line 46... Line 44...
  WP_WRITE    = 2,
  WP_WRITE    = 2,
  WP_READ     = 3,
  WP_READ     = 3,
  WP_ACCESS   = 4
  WP_ACCESS   = 4
};
};
 
 
 
 
class MpHash;
class MpHash;
 
 
//! A structure for a matchpoint hash table entry
//! A structure for a matchpoint hash table entry
struct MpEntry
struct MpEntry {
{
 
public:
public:
 
 
  friend class MpHash;          // The only one which can get at next
  friend class MpHash;          // The only one which can get at next
 
 
  MpType    type;               //!< Type of matchpoint
  MpType    type;               //!< Type of matchpoint
  uint32_t  addr;               //!< Address with the matchpoint
  uint32_t  addr;               //!< Address with the matchpoint
  uint32_t  instr;              //!< Substituted instruction
  uint32_t  instr;              //!< Substituted instruction
 
 
 
 
private:
private:
 
 
  MpEntry *next;                //!< Next in this slot
  MpEntry *next;                //!< Next in this slot
};
};
 
 
 
 
//! A hash table for matchpoints
//! A hash table for matchpoints
 
 
//! We do this as our own open hash table. Our keys are a pair of entities
//! We do this as our own open hash table. Our keys are a pair of entities
//! (address and type), so STL map is not trivial to use.
//! (address and type), so STL map is not trivial to use.
 
 
class MpHash
class MpHash {
{
 
public:
public:
 
 
  // Constructor and destructor
  // Constructor and destructor
  MpHash (int  _size = DEFAULT_MP_HASH_SIZE);
  MpHash (int  _size = DEFAULT_MP_HASH_SIZE);
  ~MpHash ();
  ~MpHash ();
 
 
  // Accessor methods
  // Accessor methods
  void  add (MpType    type,
        void add(MpType type, uint32_t addr, uint32_t instr);
             uint32_t  addr,
        MpEntry *lookup(MpType type, uint32_t addr);
             uint32_t  instr);
        bool remove(MpType type, uint32_t addr, uint32_t * instr = NULL);
  MpEntry *lookup (MpType    type,
 
                   uint32_t  addr);
 
  bool  remove (MpType    type,
 
                uint32_t  addr,
 
                uint32_t *instr = NULL);
 
 
 
private:
private:
 
 
  //! The hash table
  //! The hash table
  MpEntry **hashTab;
  MpEntry **hashTab;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.