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

Subversion Repositories openrisc

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

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
//! Default size of the matchpoint hash table. Largest prime < 2^10
35
#define DEFAULT_MP_HASH_SIZE  1021
36
 
37
//! Enumeration of different types of matchpoint.
38
 
39
//! These have explicit values matching the second digit of 'z' and 'Z'
40
//! packets.
41
enum MpType {
42 462 julius
        BP_MEMORY = 0,
43
        BP_HARDWARE = 1,
44
        WP_WRITE = 2,
45
        WP_READ = 3,
46
        WP_ACCESS = 4
47 63 julius
};
48
 
49
class MpHash;
50
 
51
//! A structure for a matchpoint hash table entry
52 462 julius
struct MpEntry {
53 63 julius
public:
54
 
55 462 julius
        friend class MpHash;    // The only one which can get at next
56 63 julius
 
57 462 julius
        MpType type;            //!< Type of matchpoint
58
        uint32_t addr;          //!< Address with the matchpoint
59
        uint32_t instr;         //!< Substituted instruction
60 63 julius
 
61
private:
62
 
63 462 julius
         MpEntry * next;        //!< Next in this slot
64 63 julius
};
65
 
66
//! A hash table for matchpoints
67
 
68
//! We do this as our own open hash table. Our keys are a pair of entities
69
//! (address and type), so STL map is not trivial to use.
70
 
71 462 julius
class MpHash {
72 63 julius
public:
73
 
74 462 julius
        // Constructor and destructor
75
        MpHash(int _size = DEFAULT_MP_HASH_SIZE);
76
        ~MpHash();
77 63 julius
 
78 462 julius
        // Accessor methods
79
        void add(MpType type, uint32_t addr, uint32_t instr);
80
        MpEntry *lookup(MpType type, uint32_t addr);
81
        bool remove(MpType type, uint32_t addr, uint32_t * instr = NULL);
82 63 julius
 
83
private:
84
 
85 462 julius
        //! The hash table
86
         MpEntry ** hashTab;
87 63 julius
 
88 462 julius
        //! Size of the hash table
89
        int size;
90 63 julius
 
91
};
92
 
93 462 julius
#endif // MP_HASH__H

powered by: WebSVN 2.1.0

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