vm

package
v0.0.0-...-bcc578f Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

README

Virtual Machine

Processor

  • 64bit RISC Architecture
  • Barrel Design
  • 8 Cores per Processor
  • 8 Contexts per Core
  • 8-Stage Pipeline
    • Fetch Instruction
    • Load Instruction
    • Decode Instruction
    • Load Data
    • Execute Operation
    • Format Data
    • Store Data
    • Retire Instruction
  • 32 Registers per Context
    • r0 : r15 - Special Purpose
    • r16 : r31 - General Purpose

Cache

  • 8 x 256KB L1 Instruction (1 per Core)
  • 8 x 256KB L1 Data (1 per Core)
  • 1 x 8MB L2 (1 shared between 8 Cores)

Memory

  • 1GB

IO Devices

  • Storage
  • Display
  • Keyboard

Documentation

Index

Constants

View Source
const (
	ReadCommand       = flamego.MemoryOperation(3)
	ReadDeviceAddress = flamego.MemoryOperation(4)
	ReadMemoryAddress = flamego.MemoryOperation(5)
)
View Source
const PixelBytes = 4

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

func NewBus

func NewBus(size int) *Bus

func (*Bus) Data

func (b *Bus) Data() []byte

func (*Bus) IsDirty

func (b *Bus) IsDirty(offset int) bool

func (*Bus) IsValid

func (b *Bus) IsValid(offset int) bool

func (*Bus) Read

func (b *Bus) Read(offset int) byte

func (*Bus) ReadFrom

func (b *Bus) ReadFrom(bus flamego.Bus)

func (*Bus) SetDirty

func (b *Bus) SetDirty(offset int, dirty bool)

func (*Bus) SetValid

func (b *Bus) SetValid(offset int, valid bool)

func (*Bus) Size

func (b *Bus) Size() int

func (*Bus) Write

func (b *Bus) Write(offset int, value byte)

func (*Bus) WriteTo

func (b *Bus) WriteTo(bus flamego.Bus, offset int)

type Cache

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

func NewCache

func NewCache(size, lineWidth, busWidth, offsetBits int, lower flamego.Store) *Cache

func NewL1Cache

func NewL1Cache(size int, lower flamego.Store) *Cache

func NewL2Cache

func NewL2Cache(size int, lower flamego.Store) *Cache

func NewL3Cache

func NewL3Cache(size int, lower flamego.Store) *Cache

func (*Cache) Address

func (c *Cache) Address() uint64

func (*Cache) Bus

func (c *Cache) Bus() flamego.Bus

func (*Cache) Clear

func (c *Cache) Clear(address uint64)

func (*Cache) Clock

func (c *Cache) Clock(cycle int)

func (*Cache) CreateAddress

func (c *Cache) CreateAddress(tag, index, offset uint64) uint64

func (*Cache) Flush

func (c *Cache) Flush(address uint64)

func (*Cache) Free

func (c *Cache) Free()

func (*Cache) IndexBits

func (c *Cache) IndexBits() int

func (*Cache) IsBusy

func (c *Cache) IsBusy() bool

func (*Cache) IsFree

func (c *Cache) IsFree() bool

func (*Cache) IsSuccessful

func (c *Cache) IsSuccessful() bool

func (*Cache) LineWidth

func (c *Cache) LineWidth() int

func (*Cache) Lines

func (c *Cache) Lines() []*CacheLine

func (*Cache) LowerAddress

func (c *Cache) LowerAddress() uint64

func (*Cache) LowerOperation

func (c *Cache) LowerOperation() flamego.CacheOperation

func (*Cache) OffsetBits

func (c *Cache) OffsetBits() int

func (*Cache) Operation

func (c *Cache) Operation() flamego.CacheOperation

func (*Cache) ParseAddress

func (c *Cache) ParseAddress(a uint64) (uint64, uint64, uint64)

func (*Cache) Read

func (c *Cache) Read(address uint64)

func (*Cache) Size

func (c *Cache) Size() int

func (*Cache) TagBits

func (c *Cache) TagBits() int

func (*Cache) Write

func (c *Cache) Write(address uint64)

type CacheLine

type CacheLine struct {
	Bus
	// contains filtered or unexported fields
}

func NewCacheLine

func NewCacheLine(size int) *CacheLine

func (*CacheLine) Tag

func (c *CacheLine) Tag() uint64

type Context

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

func NewContext

func NewContext(id int, c *Core, l1ICache flamego.Cache, l1DCache flamego.Cache) *Context

func (*Context) AcquiredLock

func (x *Context) AcquiredLock() bool

func (*Context) Core

func (x *Context) Core() flamego.Core

func (*Context) DataCache

func (x *Context) DataCache() flamego.Cache

func (*Context) DecodeInstruction

func (x *Context) DecodeInstruction()

func (*Context) Error

func (x *Context) Error(value flamego.InterruptValue)

func (*Context) ExecuteOperation

func (x *Context) ExecuteOperation(a, b, c, d uint64) (uint64, uint64)

func (*Context) FetchInstruction

func (x *Context) FetchInstruction()

func (*Context) FormatData

func (x *Context) FormatData(e, f uint64) (uint64, uint64)

func (*Context) Id

func (x *Context) Id() int

func (*Context) IncrementProgramCounter

func (x *Context) IncrementProgramCounter()

func (*Context) Instruction

func (x *Context) Instruction() flamego.Instruction

func (*Context) InstructionCache

func (x *Context) InstructionCache() flamego.Cache

func (*Context) InstructionString

func (x *Context) InstructionString() string

func (*Context) IsAligned

func (x *Context) IsAligned() bool

func (*Context) IsAsleep

func (x *Context) IsAsleep() bool

func (*Context) IsInterrupted

func (x *Context) IsInterrupted() bool

func (*Context) IsRetrying

func (x *Context) IsRetrying() bool

func (*Context) IsSignalled

func (x *Context) IsSignalled() bool

func (*Context) IsValid

func (x *Context) IsValid() bool

func (*Context) LoadData

func (x *Context) LoadData() (uint64, uint64, uint64, uint64)

func (*Context) LoadInstruction

func (x *Context) LoadInstruction()

func (*Context) NextInterrupt

func (x *Context) NextInterrupt() flamego.InterruptValue

func (*Context) Opcode

func (x *Context) Opcode() uint32

func (*Context) ReadRegister

func (x *Context) ReadRegister(register flamego.Register) uint64

func (*Context) RequiresLock

func (x *Context) RequiresLock() bool

func (*Context) RetireInstruction

func (x *Context) RetireInstruction()

func (*Context) SetAcquiredLock

func (x *Context) SetAcquiredLock(acquired bool)

func (*Context) SetInterrupted

func (x *Context) SetInterrupted(i bool)

func (*Context) SetProgramCounter

func (x *Context) SetProgramCounter(pc uint64)

func (*Context) SetRequiresLock

func (x *Context) SetRequiresLock(required bool)

func (*Context) Signal

func (x *Context) Signal()

func (*Context) Sleep

func (x *Context) Sleep()

func (*Context) SleepCycles

func (x *Context) SleepCycles() int

func (*Context) Status

func (x *Context) Status() string

func (*Context) StoreData

func (x *Context) StoreData(g, h uint64)

func (*Context) WriteRegister

func (x *Context) WriteRegister(register flamego.Register, value uint64)

type Core

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

func NewCore

func NewCore(id int, processor flamego.Processor, cache flamego.Cache) *Core

func (*Core) AcquiredLock

func (c *Core) AcquiredLock() bool

func (*Core) AddContext

func (c *Core) AddContext(x flamego.Context)

func (*Core) Cache

func (c *Core) Cache() flamego.Cache

func (*Core) Clock

func (c *Core) Clock(cycle int)

func (*Core) Context

func (c *Core) Context(index int) flamego.Context

func (*Core) ExecuteRegister0

func (c *Core) ExecuteRegister0() uint64

func (*Core) ExecuteRegister1

func (c *Core) ExecuteRegister1() uint64

func (*Core) FormatRegister0

func (c *Core) FormatRegister0() uint64

func (*Core) FormatRegister1

func (c *Core) FormatRegister1() uint64

func (*Core) Id

func (c *Core) Id() int

func (*Core) LoadRegister0

func (c *Core) LoadRegister0() uint64

func (*Core) LoadRegister1

func (c *Core) LoadRegister1() uint64

func (*Core) LoadRegister2

func (c *Core) LoadRegister2() uint64

func (*Core) LoadRegister3

func (c *Core) LoadRegister3() uint64

func (*Core) LockHolder

func (c *Core) LockHolder() int

func (*Core) NextContext

func (c *Core) NextContext() int

Index of the next context to fetch an instruction

func (*Core) Processor

func (c *Core) Processor() flamego.Processor

func (*Core) RequiresLock

func (c *Core) RequiresLock() bool

func (*Core) SetAcquiredLock

func (c *Core) SetAcquiredLock(acquired bool)

type Device

type Device struct {
	OnMemoryRead  func() error
	OnMemoryWrite func() error
	OnSignal      func(int)
	// contains filtered or unexported fields
}

func NewDevice

func NewDevice(m flamego.Memory, o uint64) *Device

func (*Device) AddOperation

func (d *Device) AddOperation(o flamego.DeviceOperation, f func() error)

func (*Device) Clock

func (d *Device) Clock(cycle int)

func (*Device) Command

func (d *Device) Command() uint64

func (*Device) Controller

func (d *Device) Controller() int

func (*Device) CopyCommand

func (d *Device) CopyCommand()

func (*Device) CopyData

func (d *Device) CopyData() uint64

func (*Device) CopyDeviceAddress

func (d *Device) CopyDeviceAddress()

func (*Device) CopyMemoryAddress

func (d *Device) CopyMemoryAddress()

func (*Device) DeviceAddress

func (d *Device) DeviceAddress() uint64

func (*Device) IsBusy

func (d *Device) IsBusy() bool

func (*Device) MemoryAddress

func (d *Device) MemoryAddress() uint64

func (*Device) MemoryOffset

func (d *Device) MemoryOffset() uint64

func (*Device) MemoryOperation

func (d *Device) MemoryOperation() flamego.MemoryOperation

func (*Device) Operation

func (d *Device) Operation() flamego.DeviceOperation

func (*Device) Parameter

func (d *Device) Parameter() uint64

func (*Device) ReadCommand

func (d *Device) ReadCommand()

func (*Device) ReadDeviceAddress

func (d *Device) ReadDeviceAddress()

func (*Device) ReadMemoryAddress

func (d *Device) ReadMemoryAddress()

func (*Device) SetOnSignal

func (d *Device) SetOnSignal(s func(int))

func (*Device) Signal

func (d *Device) Signal()

func (*Device) SignalController

func (d *Device) SignalController()

type Display

type Display struct {
	Device
	// contains filtered or unexported fields
}

func NewDisplay

func NewDisplay(m flamego.Memory, o uint64, w, h int) *Display

func (*Display) Disable

func (d *Display) Disable() error

func (*Display) Enable

func (d *Display) Enable() error

func (*Display) FetchFrame

func (d *Display) FetchFrame() error

func (*Display) Image

func (d *Display) Image() image.Image

func (*Display) LoadFrame

func (d *Display) LoadFrame() error

func (*Display) Status

func (d *Display) Status() error

type FileStorage

type FileStorage struct {
	Device
	// contains filtered or unexported fields
}

func NewFileStorage

func NewFileStorage(m flamego.Memory, o uint64) *FileStorage

func (*FileStorage) Close

func (s *FileStorage) Close() error

func (*FileStorage) Disable

func (s *FileStorage) Disable() error

func (*FileStorage) Enable

func (s *FileStorage) Enable() error

func (*FileStorage) File

func (s *FileStorage) File() *os.File

func (*FileStorage) Open

func (s *FileStorage) Open(path string) error

func (*FileStorage) Read

func (s *FileStorage) Read() error

func (*FileStorage) Status

func (s *FileStorage) Status() error

func (*FileStorage) Write

func (s *FileStorage) Write() error

type Machine

type Machine struct {
	Processor *Processor
	Memory    *Memory

	Tick int
}

func NewMachine

func NewMachine() *Machine

func (*Machine) Clock

func (m *Machine) Clock()

type Memory

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

func NewMemory

func NewMemory(size int) *Memory

func (*Memory) Address

func (m *Memory) Address() uint64

func (*Memory) Bus

func (m *Memory) Bus() flamego.Bus

func (*Memory) Clock

func (m *Memory) Clock(cycle int)

func (*Memory) Data

func (m *Memory) Data() []byte

func (*Memory) Free

func (m *Memory) Free()

func (*Memory) IsBusy

func (m *Memory) IsBusy() bool

func (*Memory) IsFree

func (m *Memory) IsFree() bool

func (*Memory) IsSuccessful

func (m *Memory) IsSuccessful() bool

func (*Memory) Load

func (m *Memory) Load(r io.Reader) (int, error)

func (*Memory) Operation

func (m *Memory) Operation() flamego.MemoryOperation

func (*Memory) Read

func (m *Memory) Read(address uint64)

func (*Memory) Set

func (m *Memory) Set(address uint64, data []byte)

func (*Memory) Size

func (m *Memory) Size() int

func (*Memory) Write

func (m *Memory) Write(address uint64)

type Processor

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

func NewProcessor

func NewProcessor(cache flamego.Cache, memory flamego.Memory) *Processor

func (*Processor) AddCore

func (p *Processor) AddCore(c flamego.Core)

func (*Processor) AddDevice

func (p *Processor) AddDevice(d flamego.Device)

func (*Processor) Cache

func (p *Processor) Cache() flamego.Cache

func (*Processor) Clock

func (p *Processor) Clock(cycle int)

func (*Processor) Core

func (p *Processor) Core(index int) flamego.Core

func (*Processor) Device

func (p *Processor) Device(index int) flamego.Device

func (*Processor) Halt

func (p *Processor) Halt()

func (*Processor) HasHalted

func (p *Processor) HasHalted() bool

func (*Processor) LockHolder

func (p *Processor) LockHolder() int

func (*Processor) Signal

func (p *Processor) Signal(device int)

Jump to

Keyboard shortcuts

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