cache

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2019 License: MIT Imports: 4 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCacheLineID

func GetCacheLineID(addr uint64, blockSizeAsPowerOf2 uint64) (cacheLineID, offset uint64)

Types

type BankedLowModuleFinder

type BankedLowModuleFinder struct {
	BankSize   uint64
	LowModules []akita.Port
}

BankedLowModuleFinder defines the lower level modules by address banks

func NewBankedLowModuleFinder

func NewBankedLowModuleFinder(bankSize uint64) *BankedLowModuleFinder

func (*BankedLowModuleFinder) Find

func (f *BankedLowModuleFinder) Find(address uint64) akita.Port

type Block

type Block struct {
	Tag          uint64
	WayID        int
	SetID        int
	CacheAddress uint64
	IsValid      bool
	IsDirty      bool
	IsLocked     bool
}

A Block of a cache is the information that is associated with a cache line

type Builder

type Builder struct {
	Engine          akita.Engine
	LowModuleFinder LowModuleFinder
}

A Builder can build different types of cache components

func (*Builder) BuildWriteAroundCache

func (b *Builder) BuildWriteAroundCache(
	name string,
	wayAssociativity int,
	byteSize uint64,
	numMSHREntry int,
) *WriteAroundCache

BuildWriteAroundCache creates a write-around cache

func (*Builder) BuildWriteBackCache

func (b *Builder) BuildWriteBackCache(
	name string,
	wayAssociativity int,
	byteSize uint64,
	numMSHREntry int,
) *WriteBackCache

BuildWriteBackCache creates a write-back cache

type Directory

type Directory interface {
	TotalSize() uint64
	Lookup(address uint64) *Block
	Evict(address uint64) *Block
	WayAssociativity() int
	Reset()
}

A Directory stores the information about what is stored in the cache.

type DirectoryImpl

type DirectoryImpl struct {
	NumSets   int
	NumWays   int
	BlockSize int

	Sets []Set
	// contains filtered or unexported fields
}

A DirectoryImpl is the default implementation of a Directory

The directory can translate from the request address (can be either virtual addree or physical address) to the cache based address.

func NewDirectory

func NewDirectory(set int, way int, blockSize int, evictor Evictor) *DirectoryImpl

NewDirectory returns a new directory object

func (*DirectoryImpl) Evict

func (d *DirectoryImpl) Evict(reqAddr uint64) *Block

Evict returns a block that can be used to stored the data at reqAddr.

If it is valid, the cache controller need to decide what to do to evict the the data in the block

func (*DirectoryImpl) Lookup

func (d *DirectoryImpl) Lookup(reqAddr uint64) *Block

Lookup finds the block that stores the reqAddr. If the reqAddr is valid in the cache, return the block information. Otherwise, return nil

func (*DirectoryImpl) Reset

func (d *DirectoryImpl) Reset()

Reset will mark all the blocks in the directory invalid

func (*DirectoryImpl) TotalSize

func (d *DirectoryImpl) TotalSize() uint64

TotalSize returns the maximum number of bytes can be stored in the cache

func (*DirectoryImpl) WayAssociativity

func (d *DirectoryImpl) WayAssociativity() int

WayAssociativity returns the number of ways per set in the cache.

type Evictor

type Evictor interface {
	Evict(set *Set) *Block
}

A Evictor decides with block should be evicted

type InterleavedLowModuleFinder

type InterleavedLowModuleFinder struct {
	UseAddressSpaceLimitation bool
	LowAddress                uint64
	HighAddress               uint64
	InterleavingSize          uint64
	LowModules                []akita.Port
	ModuleForOtherAddresses   akita.Port
}

InterleavedLowModuleFinder helps find the low module when the low modules maintains interleaved address space

func NewInterleavedLowModuleFinder

func NewInterleavedLowModuleFinder(interleavingSize uint64) *InterleavedLowModuleFinder

NewInterleavedLowModuleFinder creates a new finder for interleaved lower modules

func (*InterleavedLowModuleFinder) Find

func (f *InterleavedLowModuleFinder) Find(address uint64) akita.Port

Find returns the low module that has the data at provided address

type LRUEvictor

type LRUEvictor struct {
}

LRUEvictor structure

func NewLRUEvictor

func NewLRUEvictor() *LRUEvictor

NewLRUEvictor returns a newly constructed lru evictor

func (*LRUEvictor) Evict

func (e *LRUEvictor) Evict(set *Set) *Block

Evict implements the eviction method

type LowModuleFinder

type LowModuleFinder interface {
	Find(address uint64) akita.Port
}

LowModuleFinder helps a cache unit or a akita to find the low module that should hold the data at a certain address

type MSHR

type MSHR interface {
	Query(addr uint64) *MSHREntry
	QueryByBlockTag(addr uint64) *MSHREntry
	Add(addr uint64) *MSHREntry
	Remove(addr uint64) *MSHREntry
	IsFull() bool
}

MSHR is an interface that controls MSHR

type MSHREntry

type MSHREntry struct {
	Requests []mem.AccessReq
	Data     []byte
	Block    *Block
}

MSHREntry is an entry in MSHR

func NewMSHREntry

func NewMSHREntry() *MSHREntry

NewMSHREntry returns a new MSHR entry object

type MSHRImpl

type MSHRImpl struct {
	*akita.ComponentBase

	CapacityInNumEntries int
	// contains filtered or unexported fields
}

MSHRImpl is a default implementation of MSHR

func NewMSHR

func NewMSHR(capacity int) *MSHRImpl

NewMSHR returns a new MSHRImpl object

func (*MSHRImpl) Add

func (m *MSHRImpl) Add(addr uint64) *MSHREntry

Add creats a new entry in the mshr. The Address passed in needs to be the block ID.

func (*MSHRImpl) IsFull

func (m *MSHRImpl) IsFull() bool

IsFull returns true if no more MSHR entries can be added

func (*MSHRImpl) Query

func (m *MSHRImpl) Query(addr uint64) *MSHREntry

Query returns the entry mapped by the input address. If the address is not in MSHR, return nil

func (*MSHRImpl) QueryByBlockTag

func (m *MSHRImpl) QueryByBlockTag(addr uint64) *MSHREntry

func (*MSHRImpl) Remove

func (m *MSHRImpl) Remove(addr uint64) *MSHREntry

Remove deletes the entry in the MSHR and returns the deleted entry.

type MockDirectory

type MockDirectory struct {
	Resetted bool
	// contains filtered or unexported fields
}

func (*MockDirectory) AllExpectedCalled

func (d *MockDirectory) AllExpectedCalled() bool

func (*MockDirectory) Evict

func (d *MockDirectory) Evict(address uint64) *Block

func (*MockDirectory) ExpectEvict

func (d *MockDirectory) ExpectEvict(addr uint64, block *Block)

func (*MockDirectory) ExpectLookup

func (d *MockDirectory) ExpectLookup(addr uint64, block *Block)

func (*MockDirectory) Lookup

func (d *MockDirectory) Lookup(address uint64) *Block

func (*MockDirectory) Reset

func (d *MockDirectory) Reset()

func (*MockDirectory) TotalSize

func (d *MockDirectory) TotalSize() uint64

func (*MockDirectory) WayAssociativity

func (d *MockDirectory) WayAssociativity() int

type ProcessMSHRReturnEvent

type ProcessMSHRReturnEvent struct {
	*akita.EventBase
}

ProcessMSHRReturnEvent is an event to let the cache to process the requests associate with an MSHREntry

func NewProcessMSHRReturnEvent

func NewProcessMSHRReturnEvent(
	time akita.VTimeInSec,
	handler akita.Handler,
) *ProcessMSHRReturnEvent

NewProcessMSHRReturnEvent creates a new ProcessMSHRReturnEvent

type ReadCompleteEvent

type ReadCompleteEvent struct {
	*akita.EventBase

	ReadReq *mem.ReadReq
	Block   *Block
}

A ReadCompleteEvent marks the completion of a cache read

func NewReadCompleteEvent

func NewReadCompleteEvent(
	time akita.VTimeInSec,
	handler akita.Handler,
) *ReadCompleteEvent

NewReadCompleteEvent creates a new ReadCompleteEvent

type ReadForEvictEvent

type ReadForEvictEvent struct {
	*akita.EventBase

	DataReady     *mem.DataReadyRsp
	EvictBlock    *Block
	NewBlock      *Block
	ReadBottomReq *mem.ReadReq
}

A ReadForEvictEvent marks the completion of a cache read. The data read is going to be written to the low module

func NewReadForEvictEvent

func NewReadForEvictEvent(
	time akita.VTimeInSec,
	handler akita.Handler,
) *ReadForEvictEvent

NewReadForEvictEvent creates a new ReadForEvictEvent

type ReadFromMSHREvent

type ReadFromMSHREvent struct {
	*akita.EventBase

	ReadReq *mem.ReadReq
	Data    []byte
}

ReadFromMSHREvent will respond data ready to the sender with the data that has not been written into the cache storage

func NewReadFromMSHREvent

func NewReadFromMSHREvent(
	time akita.VTimeInSec,
	handler akita.Handler,
) *ReadFromMSHREvent

NewReadFromMSHREvent creates a new ReadFromMSHREvent

type SendEvent

type SendEvent struct {
	*akita.EventBase
}

SendEvent triggers a cache to check its buffer and send requests out.

func NewSendEvent

func NewSendEvent(
	time akita.VTimeInSec,
	handler akita.Handler,
) *SendEvent

NewSendEvent creates a new SendEvent

type Set

type Set struct {
	Blocks   []*Block
	LRUQueue []*Block
}

A Set is a list of blocks where a certain piece memory can be stored at

func NewSet

func NewSet() *Set

NewSet create a new Set object

type SetBankCycleLeftToZeroEvent

type SetBankCycleLeftToZeroEvent struct {
	*akita.EventBase
	// contains filtered or unexported fields
}

func NewSetBankCycleLeftToZeroEvent

func NewSetBankCycleLeftToZeroEvent(
	time akita.VTimeInSec,
	handler akita.Handler,
	bankNum int,
) *SetBankCycleLeftToZeroEvent

type SingleLowModuleFinder

type SingleLowModuleFinder struct {
	LowModule akita.Port
}

SingleLowModuleFinder is used when a unit is connected with only one low module

func (*SingleLowModuleFinder) Find

func (f *SingleLowModuleFinder) Find(address uint64) akita.Port

Find simply returns the solo unit that it connects to

type WriteAroundCache

type WriteAroundCache struct {
	*akita.ComponentBase

	ToTop    akita.Port
	ToBottom akita.Port

	LowModuleFinder LowModuleFinder

	Freq akita.Freq

	DirectoryLatency    int
	Latency             int
	NumBank             int
	BlockSizeAsPowerOf2 uint64
	// contains filtered or unexported fields
}

A WriteAroundCache is a cache that performs the write-through policy

func NewWriteAroundCache

func NewWriteAroundCache(
	name string,
	engine akita.Engine,
	directory Directory,
	mshr MSHR,
	lowModuleFinder LowModuleFinder,
	storage *mem.Storage,
) *WriteAroundCache

NewWriteAroundCache creates a new write-through cache, injecting the dependency of the engine, the directory and the storage.

func (*WriteAroundCache) Handle

func (c *WriteAroundCache) Handle(e akita.Event) error

func (*WriteAroundCache) NotifyPortFree

func (c *WriteAroundCache) NotifyPortFree(now akita.VTimeInSec, port akita.Port)

func (*WriteAroundCache) NotifyRecv

func (c *WriteAroundCache) NotifyRecv(now akita.VTimeInSec, port akita.Port)

func (*WriteAroundCache) Reset

func (c *WriteAroundCache) Reset()

func (*WriteAroundCache) SetNumBanks

func (c *WriteAroundCache) SetNumBanks(n int)

type WriteBackCache

type WriteBackCache struct {
	*akita.ComponentBase

	ToTop    akita.Port
	ToBottom akita.Port

	Directory Directory

	Storage *mem.Storage

	Freq                akita.Freq
	DirectoryLatency    int
	Latency             int
	NumBank             int
	BlockSizeAsPowerOf2 uint64
	// contains filtered or unexported fields
}

A WriteBackCache is a cache that performs the write-through policy

func NewWriteBackCache

func NewWriteBackCache(
	name string,
	engine akita.Engine,
	directory Directory,
	mshr MSHR,
	lowModuleFinder LowModuleFinder,
	storage *mem.Storage,
) *WriteBackCache

NewWriteBackCache creates a new write-through cache, injecting the dependency of the engine, the directory and the storage.

func (*WriteBackCache) Handle

func (c *WriteBackCache) Handle(e akita.Event) error

func (*WriteBackCache) NotifyPortFree

func (c *WriteBackCache) NotifyPortFree(now akita.VTimeInSec, port akita.Port)

func (*WriteBackCache) NotifyRecv

func (c *WriteBackCache) NotifyRecv(now akita.VTimeInSec, port akita.Port)

func (*WriteBackCache) SetNumBanks

func (c *WriteBackCache) SetNumBanks(n int)

type WriteCompleteEvent

type WriteCompleteEvent struct {
	*akita.EventBase

	WriteReq *mem.WriteReq
	Block    *Block
	Offset   uint64
}

A WriteCompleteEvent marks the completion of a write completion

func NewWriteCompleteEvent

func NewWriteCompleteEvent(
	time akita.VTimeInSec,
	handler akita.Handler,
) *WriteCompleteEvent

NewWriteCompleteEvent creates a new WriteCompleteEvent

type WriteFromBottomCompleteEvent

type WriteFromBottomCompleteEvent struct {
	*akita.EventBase

	DataReadyRsp *mem.DataReadyRsp
	ReadReq      *mem.ReadReq
	Block        *Block
}

WriteFromBottomCompleteEvent is the event that represents a cache write operation triggered by a DataReadyRsp from the bottom

func NewWriteFromBottomCompleteEvent

func NewWriteFromBottomCompleteEvent(
	time akita.VTimeInSec,
	handler akita.Handler,
) *WriteFromBottomCompleteEvent

NewWriteFromBottomCompleteEvent creates a new WriteCompleteEvent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL