memory

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package memory holds an interface for main memory emulation, similar to akita.mem.Storage

TODO: TEMPORARY PACKAGE. The contained files should be moved to vemulator when a larger refactor is possible.

Index

Constants

View Source
const (

	// RowBytes describes the byte length of a cache row.
	RowBytes uint64 = 16
	// RowAlignMask is used to align an address to a row boundary.
	RowAlignMask uint64 = ^(RowBytes - 1)
)

Variables

This section is empty.

Functions

func GetElf

func GetElf(binaryPath string) *elf.File

GetElf retrieves the elf file object for the filepath.

func LoadPrograms

func LoadPrograms(storage Loadable, elfFile *elf.File)

LoadPrograms writes the LOAD prog headers to the provided storage.

Types

type BasicMem

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

BasicMem is a memory unit that also contains an HTIF.

func NewBasicMem

func NewBasicMem(cap uint64, xlen riscv.Xlen) *BasicMem

NewBasicMem returns a new instance of HTIFMem, containing a MemWrapper core and barrier used to trigger HTIF requests.

func (*BasicMem) Read

func (h *BasicMem) Read(addr uint64, len uint64) ([]byte, error)

Read retrieves data from the memory unit.

func (*BasicMem) Write

func (h *BasicMem) Write(addr uint64, data []byte) error

Write updates data in the unit and checks if the HTIF was written.

type Cache32

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

Cache32 is a set-associative cache that can read in 32-bit chunks.

This implementation is not intended to be written to by the CPU core. The use of dynamic structures is restricted for performance.

func NewCache32

func NewCache32(xlen riscv.Xlen) Cache32

NewCache32 creates a new instance of Cache32

func (*Cache32) Populate

func (b *Cache32) Populate(addr uint64, data [RowBytes]byte)

Populate adds a new line to the cache

func (*Cache32) Read16

func (b *Cache32) Read16(addr uint64) (data uint16, ok bool)

Read16 reads retrieves a uint16 from the cache.

func (*Cache32) Read32

func (b *Cache32) Read32(addr uint64) (data uint32, ok bool)

Read32 reads retrieves a uint32 from the cache.

type Loadable

type Loadable interface {
	Write(address uint64, data []byte) error
}

A Loadable is a memory structure to which data can be written.

type Loader

type Loader interface {
	Load(store Loadable)
	Entry() uint64
	// TODO: This should not be part of this interface. The HTIF (and similar
	// functionality) should be broken out into a separate module.
	ToHostAddr() uint64
}

Loader loads a program into memory. Each implementation makes different assumptions regarding the layout of the elf in memory.

type Mem

type Mem interface {
	Read(addr uint64, len uint64) ([]byte, error)
	Write(addr uint64, data []byte) error
}

Mem is the most basic interface to a memory unit.

type SpikeLoad

type SpikeLoad struct {
	*elf.File
	// contains filtered or unexported fields
}

SpikeLoad loads a program into memory.

This implementation assumes that the elf was compiled to run on the Spike ISA simulator.

func NewSpikeLoad

func NewSpikeLoad(elfPath string, xlen riscv.Xlen) *SpikeLoad

NewSpikeLoad initializes a new loader for the given elf path.

func (SpikeLoad) Entry

func (s SpikeLoad) Entry() uint64

Entry retrieves the elf entry point.

func (SpikeLoad) Load

func (s SpikeLoad) Load(store Loadable)

Load loads a baremetal program into the passed storage.

func (SpikeLoad) ToHostAddr

func (s SpikeLoad) ToHostAddr() uint64

ToHostAddr retrieves the tohost interface memory address.

Jump to

Keyboard shortcuts

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