Line 29... |
Line 29... |
#ifndef SPR_CACHE__H
|
#ifndef SPR_CACHE__H
|
#define SPR_CACHE__H
|
#define SPR_CACHE__H
|
|
|
#include <stdint.h>
|
#include <stdint.h>
|
|
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
//! Module for cacheing SPR accesses by the debug unit
|
//! Module for cacheing SPR accesses by the debug unit
|
|
|
//! SPR reads and writes through the Debug Unit via JTAG are time
|
//! SPR reads and writes through the Debug Unit via JTAG are time
|
//! consuming - of the order of 1000 CPU clock cycles. However when the
|
//! consuming - of the order of 1000 CPU clock cycles. However when the
|
Line 50... |
Line 49... |
//! allowed to be no more than 70% full (however NPC is always
|
//! allowed to be no more than 70% full (however NPC is always
|
//! cacheable). The hash function is a simple modulo function, stepping
|
//! cacheable). The hash function is a simple modulo function, stepping
|
//! forward to the first free slot. This works because there is no function to
|
//! forward to the first free slot. This works because there is no function to
|
//! delete an entry - just to clear the whole table, so holes cannot appear.
|
//! delete an entry - just to clear the whole table, so holes cannot appear.
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
class SprCache
|
class SprCache {
|
{
|
|
public:
|
public:
|
|
|
// Constructor and destructor
|
// Constructor and destructor
|
SprCache (int _tableSize = 257);
|
SprCache (int _tableSize = 257);
|
~SprCache ();
|
~SprCache ();
|
|
|
// Functions
|
// Functions
|
void clear ();
|
void clear ();
|
void write (uint16_t sprNum,
|
void write(uint16_t sprNum, uint32_t value, bool force);
|
uint32_t value,
|
bool read(uint16_t sprNum, uint32_t & value);
|
bool force);
|
|
bool read (uint16_t sprNum,
|
|
uint32_t &value);
|
|
|
|
private:
|
private:
|
|
|
//! The size of the hash table
|
//! The size of the hash table
|
int tableSize;
|
int tableSize;
|
Line 80... |
Line 75... |
// allowing unambiguous clearing by use of memset for efficiency.
|
// allowing unambiguous clearing by use of memset for efficiency.
|
bool *sprIsValid;
|
bool *sprIsValid;
|
uint16_t *sprKeyNum;
|
uint16_t *sprKeyNum;
|
uint32_t *sprValue;
|
uint32_t *sprValue;
|
|
|
|
|
}; // SprCache ()
|
}; // SprCache ()
|
|
|
#endif // SPR_CACHE__H
|
#endif // SPR_CACHE__H
|
|
|
No newline at end of file
|
No newline at end of file
|