iris2

package
v0.0.0-...-1646a41 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2016 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

instruction decoder module

Multiplexer circuit

machine description of iris1

move related operations

Multiplexer circuit

register file execution unit

Index

Constants

View Source
const (
	IntegerAdd = iota
	IntegerSubtract
	IntegerMultiply
	IntegerDivide
	IntegerRemainder
	IntegerShiftLeft
	IntegerShiftRight
	IntegerAnd
	IntegerOr
	IntegerNot
	IntegerXor
	IntegerAndNot
	IntegerOpCount
)
View Source
const (
	FloatAdd = iota
	FloatSubtract
	FloatMultiply
	FloatDivide
	FloatOpCount
)
View Source
const (
	// arithmetic operations
	ArithmeticOpAdd = iota
	ArithmeticOpSub
	ArithmeticOpMul
	ArithmeticOpDiv
	ArithmeticOpRem
	ArithmeticOpShiftLeft
	ArithmeticOpShiftRight
	ArithmeticOpBinaryAnd
	ArithmeticOpBinaryOr
	ArithmeticOpBinaryNot
	ArithmeticOpBinaryXor
	ArithmeticOpIncrement
	ArithmeticOpDecrement
	ArithmeticOpDouble
	ArithmeticOpHalve
	ArithmeticOpAddImmediate
	ArithmeticOpSubImmediate
	ArithmeticOpMulImmediate
	ArithmeticOpDivImmediate
	ArithmeticOpRemImmediate
	ArithmeticOpShiftLeftImmediate
	ArithmeticOpShiftRightImmediate
	// always last
	ArithmeticOpCount
)
View Source
const (
	// Compare operations
	CompareOpEq = iota
	CompareOpEqAnd
	CompareOpEqOr
	CompareOpEqXor
	CompareOpNeq
	CompareOpNeqAnd
	CompareOpNeqOr
	CompareOpNeqXor
	CompareOpLessThan
	CompareOpLessThanAnd
	CompareOpLessThanOr
	CompareOpLessThanXor
	CompareOpGreaterThan
	CompareOpGreaterThanAnd
	CompareOpGreaterThanOr
	CompareOpGreaterThanXor
	CompareOpLessThanOrEqualTo
	CompareOpLessThanOrEqualToAnd
	CompareOpLessThanOrEqualToOr
	CompareOpLessThanOrEqualToXor
	CompareOpGreaterThanOrEqualTo
	CompareOpGreaterThanOrEqualToAnd
	CompareOpGreaterThanOrEqualToOr
	CompareOpGreaterThanOrEqualToXor

	CompareOpCount
)
View Source
const (
	CombineNone = iota
	CombineAnd
	CombineOr
	CombineXor
	CombineError
)
View Source
const (
	CompareBodyEq = iota
	CompareBodyNeq
	CompareBodyLt
	CompareBodyGt
	CompareBodyLe
	CompareBodyGe
	CompareBodyError
)
View Source
const (
	Equal = iota
	NotEqual
	LessThan
	GreaterThan
	LessThanOrEqual
	GreaterThanOrEqual
	SelectSource0
	SelectSource1
	PassTrue
	PassFalse
	NumberOfCondStates
)
View Source
const (
	RegisterCount            = 256
	MemorySize               = 131072 // 131072 * 8 = 1 megabyte but we use a mmu to lay the memory out appropriately
	MajorOperationGroupCount = 8
	SystemCallCount          = 256
)
View Source
const (
	// Error codes
	ErrorNone = iota
	ErrorPanic
	ErrorGetRegisterOutOfRange
	ErrorPutRegisterOutOfRange
	ErrorInvalidInstructionGroupProvided
	ErrorInvalidArithmeticOperation
	ErrorInvalidMoveOperation
	ErrorInvalidJumpOperation
	ErrorInvalidCompareOperation
	ErrorInvalidMiscOperation
	ErrorInvalidSystemCommand
	ErrorWriteToFalseRegister
	ErrorWriteToTrueRegister
	ErrorEncodeByteOutOfRange
	ErrorGroupValueOutOfRange
	ErrorOpValueOutOfRange
)
View Source
const (
	// Instruction groups
	InstructionGroupArithmetic = iota
	InstructionGroupMove
	InstructionGroupJump
	InstructionGroupCompare
	InstructionGroupMisc
)
View Source
const (
	// Misc operations
	MiscOpSystemCall = iota
	NumberOfMiscOperations
)
View Source
const (
	// Move Operations
	MoveOpMove = iota
	MoveOpSwap
	MoveOpSet
	MoveOpLoad
	MoveOpStore
	MoveOpPush
	MoveOpPop
	MoveOpPeek
	MoveOpStoreCode
	MoveOpLoadCode
	// always last
	MoveOpCount
)
View Source
const (
	// reserved registers
	FalseRegister = iota
	TrueRegister
	InstructionPointer
	StackPointer
	PredicateRegister
	CallPointer
	UserRegisterBegin
)
View Source
const (
	// System commands
	SystemCallTerminate = iota
	SystemCallPanic
	SystemCallPutc
	NumberOfSystemCalls
)
View Source
const (
	DivideByZeroMessage = "Divide by zero error!"
)

Variables

This section is empty.

Functions

func InvalidRegister

func InvalidRegister(value string) error

func NewError

func NewError(code, value uint) error

func RegistrationName

func RegistrationName() string

Types

type Alu

type Alu struct {
	Result                      <-chan Word
	Error                       <-chan error
	Control                     <-chan Word
	Operation, Source0, Source1 chan<- Word
	// contains filtered or unexported fields
}

func NewAlu

func NewAlu(control <-chan Word) *Alu

func (*Alu) Startup

func (this *Alu) Startup() error

type ArithmeticOp

type ArithmeticOp struct {
	ImmediateForm bool
	Fn            func(Word, Word) (Word, error)
}

func (*ArithmeticOp) Invoke

func (this *ArithmeticOp) Invoke(first, second Word) (Word, error)

type BranchUnit

type BranchUnit struct {
	Control                    <-chan Word
	Result                     <-chan Word
	Error                      <-chan error
	Condition, OnTrue, OnFalse chan<- Word
	// contains filtered or unexported fields
}

func NewBranchUnit

func NewBranchUnit(control <-chan Word) *BranchUnit

func (*BranchUnit) Startup

func (this *BranchUnit) Startup() error

type CondUnit

type CondUnit struct {
	Error           <-chan error
	Result, Control <-chan Word
	// contains filtered or unexported fields
}

func NewCondUnit

func NewCondUnit(control, operation, source0, source1 <-chan Word) *CondUnit

func (*CondUnit) Startup

func (this *CondUnit) Startup() error

type Core

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

func New

func New() (*Core, error)

func (*Core) AdvanceProgramCounter

func (this *Core) AdvanceProgramCounter() error

func (*Core) Call

func (this *Core) Call(addr Word) error

func (*Core) CallMemory

func (this *Core) CallMemory(address Word) Word

func (*Core) CodeMemory

func (this *Core) CodeMemory(address Word) Instruction

func (*Core) CurrentInstruction

func (this *Core) CurrentInstruction() Instruction

func (*Core) DataMemory

func (this *Core) DataMemory(address Word) Word

func (*Core) Dispatch

func (this *Core) Dispatch(inst Instruction) error

func (*Core) Dump

func (this *Core) Dump(output chan<- byte) error

func (*Core) ExecuteCurrentInstruction

func (this *Core) ExecuteCurrentInstruction() error

func (*Core) GetDebugStatus

func (this *Core) GetDebugStatus() bool

func (*Core) HaltExecution

func (this *Core) HaltExecution()

func (*Core) InstallExecutionUnit

func (this *Core) InstallExecutionUnit(group byte, fn ExecutionUnit) error

func (*Core) InstallProgram

func (this *Core) InstallProgram(input <-chan byte) error

func (*Core) InstallSystemCall

func (this *Core) InstallSystemCall(offset byte, fn SystemCall) error

func (*Core) InstructionAddress

func (this *Core) InstructionAddress() Word

func (*Core) Invoke

func (this *Core) Invoke(inst *DecodedInstruction) error

func (*Core) IoMemory

func (this *Core) IoMemory(address Word) (Word, error)

func (*Core) MicrocodeMemory

func (this *Core) MicrocodeMemory(address Word) Word

func (*Core) NextInstructionAddress

func (this *Core) NextInstructionAddress() Word

func (*Core) Peek

func (this *Core) Peek() Word

func (*Core) Pop

func (this *Core) Pop() Word

func (*Core) PredicateValue

func (this *Core) PredicateValue(index byte) bool

func (*Core) Push

func (this *Core) Push(value Word)

func (*Core) RegisterIoDevice

func (this *Core) RegisterIoDevice(dev IoDevice) error

func (*Core) ResumeExecution

func (this *Core) ResumeExecution()

func (*Core) Return

func (this *Core) Return() Word

func (*Core) Run

func (this *Core) Run() error

func (*Core) SetCallMemory

func (this *Core) SetCallMemory(address, value Word) error

func (*Core) SetCodeMemory

func (this *Core) SetCodeMemory(address Word, value Instruction) error

func (*Core) SetDataMemory

func (this *Core) SetDataMemory(address, value Word) error

func (*Core) SetDebug

func (this *Core) SetDebug(_ bool)

func (*Core) SetIoMemory

func (this *Core) SetIoMemory(address, value Word) error

func (*Core) SetMicrocodeMemory

func (this *Core) SetMicrocodeMemory(address, value Word) error

func (*Core) SetStackMemory

func (this *Core) SetStackMemory(address, value Word) error

func (*Core) ShouldExecute

func (this *Core) ShouldExecute() bool

func (*Core) Shutdown

func (this *Core) Shutdown() error

func (*Core) StackMemory

func (this *Core) StackMemory(address Word) Word

func (*Core) Startup

func (this *Core) Startup() error

func (*Core) SystemCall

func (this *Core) SystemCall(inst *DecodedInstruction) error

func (*Core) TerminateExecution

func (this *Core) TerminateExecution() bool

type DecodedInstruction

type DecodedInstruction struct {
	Group, Op                     byte
	Destination, Source0, Source1 byte
	Immediate                     Word
}

func NewDecodedInstruction

func NewDecodedInstruction(group, op, data0, data1, data2 byte) (*DecodedInstruction, error)

func NewDecodedInstructionImmediate

func NewDecodedInstructionImmediate(group, op, data0 byte, imm Word) (*DecodedInstruction, error)

func (*DecodedInstruction) Encode

func (this *DecodedInstruction) Encode() *Instruction

func (*DecodedInstruction) Immediate

func (this *DecodedInstruction) Immediate() Word

func (*DecodedInstruction) SetImmediate

func (this *DecodedInstruction) SetImmediate(value Word)

type DecoderUnit

type DecoderUnit struct {
	Error   <-chan error
	Input   chan<- Word
	Control <-chan Word
	Result  <-chan *DecodedInstruction
	// contains filtered or unexported fields
}

func NewDecoderUnit

func NewDecoderUnit(control <-chan Word) (*DecoderUnit, error)

func (*DecoderUnit) Startup

func (this *DecoderUnit) Startup() error

type Demux

type Demux struct {
	Select  chan<- Word
	Control <-chan Word
	Error   <-chan error
	Source  chan<- interface{}
	// contains filtered or unexported fields
}

func NewDemux

func NewDemux(control <-chan Word) *Demux

func (*Demux) AddDestination

func (this *Demux) AddDestination(dest chan<- interface{})

func (*Demux) Startup

func (this *Demux) Startup() error

type ExecutionUnit

type ExecutionUnit func(*Core, *DecodedInstruction) error

type Fpu

type Fpu struct {
	Result  <-chan float64
	Error   <-chan error
	Control <-chan Word
	// contains filtered or unexported fields
}

func NewFpu

func NewFpu(control, operation <-chan Word, source0, source1 <-chan float64) *Fpu

func (*Fpu) Startup

func (this *Fpu) Startup() error

type Instruction

type Instruction uint32

func (Instruction) Decode

func (this Instruction) Decode() (*DecodedInstruction, error)

type IoDevice

type IoDevice interface {
	Begin() Word
	End() Word
	Load(address Word) (Word, error)
	Store(address, value Word) error
	RespondsTo(address Word) bool
	Startup() error
	Shutdown() error
}

type IrisError

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

func (IrisError) Error

func (this IrisError) Error() string

type MoveOp

type MoveOp func(*Core, *DecodedInstruction) error

func (MoveOp) Invoke

func (fn MoveOp) Invoke(core *Core, inst *DecodedInstruction) error

type Mux

type Mux struct {
	Control     <-chan Word
	Select      chan<- Word
	Destination <-chan interface{}
	Error       <-chan error
	// contains filtered or unexported fields
}

func NewMux

func NewMux(control chan<- Word) *Mux

func (*Mux) AddSource

func (this *Mux) AddSource(src <-chan interface{})

func (*Mux) Startup

func (this *Mux) Startup() error

type SystemCall

type SystemCall ExecutionUnit

type Word

type Word int64

Jump to

Keyboard shortcuts

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