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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [include/] [MpHash.h] - Blame information for rev 63

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 63 julius
// ----------------------------------------------------------------------------
2
 
3
// Matchpoint hash table: definition
4
 
5
// Copyright (C) 2008  Embecosm Limited <info@embecosm.com>
6
 
7
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
// This file is part of the cycle accurate model of the OpenRISC 1000 based
10
// system-on-chip, ORPSoC, built using Verilator.
11
 
12
// This program is free software: you can redistribute it and/or modify it
13
// under the terms of the GNU Lesser General Public License as published by
14
// the Free Software Foundation, either version 3 of the License, or (at your
15
// option) any later version.
16
 
17
// This program is distributed in the hope that it will be useful, but WITHOUT
18
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
20
// License for more details.
21
 
22
// You should have received a copy of the GNU Lesser General Public License
23
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 
25
// ----------------------------------------------------------------------------
26
 
27
// $Id: MpHash.h 317 2009-02-22 19:52:12Z jeremy $
28
 
29
#ifndef MP_HASH__H
30
#define MP_HASH__H
31
 
32
#include <stdint.h>
33
 
34
 
35
//! Default size of the matchpoint hash table. Largest prime < 2^10
36
#define DEFAULT_MP_HASH_SIZE  1021
37
 
38
 
39
//! Enumeration of different types of matchpoint.
40
 
41
//! These have explicit values matching the second digit of 'z' and 'Z'
42
//! packets.
43
enum MpType {
44
  BP_MEMORY   = 0,
45
  BP_HARDWARE = 1,
46
  WP_WRITE    = 2,
47
  WP_READ     = 3,
48
  WP_ACCESS   = 4
49
};
50
 
51
 
52
class MpHash;
53
 
54
//! A structure for a matchpoint hash table entry
55
struct MpEntry
56
{
57
public:
58
 
59
  friend class MpHash;          // The only one which can get at next
60
 
61
  MpType    type;               //!< Type of matchpoint
62
  uint32_t  addr;               //!< Address with the matchpoint
63
  uint32_t  instr;              //!< Substituted instruction
64
 
65
 
66
private:
67
 
68
  MpEntry *next;                //!< Next in this slot
69
};
70
 
71
 
72
//! A hash table for matchpoints
73
 
74
//! We do this as our own open hash table. Our keys are a pair of entities
75
//! (address and type), so STL map is not trivial to use.
76
 
77
class MpHash
78
{
79
public:
80
 
81
  // Constructor and destructor
82
  MpHash (int  _size = DEFAULT_MP_HASH_SIZE);
83
  ~MpHash ();
84
 
85
  // Accessor methods
86
  void  add (MpType    type,
87
             uint32_t  addr,
88
             uint32_t  instr);
89
  MpEntry *lookup (MpType    type,
90
                   uint32_t  addr);
91
  bool  remove (MpType    type,
92
                uint32_t  addr,
93
                uint32_t *instr = NULL);
94
 
95
private:
96
 
97
  //! The hash table
98
  MpEntry **hashTab;
99
 
100
  //! Size of the hash table
101
  int  size;
102
 
103
};
104
 
105
#endif  // MP_HASH__H

powered by: WebSVN 2.1.0

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