mem

package module
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 4 Imported by: 0

README

Akita Memory Model

Discord

Go Report Card Test Coverage

This repository contains the definition and the implementation for memory system components.

Please check here For detailed documentation.

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 {
	akita.Msg
	GetAddress() uint64
	GetByteSize() uint64
	GetPID() ca.PID
}

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

type AccessRsp

type AccessRsp interface {
	akita.Msg
	GetRespondTo() string
}

A AccessRsp is a respond in the memory system.

type DataReadyRsp

type DataReadyRsp struct {
	akita.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) GetRespondTo

func (r *DataReadyRsp) GetRespondTo() string

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

func (*DataReadyRsp) Meta

func (r *DataReadyRsp) Meta() *akita.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 ReadReq

type ReadReq struct {
	akita.MsgMeta

	Address            uint64
	AccessByteSize     uint64
	PID                ca.PID
	CanWaitForCoalesce bool
}

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() ca.PID

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

func (*ReadReq) Meta

func (r *ReadReq) Meta() *akita.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 akita.Port) ReadReqBuilder

WithDst sets the destination of the request to build.

func (ReadReqBuilder) WithPID

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

WithPID sets the PID of the request to build.

func (ReadReqBuilder) WithSendTime

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

WithSendTime sets the send time of the request to build.

func (ReadReqBuilder) WithSrc

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

WithSrc sets the source of the request to build.

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 mmemory 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 (*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 WriteBuffer

type WriteBuffer interface {
	Tick(now akita.VTimeInSec) bool
	CanEnqueue() bool
	Enqueue(write *WriteReq)
	Query(read *ReadReq) *WriteReq
	SetWriteCombineGranularity(size uint64)
}

WriteBuffer is a place where the write can be transferred at a later time.

func NewWriteBuffer

func NewWriteBuffer(capacity int, port akita.Port) WriteBuffer

NewWriteBuffer creates and returns a default write buffer

type WriteDoneRsp

type WriteDoneRsp struct {
	akita.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) GetRespondTo

func (r *WriteDoneRsp) GetRespondTo() string

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

func (*WriteDoneRsp) Meta

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

Meta returns the meta data accociated 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 {
	akita.MsgMeta

	Address            uint64
	Data               []byte
	DirtyMask          []bool
	PID                ca.PID
	CanWaitForCoalesce bool
}

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() ca.PID

GetPID returns the PID of the read address

func (*WriteReq) Meta

func (r *WriteReq) Meta() *akita.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 akita.Port) WriteReqBuilder

WithDst sets the destination of the request to build.

func (WriteReqBuilder) WithPID

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

WithPID sets the PID of the request to build.

func (WriteReqBuilder) WithSendTime

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

WithSendTime sets the send time of the message to build.

func (WriteReqBuilder) WithSrc

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

WithSrc sets the source of the request to build.

Directories

Path Synopsis
Package acceptancetests provides utility data structure definitions for writing memory system acceptance tests.
Package acceptancetests provides utility data structure definitions for writing memory system acceptance tests.
Package cache provides the basic commonly used utility data structures for cache implementation.
Package cache provides the basic commonly used utility data structures for cache implementation.
writeback
Package writeback implement a writeback cache.=
Package writeback implement a writeback cache.=
Package idealmemcontroller provides an implementation of an ideal memory controller, which has a fix latency and unlimited concurrency.
Package idealmemcontroller provides an implementation of an ideal memory controller, which has a fix latency and unlimited concurrency.
Package trace provides a tracer that can trace memory system tasks.
Package trace provides a tracer that can trace memory system tasks.
vm
Package vm provides the models for address translations
Package vm provides the models for address translations
addresstranslator
Package addresstranslator implements a component that can forward the translated read and write request to the bottom memory unit.
Package addresstranslator implements a component that can forward the translated read and write request to the bottom memory unit.
mmu
Package mmu provides a Memory Management Unit implementation.
Package mmu provides a Memory Management Unit implementation.
tlb
Package tlb provides a TLB component implementation.
Package tlb provides a TLB component implementation.
tlb/internal
Package internal provides the definition required for defining TLB.
Package internal provides the definition required for defining TLB.

Jump to

Keyboard shortcuts

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