Skip to content

Class simtix::mem::Cache

ClassList > simtix > mem > Cache

A cache implementation.

  • #include <mem.h>

Inherits the following classes: simtix::mem::CacheInterface

Classes

Type Name
class Impl
struct Param

Public Types inherited from simtix::mem::MemoryInterface

See simtix::mem::MemoryInterface

Type Name
typedef std::function< bool(RespStatus)> OnResp
enum uint8_t RespStatus

Public Static Attributes

Type Name
const Param kDefaultParam = /* multi line expression */

Public Functions

Type Name
virtual void AttachNextLevel (MemoryInterface * next_level) override
Attach the next level of memory hierarchy.
Cache (const std::string & name, MemoryInterface * next_level=nullptr, const Param & param=kDefaultParam)
virtual bool Flush (OnResp on_resp) override
Flush the cache.
virtual bool Read (Payload payload, OnResp on_resp) override
Enqueue a read request to the request queue.
virtual void ResetStat () override
Reset the statistics of the cache.
virtual bool Write (Payload payload, OnResp on_resp) override
Enqueue a write request to the request queue.
virtual uint8_t & operator[] (const uint64_t addr) override
The operator[] is used by the simulator to read or modify memory directly.
virtual const std::shared_ptr< stat::Group > stat () override const
Get statistics group for the cache.
~Cache ()

Public Functions inherited from simtix::mem::CacheInterface

See simtix::mem::CacheInterface

Type Name
virtual void AttachNextLevel (MemoryInterface * next_level) = 0
Attach the next level of memory hierarchy.
CacheInterface (const std::string & name, sim::TickPri pri=sim::kMemTickPri)
Constructor of CacheInterface .
virtual bool Flush (OnResp on_resp) = 0
Flush the cache.
virtual void ResetStat () = 0
Reset the statistics of the cache.
virtual const std::shared_ptr< stat::Group > stat () const = 0
Get statistics group for the cache.
virtual ~CacheInterface () = default

Public Functions inherited from simtix::mem::MemoryInterface

See simtix::mem::MemoryInterface

Type Name
MemoryInterface (const std::string & name, sim::TickPri pri=sim::kMemTickPri)
virtual bool Read (Payload payload, OnResp on_resp)
Enqueue a read request to the request queue.
virtual bool Write (Payload payload, OnResp on_resp)
Enqueue a write request to the request queue.
virtual uint8_t & operator[] (const uint64_t addr) = 0
The operator[] is used by the simulator to read or modify memory directly.
virtual ~MemoryInterface () = default

Public Functions inherited from simtix::sim::Clocked

See simtix::sim::Clocked

Type Name
Clocked (const std::string & name, TickPri pri=kDefaultPri)
Constructor for clocled.
const std::string & name () const
Get the name of the clocked object.
virtual ~Clocked ()

Protected Attributes

Type Name
std::unique_ptr< Impl > impl_

Protected Attributes inherited from simtix::sim::Clocked

See simtix::sim::Clocked

Type Name
std::string name_
TickPri pri_

Protected Static Attributes inherited from simtix::sim::Clocked

See simtix::sim::Clocked

Type Name
bool busy_ = true
std::map< TickPri, std::vector< Clocked * > > clocked_objs_map_
uint64_t cur_tick_ = 0

Protected Functions

Type Name
virtual bool HasPendingTasks () override
Check if the cache has pending tasks at the current tick.
virtual void Tick () override
Perform cache operation cycle.

Protected Functions inherited from simtix::sim::Clocked

See simtix::sim::Clocked

Type Name
virtual bool HasPendingTasks () = 0
Checks if any registered clocked objects have pending tasks at the current tick.
virtual void Tick () = 0
Global tick function that advances the simulation by one cycle.

Protected Static Functions inherited from simtix::sim::Clocked

See simtix::sim::Clocked

Type Name
void Register (Clocked * c)
Register a clocked object to participate in tick-driven simulation.
void Unregister (Clocked * c)
Unregister a clocked object from tick-driven simulation.

Public Static Attributes Documentation

variable kDefaultParam

const Param simtix::mem::Cache::kDefaultParam;

Public Functions Documentation

function AttachNextLevel

Attach the next level of memory hierarchy.

virtual void simtix::mem::Cache::AttachNextLevel (
    MemoryInterface * next_level
) override

Parameters:

  • next_level Pointer to the next level memory interface.

Implements simtix::mem::CacheInterface::AttachNextLevel


function Cache

explicit simtix::mem::Cache::Cache (
    const std::string & name,
    MemoryInterface * next_level=nullptr,
    const Param & param=kDefaultParam
) 

function Flush

Flush the cache.

virtual bool simtix::mem::Cache::Flush (
    OnResp on_resp
) override

Parameters:

  • on_resp Callback for the response.

Returns:

True if the flush operation is successful.

Implements simtix::mem::CacheInterface::Flush


function Read

Enqueue a read request to the request queue.

virtual bool simtix::mem::Cache::Read (
    Payload payload,
    OnResp on_resp
) override

Parameters:

  • payload Payload for the read operation.
  • on_resp Callback for the response.

Returns:

True if enqueued successfully.

Implements simtix::mem::MemoryInterface::Read


function ResetStat

Reset the statistics of the cache.

virtual void simtix::mem::Cache::ResetStat () override

Implements simtix::mem::CacheInterface::ResetStat


function Write

Enqueue a write request to the request queue.

virtual bool simtix::mem::Cache::Write (
    Payload payload,
    OnResp on_resp
) override

Parameters:

  • payload Payload for the write operation.
  • on_resp Callback for the response.

Returns:

True if enqueued successfully.

Implements simtix::mem::MemoryInterface::Write


function operator[]

The operator[] is used by the simulator to read or modify memory directly.

virtual uint8_t & simtix::mem::Cache::operator[] (
    const uint64_t addr
) override

Implements simtix::mem::MemoryInterface::operator[]


function stat

Get statistics group for the cache.

virtual const std::shared_ptr< stat::Group > simtix::mem::Cache::stat () override const

Returns:

Pointer to the statistics group.

Implements simtix::mem::CacheInterface::stat


function ~Cache

simtix::mem::Cache::~Cache () 

Protected Attributes Documentation

variable impl_

std::unique_ptr<Impl> simtix::mem::Cache::impl_;

Protected Functions Documentation

function HasPendingTasks

Check if the cache has pending tasks at the current tick.

virtual bool simtix::mem::Cache::HasPendingTasks () override

Returns:

True if there are pending tasks, false otherwise.

Implements simtix::sim::Clocked::HasPendingTasks


function Tick

Perform cache operation cycle.

virtual void simtix::mem::Cache::Tick () override

Implements simtix::sim::Clocked::Tick



The documentation for this class was generated from the following file projects/simtix/include/simtix/mem.h