coreblocks.cache package

Submodules

coreblocks.cache.icache module

class coreblocks.cache.icache.ICache

Bases: Elaboratable, CacheInterface

A simple set-associative instruction cache.

The replacement policy is a pseudo random scheme. Every time a line is trashed, we select the next way we write to (we keep one global counter for selecting the next way).

Refilling a cache line is abstracted away from this module. ICache module needs two methods from the refiller refiller_start, which is called whenever we need to refill a cache line. refiller_accept should be ready to be called whenever the refiller has another fetch block ready to be written to cache. refiller_accept should set last bit when either an error occurs or the transfer is over. After issuing last bit, refiller_accept shouldn’t be ready until the next transfer is started.

__init__(layouts: ICacheLayouts, params: ICacheParameters, refiller: CacheRefillerInterface) None
Parameters:
layoutsICacheLayouts

Instance of ICacheLayouts used to create cache methods.

paramsICacheParameters

Instance of ICacheParameters with parameters which should be used to generate the cache.

refiller_startMethod

A method with input layout ICacheLayouts.start_refill

refiller_acceptMethod

A method with output layout ICacheLayouts.accept_refill

deserialize_addr(raw_addr: Value) dict[str, Value]
serialize_addr(addr: View) Value
class coreblocks.cache.icache.ICacheBypass

Bases: Elaboratable, CacheInterface

__init__(layouts: ICacheLayouts, params: ICacheParameters, bus_master: BusMasterInterface) None

coreblocks.cache.iface module

class coreblocks.cache.iface.CacheInterface

Bases: HasElaborate, Protocol

Cache Interface.

Parameters:
issue_reqMethod

A method that is used to issue a cache lookup request.

accept_resMethod

A method that is used to accept the result of a cache lookup request.

flushMethod

A method that is used to flush the whole cache.

accept_res: Method
flush: Method
issue_req: Method
class coreblocks.cache.iface.CacheRefillerInterface

Bases: HasElaborate, Protocol

Cache Refiller Interface.

Parameters:
start_refillMethod

A method that is used to start a refill for a given cache line.

accept_refillMethod

A method that is used to accept one fetch block from the requested cache line.

accept_refill: Method
start_refill: Method

coreblocks.cache.plru module

class coreblocks.cache.plru.TreePLRU

Bases: Elaboratable

Tree-based pseudo-LRU replacement state over a power-of-two number of ways.

Tree-PLRU keeps one bit per internal node of a balanced binary tree. For a cache with N ways, it requires exactly N - 1 bits. Each internal node indicates which side was accessed less recently (0 - the left side).

To find the least recently used item, we traverse down the tree from the root node, following the directions indicated by each bit.

When accessing an item, the bits along its specific path are flipped to point in the opposite direction, so it is not selected for subsequent evictions.

Methods

get_victim: Method (nonexclusive)

Returns the way to replace.

touch: Methods

Each method marks its way argument as most-recently-used. Touches are applied in port order, so a higher-indexed port wins.

__init__(ways: int, touch_ports: int = 1)

coreblocks.cache.refiller module

class coreblocks.cache.refiller.SimpleCommonBusCacheRefiller

Bases: Elaboratable, CacheRefillerInterface

__init__(layouts: ICacheLayouts, params: ICacheParameters, bus_master: BusMasterInterface)

Module contents