mem

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 5 Imported by: 28

Documentation

Overview

Package mem and its subpackages provide definitions for memoy systems.

Index

Constants

View Source
const (
	KB uint64 = 1 << (10 * iota)
	MB
	GB
	TB
)

For capacity

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessReq

type AccessReq interface {
	sim.Msg
	GetAddress() uint64
	GetByteSize() uint64
	GetPID() vm.PID
}

AccessReq abstracts read and write requests that are sent to the cache modules or memory controllers.

type AccessRsp

type AccessRsp interface {
	sim.Msg
	sim.Rsp
}

A AccessRsp is a respond in the memory system.

type AddressConverter

type AddressConverter interface {
	ConvertExternalToInternal(external uint64) uint64
	ConvertInternalToExternal(internal uint64) uint64
}

AddressConverter can translate the address between two domains

type BankedLowModuleFinder

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

BankedLowModuleFinder defines the lower level modules by address banks

func NewBankedLowModuleFinder

func NewBankedLowModuleFinder(bankSize uint64) *BankedLowModuleFinder

NewBankedLowModuleFinder returns a new BankedLowModuleFinder.

func (*BankedLowModuleFinder) Find

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

Find returns the port that can provide the data.

type ControlMsg

type ControlMsg struct {
	sim.MsgMeta

	DiscardTransations bool
	Restart            bool
	NotifyDone         bool
}

ControlMsg is the commonly used message type for controlling the components on the memory hierarchy. It is also used for resonpding the original requester with the Done field.

func (*ControlMsg) Meta

func (m *ControlMsg) Meta() *sim.MsgMeta

Meta returns the meta data assocated with the ControlMsg.

type ControlMsgBuilder

type ControlMsgBuilder struct {
	// contains filtered or unexported fields
}

A ControlMsgBuilder can build control messages.

func (ControlMsgBuilder) Build

func (b ControlMsgBuilder) Build() *ControlMsg

Build creates a new ControlMsg.

func (ControlMsgBuilder) ToDiscardTransactions

func (b ControlMsgBuilder) ToDiscardTransactions() ControlMsgBuilder

ToDiscardTransactions sets the discard transactions bit of the control messages to 1.

func (ControlMsgBuilder) ToNotifyDone

func (b ControlMsgBuilder) ToNotifyDone() ControlMsgBuilder

ToNotifyDone sets the "notify done" bit of the control messages to 1.

func (ControlMsgBuilder) ToRestart

func (b ControlMsgBuilder) ToRestart() ControlMsgBuilder

ToRestart sets the restart bit of the control messages to 1.

func (ControlMsgBuilder) WithDst

WithDst sets the destination of the request to build.

func (ControlMsgBuilder) WithSendTime

func (b ControlMsgBuilder) WithSendTime(
	t sim.VTimeInSec,
) ControlMsgBuilder

WithSendTime sets the send time of the message to build.

func (ControlMsgBuilder) WithSrc

WithSrc sets the source of the request to build.

type DataReadyRsp

type DataReadyRsp struct {
	sim.MsgMeta

	RespondTo string // The ID of the request it replies
	Data      []byte
}

A DataReadyRsp is the respond sent from the lower module to the higher module that carries the data loaded.

func (*DataReadyRsp) GetRspTo

func (r *DataReadyRsp) GetRspTo() string

GetRspTo returns the ID if the request that the respond is responding to.

func (*DataReadyRsp) Meta

func (r *DataReadyRsp) Meta() *sim.MsgMeta

Meta returns the meta data attached to each message.

type DataReadyRspBuilder

type DataReadyRspBuilder struct {
	// contains filtered or unexported fields
}

DataReadyRspBuilder can build data ready responds.

func (DataReadyRspBuilder) Build

func (b DataReadyRspBuilder) Build() *DataReadyRsp

Build creates a new DataReadyRsp

func (DataReadyRspBuilder) WithData

func (b DataReadyRspBuilder) WithData(data []byte) DataReadyRspBuilder

WithData sets the data of the request to build.

func (DataReadyRspBuilder) WithDst

WithDst sets the destination of the request to build.

func (DataReadyRspBuilder) WithRspTo

WithRspTo sets ID of the request that the respond to build is replying to.

func (DataReadyRspBuilder) WithSendTime

WithSendTime sets the send time of the request to build.

func (DataReadyRspBuilder) WithSrc

WithSrc sets the source of the request to build.

type GL0InvalidateReq

type GL0InvalidateReq struct {
	sim.MsgMeta
	PID vm.PID
}

GL0InvalidateReq is a request that invalidates the L0 cache.

func (*GL0InvalidateReq) GetAddress

func (r *GL0InvalidateReq) GetAddress() uint64

GetAddress returns the address that the request is accessing

func (*GL0InvalidateReq) GetByteSize

func (r *GL0InvalidateReq) GetByteSize() uint64

GetByteSize returns the number of byte that the request is accessing.

func (*GL0InvalidateReq) GetPID

func (r *GL0InvalidateReq) GetPID() vm.PID

GetPID returns the process ID that the request is working on.

func (*GL0InvalidateReq) Meta

func (r *GL0InvalidateReq) Meta() *sim.MsgMeta

Meta returns the meta data associated with the message.

type GL0InvalidateReqBuilder

type GL0InvalidateReqBuilder struct {
	PID vm.PID
	// contains filtered or unexported fields
}

GL0InvalidateReqBuilder can build new GL0InvalidReq.

func (GL0InvalidateReqBuilder) Build

Build creates a new GL0InvalidateReq

func (GL0InvalidateReqBuilder) WithDst

WithDst sets the destination of the request to build.

func (GL0InvalidateReqBuilder) WithPID

WithPID sets the PID of the request to build.

func (GL0InvalidateReqBuilder) WithSendTime

WithSendTime sets the send time of the request to build.

func (GL0InvalidateReqBuilder) WithSrc

WithSrc sets the source of the request to build.

type GL0InvalidateRsp

type GL0InvalidateRsp struct {
	sim.MsgMeta
	PID       vm.PID
	RespondTo string
}

GL0InvalidateRsp is a response to a GL0InvalidateReq.

func (*GL0InvalidateRsp) GetAddress

func (r *GL0InvalidateRsp) GetAddress() uint64

GetAddress returns the address that the request is accessing

func (*GL0InvalidateRsp) GetByteSize

func (r *GL0InvalidateRsp) GetByteSize() uint64

GetByteSize returns the number of byte that the request is accessing.

func (*GL0InvalidateRsp) GetPID

func (r *GL0InvalidateRsp) GetPID() vm.PID

GetPID returns the process ID that the request is working on.

func (*GL0InvalidateRsp) GetRespondTo

func (r *GL0InvalidateRsp) GetRespondTo() string

GetRespondTo returns the ID if the request that the respond is responding to.

func (*GL0InvalidateRsp) GetRspTo

func (r *GL0InvalidateRsp) GetRspTo() string

GetRspTo returns the ID of the request that this response is responding to.

func (*GL0InvalidateRsp) Meta

func (r *GL0InvalidateRsp) Meta() *sim.MsgMeta

Meta returns the meta data associated with the message.

type GL0InvalidateRspBuilder

type GL0InvalidateRspBuilder struct {
	PID vm.PID
	// contains filtered or unexported fields
}

GL0InvalidateRspBuilder can build new GL0 Invalid Rsp Builder

func (GL0InvalidateRspBuilder) Build

Build creates a new CUPipelineRestartReq

func (GL0InvalidateRspBuilder) WithDst

WithDst sets the destination of the request to build.

func (GL0InvalidateRspBuilder) WithPID

WithPID sets the PID of the request to build.

func (GL0InvalidateRspBuilder) WithRspTo

WithRspTo sets ID of the request that the respond to build is replying to.

func (GL0InvalidateRspBuilder) WithSendTime

WithSendTime sets the send time of the request to build.:w

func (GL0InvalidateRspBuilder) WithSrc

WithSrc sets the source of the request to build.

type InterleavedLowModuleFinder

type InterleavedLowModuleFinder struct {
	UseAddressSpaceLimitation bool
	LowAddress                uint64
	HighAddress               uint64
	InterleavingSize          uint64
	LowModules                []sim.Port
	ModuleForOtherAddresses   sim.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) sim.Port

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

type InterleavingConverter

type InterleavingConverter struct {
	InterleavingSize    uint64
	TotalNumOfElements  int
	CurrentElementIndex int
	Offset              uint64
}

InterleavingConverter is an address converter that can converts the address from an continuous address space to interleaved addresses.

For example, DRAM is divided into multiple banks, the internal address of each bank starts from 0, while the global address is continuous. In this case, we can use the InterleavingConverter to convert the external addresses from/ to internal addresses.

func (InterleavingConverter) ConvertExternalToInternal

func (c InterleavingConverter) ConvertExternalToInternal(external uint64) uint64

ConvertExternalToInternal converts from external address to internal address

func (InterleavingConverter) ConvertInternalToExternal

func (c InterleavingConverter) ConvertInternalToExternal(internal uint64) uint64

ConvertInternalToExternal converts from internal address to external address

type LowModuleFinder

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

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

type ReadReq

type ReadReq struct {
	sim.MsgMeta

	Address            uint64
	AccessByteSize     uint64
	PID                vm.PID
	CanWaitForCoalesce bool
	Info               interface{}
}

A ReadReq is a request sent to a memory controller to fetch data

func (*ReadReq) GetAddress

func (r *ReadReq) GetAddress() uint64

GetAddress returns the address that the request is accessing

func (*ReadReq) GetByteSize

func (r *ReadReq) GetByteSize() uint64

GetByteSize returns the number of byte that the request is accessing.

func (*ReadReq) GetPID

func (r *ReadReq) GetPID() vm.PID

GetPID returns the process ID that the request is working on.

func (*ReadReq) Meta

func (r *ReadReq) Meta() *sim.MsgMeta

Meta returns the message meta.

type ReadReqBuilder

type ReadReqBuilder struct {
	// contains filtered or unexported fields
}

ReadReqBuilder can build read requests.

func (ReadReqBuilder) Build

func (b ReadReqBuilder) Build() *ReadReq

Build creates a new ReadReq

func (ReadReqBuilder) CanWaitForCoalesce

func (b ReadReqBuilder) CanWaitForCoalesce() ReadReqBuilder

CanWaitForCoalesce allow the request to build to wait for coalesce.

func (ReadReqBuilder) WithAddress

func (b ReadReqBuilder) WithAddress(address uint64) ReadReqBuilder

WithAddress sets the address of the request to build.

func (ReadReqBuilder) WithByteSize

func (b ReadReqBuilder) WithByteSize(byteSize uint64) ReadReqBuilder

WithByteSize sets the byte size of the request to build.

func (ReadReqBuilder) WithDst

func (b ReadReqBuilder) WithDst(dst sim.Port) ReadReqBuilder

WithDst sets the destination of the request to build.

func (ReadReqBuilder) WithInfo

func (b ReadReqBuilder) WithInfo(info interface{}) ReadReqBuilder

WithInfo sets the Info of the request to build.

func (ReadReqBuilder) WithPID

func (b ReadReqBuilder) WithPID(pid vm.PID) ReadReqBuilder

WithPID sets the PID of the request to build.

func (ReadReqBuilder) WithSendTime

func (b ReadReqBuilder) WithSendTime(t sim.VTimeInSec) ReadReqBuilder

WithSendTime sets the send time of the request to build.

func (ReadReqBuilder) WithSrc

func (b ReadReqBuilder) WithSrc(src sim.Port) ReadReqBuilder

WithSrc sets the source of the request to build.

type SingleLowModuleFinder

type SingleLowModuleFinder struct {
	LowModule sim.Port
}

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

func (*SingleLowModuleFinder) Find

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

Find simply returns the solo unit that it connects to

type Storage

type Storage struct {
	sync.Mutex
	Capacity uint64
	// contains filtered or unexported fields
}

A Storage keeps the data of the guest system.

A storage is an abstraction of all different type of storage including registers, main memory, and hard drives.

The storage implementation manages the storage in units. The unit can is similar to the concept of page in memory management. For the units that it not touched by Read and Write function, no memory will be allocated.

func NewStorage

func NewStorage(capacity uint64) *Storage

NewStorage creates a storage object with the specified capacity

func NewStorageWithUnitSize

func NewStorageWithUnitSize(capacity uint64, unitSize uint64) *Storage

NewStorageWithUnitSize creates a storage object with the specified capacity. The unit size is specified in bytes. Using unit size can reduces the memory consumption of storage.

func (*Storage) Read

func (s *Storage) Read(address uint64, len uint64) ([]byte, error)

func (*Storage) Write

func (s *Storage) Write(address uint64, data []byte) error

type WriteDoneRsp

type WriteDoneRsp struct {
	sim.MsgMeta

	RespondTo string
}

A WriteDoneRsp is a respond sent from the lower module to the higher module to mark a previous requests is completed successfully.

func (*WriteDoneRsp) GetRspTo

func (r *WriteDoneRsp) GetRspTo() string

GetRspTo returns the ID of the request that the respond is responding to.

func (*WriteDoneRsp) Meta

func (r *WriteDoneRsp) Meta() *sim.MsgMeta

Meta returns the meta data associated with the message.

type WriteDoneRspBuilder

type WriteDoneRspBuilder struct {
	// contains filtered or unexported fields
}

WriteDoneRspBuilder can build data ready responds.

func (WriteDoneRspBuilder) Build

func (b WriteDoneRspBuilder) Build() *WriteDoneRsp

Build creates a new WriteDoneRsp

func (WriteDoneRspBuilder) WithDst

WithDst sets the destination of the request to build.

func (WriteDoneRspBuilder) WithRspTo

WithRspTo sets ID of the request that the respond to build is replying to.

func (WriteDoneRspBuilder) WithSendTime

WithSendTime sets the send time of the message to build.

func (WriteDoneRspBuilder) WithSrc

WithSrc sets the source of the request to build.

type WriteReq

type WriteReq struct {
	sim.MsgMeta

	Address            uint64
	Data               []byte
	DirtyMask          []bool
	PID                vm.PID
	CanWaitForCoalesce bool
	Info               interface{}
}

A WriteReq is a request sent to a memory controller to write data

func (*WriteReq) GetAddress

func (r *WriteReq) GetAddress() uint64

GetAddress returns the address that the request is accessing

func (*WriteReq) GetByteSize

func (r *WriteReq) GetByteSize() uint64

GetByteSize returns the number of byte that the request is writing.

func (*WriteReq) GetPID

func (r *WriteReq) GetPID() vm.PID

GetPID returns the PID of the read address

func (*WriteReq) Meta

func (r *WriteReq) Meta() *sim.MsgMeta

Meta returns the meta data attached to a request.

type WriteReqBuilder

type WriteReqBuilder struct {
	// contains filtered or unexported fields
}

WriteReqBuilder can build read requests.

func (WriteReqBuilder) Build

func (b WriteReqBuilder) Build() *WriteReq

Build creates a new WriteReq

func (WriteReqBuilder) CanWaitForCoalesce

func (b WriteReqBuilder) CanWaitForCoalesce() WriteReqBuilder

CanWaitForCoalesce allow the request to build to wait for coalesce.

func (WriteReqBuilder) WithAddress

func (b WriteReqBuilder) WithAddress(address uint64) WriteReqBuilder

WithAddress sets the address of the request to build.

func (WriteReqBuilder) WithData

func (b WriteReqBuilder) WithData(data []byte) WriteReqBuilder

WithData sets the data of the request to build.

func (WriteReqBuilder) WithDirtyMask

func (b WriteReqBuilder) WithDirtyMask(mask []bool) WriteReqBuilder

WithDirtyMask sets the dirty mask of the request to build.

func (WriteReqBuilder) WithDst

func (b WriteReqBuilder) WithDst(dst sim.Port) WriteReqBuilder

WithDst sets the destination of the request to build.

func (WriteReqBuilder) WithInfo

func (b WriteReqBuilder) WithInfo(info interface{}) WriteReqBuilder

WithInfo sets the information attached to the request to build.

func (WriteReqBuilder) WithPID

func (b WriteReqBuilder) WithPID(pid vm.PID) WriteReqBuilder

WithPID sets the PID of the request to build.

func (WriteReqBuilder) WithSendTime

func (b WriteReqBuilder) WithSendTime(t sim.VTimeInSec) WriteReqBuilder

WithSendTime sets the send time of the message to build.

func (WriteReqBuilder) WithSrc

func (b WriteReqBuilder) WithSrc(src sim.Port) WriteReqBuilder

WithSrc sets the source of the request to build.

Jump to

Keyboard shortcuts

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