Versions in this module Expand all Collapse all v0 v0.2.0 Jan 3, 2026 Changes in this version + const SnoopInvalidate + const SnoopRead + const SnoopReadX + const SnoopResponseData + const SnoopResponseExclusive + const SnoopResponseModified + const SnoopResponseNoData + const SnoopResponseShared + const SnoopUpgrade + const SnoopWriteback + type AccessResult struct + Data []byte + Hit bool + NeedFill bool + NewState State + OldState State + Writeback bool + type AccessType uint8 + const AccessLoad + const AccessPrefetch + const AccessRFO + const AccessStore + const AccessTranslation + func (at AccessType) String() string type Cache + Access func(addr uint64, isWrite bool) *AccessResult + Fill func(addr uint64, data []byte, state State) (evictedAddr uint64, needWriteback bool) + GetStats func() CacheStats + ResetStats func() + type CacheBlock struct + Address uint64 + Data uint64 + Dirty bool + LRU uint64 + PfMetadata uint32 + Prefetch bool + VAddress uint64 + Valid bool + func (b *CacheBlock) Invalidate() + type CacheConfig struct + BlockSize uint32 + CPU uint32 + FillLatency uint64 + HitLatency uint64 + MSHRSize uint32 + Name string + NumSets uint32 + NumWays uint32 + PrefetchAsLoad bool + func DefaultL1DConfig() CacheConfig + func DefaultL2CConfig() CacheConfig + func DefaultLLCConfig() CacheConfig + type CacheStats struct + Accesses uint64 + Evictions uint64 + Hits uint64 + Misses uint64 + Writebacks uint64 type FullyAssociativeCache + func NewFullyAssociativeCacheWithBlockSize(capacity int, blockSize uint64) *FullyAssociativeCache + func (c *FullyAssociativeCache) Access(addr uint64, isWrite bool) *AccessResult + func (c *FullyAssociativeCache) ExportState(cfg state.ExportConfig) state.CacheState + func (c *FullyAssociativeCache) Fill(addr uint64, data []byte, state State) (uint64, bool) + func (c *FullyAssociativeCache) GetStats() CacheStats + func (c *FullyAssociativeCache) ResetStats() + type SetAssociativeCache struct + func NewSetAssociativeCache(numSets, numWays int, blockSize uint64) *SetAssociativeCache + func (c *SetAssociativeCache) Access(addr uint64, isWrite bool) *AccessResult + func (c *SetAssociativeCache) CanForward(addr uint64) bool + func (c *SetAssociativeCache) Fill(addr uint64, data []byte, state State) (uint64, bool) + func (c *SetAssociativeCache) GetBlockSize() uint64 + func (c *SetAssociativeCache) GetData(addr uint64) []byte + func (c *SetAssociativeCache) GetNumSets() int + func (c *SetAssociativeCache) GetNumWays() int + func (c *SetAssociativeCache) GetState(addr uint64) State + func (c *SetAssociativeCache) GetStats() CacheStats + func (c *SetAssociativeCache) HandleSnoop(snoopOpcode int, addr uint64) (*SnoopResponse, error) + func (c *SetAssociativeCache) Invalidate(addr uint64) + func (c *SetAssociativeCache) IsPresent(addr uint64) bool + func (c *SetAssociativeCache) ResetStats() + func (c *SetAssociativeCache) SetData(addr uint64, data []byte) + func (c *SetAssociativeCache) SetEvictCallback(callback EvictCallback) + func (c *SetAssociativeCache) SetState(addr uint64, state State) type State + func MESIHandleReadSnoop(currentState State) (State, bool) + func MESIHandleWriteSnoop(currentState State) (State, bool) + func MOESIHandleReadSnoop(currentState State) (State, bool) + func MOESIHandleWriteSnoop(currentState State) (State, bool) v0.0.3 Dec 24, 2025 Changes in this version + type Cache interface + CanForward func(addr uint64) bool + GetData func(addr uint64) []byte + GetState func(addr uint64) State + HandleSnoop func(snoopOpcode int, addr uint64) (*SnoopResponse, error) + Invalidate func(addr uint64) + IsPresent func(addr uint64) bool + SetData func(addr uint64, data []byte) + SetEvictCallback func(callback EvictCallback) + SetState func(addr uint64, state State) + type CacheLine struct + Addr uint64 + Data []byte + State State + type EvictCallback func(addr uint64, state State, data []byte) + type FullyAssociativeCache struct + func NewFullyAssociativeCache(capacity int) *FullyAssociativeCache + func (c *FullyAssociativeCache) CanForward(addr uint64) bool + func (c *FullyAssociativeCache) GetCapacity() int + func (c *FullyAssociativeCache) GetData(addr uint64) []byte + func (c *FullyAssociativeCache) GetSize() int + func (c *FullyAssociativeCache) GetState(addr uint64) State + func (c *FullyAssociativeCache) HandleSnoop(snoopOpcode int, addr uint64) (*SnoopResponse, error) + func (c *FullyAssociativeCache) Invalidate(addr uint64) + func (c *FullyAssociativeCache) IsPresent(addr uint64) bool + func (c *FullyAssociativeCache) SetData(addr uint64, data []byte) + func (c *FullyAssociativeCache) SetEvictCallback(callback EvictCallback) + func (c *FullyAssociativeCache) SetState(addr uint64, state State) + type SnoopResponse struct + Data []byte + HasData bool + ResponseOpcode int + type State string + const StateExclusive + const StateInvalid + const StateModified + const StateOwned + const StateShared