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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 63 julius
// ----------------------------------------------------------------------------
2
 
3
// Debug Unit memory cache: 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 GDB interface to the cycle accurate model of the
10
// OpenRISC 1000 based 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: MemCache.h 326 2009-03-07 16:47:31Z jeremy $
28
 
29
#ifndef MEM_CACHE__H
30
#define MEM_CACHE__H
31
 
32
#include <stdint.h>
33
 
34
//! Module for cacheing memory accesses by the debug unit
35
 
36
//! Memory reads and writes through the Debug Unit via JTAG are time
37
//! consuming - of the order of 1000 CPU clock cycles. However when the
38
//! processor is stalled the values cannot change, other than through the
39
//! debug unit, so it makes sense to cache values.
40
 
41
//! Cacheing the entire memory is too much (it does need to be cleared when
42
//! the processor is unstalled. This class provides a cacheing function using
43
//! a closed hash table.
44
 
45
//! In the event of a clash on write, the old value is replaced by the new
46
//! value.
47
 
48 462 julius
class MemCache {
49 63 julius
public:
50
 
51 462 julius
        // Constructor and destructor
52
        MemCache(int _tableSize = 1009);
53
        ~MemCache();
54 63 julius
 
55 462 julius
        // Functions
56
        void clear();
57
        void write(uint32_t addr, uint32_t value);
58
        bool read(uint32_t addr, uint32_t & value);
59 63 julius
 
60
private:
61
 
62 462 julius
        //! The size of the hash table. A prime number is a good choice.
63
        int tableSize;
64 63 julius
 
65 462 julius
        // The hash table, keyed by address. Done as three parallel vectors,
66
        // allowing unambiguous clearing by use of memset for efficiency.
67
        bool *tabIsValid;
68
        uint32_t *tabKeyAddr;
69
        uint32_t *tabValue;
70 63 julius
 
71 462 julius
};                              // MemCache ()
72 63 julius
 
73 462 julius
#endif // MEM_CACHE__H

powered by: WebSVN 2.1.0

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