riscvemu

package module
v0.0.0-...-49a1f26 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: ISC Imports: 3 Imported by: 0

README

riscvemu

An interpreter for the RV32I instruction set.

Features:

  • Supports RV32I base instructions only (so far)
  • Page-based virtual memory, with custom memory traps and syscalls
  • Install with Go Modules (go get code.ivysaur.me/riscvemu)

License

ISC License

The source code includes quotations from the RISC-V Instruction Set Manual under the Creative Commons Attribution 4.0 International License.

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUState

type CPUState struct {
	Registers [32]uint32
	Pc        uint32
	// contains filtered or unexported fields
}

func NewCPU

func NewCPU(w EEI) CPUState

func (*CPUState) ReadRegister

func (c *CPUState) ReadRegister(r uint32) uint32

func (*CPUState) Step

func (c *CPUState) Step() error

type EEI

type EEI interface {
	ReadByte(addr uint32) (byte, error)
	Read16(addr uint32) (uint16, error)
	Read32(addr uint32) (uint32, error)

	WriteByte(addr uint32, value byte) error
	Write16(addr uint32, value uint16) error
	Write32(addr, value uint32) error

	Syscall() error

	MemFence(opcode uint32) error
}

EEI (Execution Environment Interface) is the enivronment in which RISC-V code is run.

type ErrBreak

type ErrBreak struct{}

func (ErrBreak) Error

func (e ErrBreak) Error() string

type ErrInvalidOpcode

type ErrInvalidOpcode struct{}

func (ErrInvalidOpcode) Error

func (e ErrInvalidOpcode) Error() string

type VirtualEEI

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

func NewVirtualEEI

func NewVirtualEEI() VirtualEEI

func (*VirtualEEI) MemFence

func (ve *VirtualEEI) MemFence(opcode uint32) error

func (*VirtualEEI) Read16

func (ve *VirtualEEI) Read16(addr uint32) (uint16, error)

func (*VirtualEEI) Read32

func (ve *VirtualEEI) Read32(addr uint32) (uint32, error)

func (*VirtualEEI) ReadByte

func (ve *VirtualEEI) ReadByte(addr uint32) (byte, error)

func (*VirtualEEI) Syscall

func (ve *VirtualEEI) Syscall() error

func (*VirtualEEI) Write16

func (ve *VirtualEEI) Write16(addr uint32, value uint16) error

func (*VirtualEEI) Write32

func (ve *VirtualEEI) Write32(addr, value uint32) error

func (*VirtualEEI) WriteAt

func (ve *VirtualEEI) WriteAt(p []byte, off int64) (n int, err error)

WriteAt implements the io.WriterAt interface on top of the EEI's virtual memory.

func (*VirtualEEI) WriteByte

func (ve *VirtualEEI) WriteByte(addr uint32, value byte) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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