cache

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2019 License: MIT Imports: 3 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
	ReadCount    int
	IsLocked     bool
	DirtyMask    []bool
}

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

type Directory

type Directory interface {
	Lookup(address uint64) *Block
	FindVictim(address uint64) *Block
	Visit(block *Block)
	TotalSize() uint64
	WayAssociativity() int
	GetSets() []Set
	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 address or physical address) to the cache based address.

func NewDirectory

func NewDirectory(
	set, way, blockSize int,
	victimFinder VictimFinder,
) *DirectoryImpl

NewDirectory returns a new directory object

func (*DirectoryImpl) FindVictim added in v1.1.5

func (d *DirectoryImpl) FindVictim(addr uint64) *Block

FindVictim returns a block that can be used to stored data at address addr.

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

func (*DirectoryImpl) GetSets added in v1.1.5

func (d *DirectoryImpl) GetSets() []Set

GetSets returns all the sets in a directory

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) Visit added in v1.1.5

func (d *DirectoryImpl) Visit(block *Block)

Visit moves the block to the end of the LRUQueue

func (*DirectoryImpl) WayAssociativity

func (d *DirectoryImpl) WayAssociativity() int

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

type FlushReq added in v1.1.5

type FlushReq struct {
	*akita.ReqBase
}

FlushReq is the request send to a cache unit to request it to flush all the cache lines.

func NewFlushReq added in v1.1.5

func NewFlushReq(time akita.VTimeInSec, src, dst akita.Port) *FlushReq

NewFlushReq creates a new flush request

type FlushRsp added in v1.1.5

type FlushRsp struct {
	*akita.ReqBase
	RspTo string
}

FlushRsp is the respond sent from the a cache unit for finishing a cache flush

func NewFlushRsp added in v1.1.5

func NewFlushRsp(
	time akita.VTimeInSec,
	src, dst akita.Port,
	rspTo string,
) *FlushRsp

NewFlushRsp creates a new flush response

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 LRUVictimFinder added in v1.1.5

type LRUVictimFinder struct {
}

LRUVictimFinder evicts the least recently used block to evict

func NewLRUVictimFinder added in v1.1.5

func NewLRUVictimFinder() *LRUVictimFinder

NewLRUVictimFinder returns a newly constructed lru evictor

func (*LRUVictimFinder) FindVictim added in v1.1.5

func (e *LRUVictimFinder) FindVictim(set *Set) *Block

FindVictim returns the least recently used block in a set

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
	Add(addr uint64) *MSHREntry
	Remove(addr uint64) *MSHREntry
	AllEntries() []*MSHREntry
	IsFull() bool
}

MSHR is an interface that controls MSHR entries

type MSHREntry

type MSHREntry struct {
	Requests  []interface{}
	Block     *Block
	ReadReq   *mem.ReadReq
	DataReady *mem.DataReadyRsp
	Data      []byte
}

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) AllEntries added in v1.1.5

func (m *MSHRImpl) AllEntries() []*MSHREntry

AllEntries returns all the MSHREntries that are currently in the MSHR

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) Remove

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

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

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

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 VictimFinder added in v1.1.5

type VictimFinder interface {
	FindVictim(set *Set) *Block
}

A VictimFinder decides with block should be evicted

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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