flamego

package module
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: 1 Imported by: 1

README

Flame

Computing from Scratch

Instruction Set Architecture

Defines the operations and encoding formats.

Assembler

Converts plain text assembly into machine code.

Virtual Machine

Simulates basic building blocks of hardware.

Bootloader

Initializes machine and loads operating system from storage

Kernel

Manages computer resources.

  • Communication Manager
  • Process Manager
  • Memory Manager
  • IO Manager

Operating System

  • Device Drivers
  • Utilities
  • Shell/Terminal
  • User Interface/User Experience

Documentation

Index

Constants

View Source
const (
	// Unit: Bytes
	LineWidthL1Cache = 64
	LineWidthL2Cache = 512
	LineWidthL3Cache = 4096

	// Unit: Bits
	OffsetBitsL1Cache = 6
	OffsetBitsL2Cache = 9
	OffsetBitsL3Cache = 12
)
View Source
const (
	// Unit: Bytes
	DataSize = 8

	// Unit: Bytes
	KB = 1024
	MB = 1024 * KB
	GB = 1024 * MB
	TB = 1024 * GB

	// Unit: Bytes
	SizeMemory  = 1 * MB //1 * GB
	SizeL3Cache = 1 * MB
	SizeL2Cache = 32 * KB
	SizeL1Cache = 1 * KB
)
View Source
const (
	DeviceControlBlockAddress = 512
	DeviceControlBlockSize    = 24
)
View Source
const (
	DeviceOffsetCommand uint32 = iota // 8bit controller, 8bit operation, 48bit parameter
	DeviceOffsetDeviceAddress
	DeviceOffsetMemoryAddress
)
View Source
const (
	RegisterCount = 32

	RCoreIdentifier       = R2
	RContextIdentifier    = R3
	RInterruptVectorTable = R4
	RProcessIdentifier    = R5
	RProgramCounter       = R6
	RProgramStart         = R7
	RProgramLimit         = R8
	RStackPointer         = R9
	RStackStart           = R10
	RStackLimit           = R11
	RDataStart            = R12
	RDataLimit            = R13
)
View Source
const (
	// Unit: Bytes
	BusSize = 8
)
View Source
const ContextCount = 8
View Source
const CoreCount = 8
View Source
const InstructionSize = 4
View Source
const InterruptCount = 9

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus interface {
	Size() int
	IsValid(int) bool
	SetValid(int, bool)
	IsDirty(int) bool
	SetDirty(int, bool)
	Read(int) byte
	Write(int, byte)
	ReadFrom(Bus)
	WriteTo(Bus, int)
}

type Cache

type Cache interface {
	Store
	Clear(uint64)
	Flush(uint64)
}

type CacheOperation

type CacheOperation uint8
const (
	CacheNone CacheOperation = iota
	CacheRead
	CacheWrite
	CacheClear
	CacheFlush
)

func (CacheOperation) String

func (o CacheOperation) String() string

type Clockable

type Clockable interface {
	Clock(int)
}

type Context

type Context interface {
	Id() int

	Core() Core
	InstructionCache() Cache
	DataCache() Cache

	IsValid() bool
	IsAsleep() bool
	Sleep()
	Error(InterruptValue)
	IsInterrupted() bool
	SetInterrupted(bool)
	Signal()
	IsSignalled() bool

	RequiresLock() bool
	SetRequiresLock(bool)
	AcquiredLock() bool
	SetAcquiredLock(bool)

	FetchInstruction()
	LoadInstruction()
	DecodeInstruction()
	LoadData() (uint64, uint64, uint64, uint64)
	ExecuteOperation(uint64, uint64, uint64, uint64) (uint64, uint64)
	FormatData(uint64, uint64) (uint64, uint64)
	StoreData(uint64, uint64)
	RetireInstruction()

	ReadRegister(Register) uint64
	WriteRegister(Register, uint64)
	IncrementProgramCounter()
	SetProgramCounter(uint64)
}

type Core

type Core interface {
	Clockable

	Id() int
	Processor() Processor
	Context(int) Context
	Cache() Cache

	AddContext(Context)

	RequiresLock() bool
	SetAcquiredLock(bool)
}

type Device

type Device interface {
	Clockable

	Signal()

	SetOnSignal(func(int))
}

type DeviceOperation

type DeviceOperation uint32
const (
	DeviceNone DeviceOperation = iota
	DeviceStatus
	DeviceEnable
	DeviceDisable
	DeviceRead
	DeviceWrite
)

func (DeviceOperation) String

func (o DeviceOperation) String() string

type Instruction

type Instruction interface {
	fmt.Stringer
	Load(Context) (uint64, uint64, uint64, uint64)
	Execute(Context, uint64, uint64, uint64, uint64) (uint64, uint64)
	Format(Context, uint64, uint64) (uint64, uint64)
	Store(Context, uint64, uint64)
	Retire(Context) bool
}

type InterruptValue

type InterruptValue int16
const (
	InterruptSignal InterruptValue = iota
	InterruptBreakpoint
	InterruptUnsupportedOperationError
	InterruptArithmeticError
	InterruptRegisterAccessError
	InterruptMemoryAccessError
	InterruptProgramAccessError
	InterruptStackOverflowError
	InterruptStackUnderflowError
)

func (InterruptValue) String

func (i InterruptValue) String() string

type Memory

type Memory interface {
	Store
}

type MemoryOperation

type MemoryOperation uint8
const (
	MemoryNone MemoryOperation = iota
	MemoryRead
	MemoryWrite
)

func (MemoryOperation) String

func (o MemoryOperation) String() string

type Processor

type Processor interface {
	Clockable

	Cache() Cache
	Core(int) Core
	AddCore(Core)
	Device(int) Device
	AddDevice(Device)

	Halt()
	HasHalted() bool

	Signal(int)
}

type Register

type Register uint8
const (
	R0  Register = iota // RO, Always 0
	R1                  // RO, Always 1
	R2                  // RO, Core Identifier (0-7)
	R3                  // RO, Context Identifier (0-7)
	R4                  // PR, Interrupt Vector Table
	R5                  // PR, Process Identifier
	R6                  // PR, Program Counter (offset from Program Start)
	R7                  // PR, Program Start
	R8                  // PR, Program Limit
	R9                  // PR, Stack Pointer
	R10                 // PR, Stack Start
	R11                 // PR, Stack Limit
	R12                 // PR, Data Start
	R13                 // PR, Data Limit
	R14                 // PR, Reserved
	R15                 // PR, Reserved
	R16                 // GP
	R17                 // GP
	R18                 // GP
	R19                 // GP
	R20                 // GP
	R21                 // GP
	R22                 // GP
	R23                 // GP
	R24                 // GP
	R25                 // GP
	R26                 // GP
	R27                 // GP
	R28                 // GP
	R29                 // GP
	R30                 // GP
	R31                 // GP
)

func (Register) String

func (r Register) String() string

type Store

type Store interface {
	Clockable

	Bus() Bus

	IsBusy() bool
	IsFree() bool
	Free()
	IsSuccessful() bool

	Read(uint64)
	Write(uint64)
}

Directories

Path Synopsis
cmd
fvm

Jump to

Keyboard shortcuts

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