device

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package device contains common device components like memory, video, audio, io, etc.

Index

Constants

View Source
const (
	EventBusRead       = iota // Read is a bus read event
	EventBusWrite             // Write is a bus write event
	EventBusAfterRead         // Read is a bus read event
	EventBusAfterWrite        // Write is a bus write event
)

Bus event types

View Source
const (
	EventUndefined = iota // Undefined event
	EventInit             // Init is a device init event
	EventReset            // Reset is a device reset event
)

Device event codes

Variables

This section is empty.

Functions

This section is empty.

Types

type AckCallback

type AckCallback func() bool

AckCallback device callback with ack control

type Bus

type Bus interface {
	// Read reads one byte from address
	Read(address uint16) byte
	// Write writes a byte at address
	Write(address uint16, data byte)
}

Bus is a 8 bit data bus of 16 bit address

type BusDevice

type BusDevice interface {
	Device // Is a Device
	Bus    // Is a DataBus
}

BusDevice is the device databus interface

type BusEvent

type BusEvent struct {
	Event          // Is a Device Event
	Address uint16 // Address on bus
}

BusEvent is a bus event

func NewBusEvent

func NewBusEvent(code int, address uint16) *BusEvent

NewBusEvent creates a bus event

type Callback

type Callback func()

Callback is a device callback

type Clock

type Clock interface {
	// Add increases clock tstates by value
	Add(value int)
	// Inc increases clock tstates by one
	Inc()
	// Restart restarts clock to tstates
	Restart(tstates int)
	// SetTstates sets the clock tstate
	SetTstates(tstate int)
	// Tstates obtains the clock tstate
	Tstates() int
	// Total gets total tstates since last reset
	Total() int64
}

Clock is the CPU clock

type ClockDevice

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

ClockDevice is the default clock implementation

func NewClock

func NewClock() *ClockDevice

NewClock returns a Clock device

func (*ClockDevice) Add

func (c *ClockDevice) Add(value int)

Add increases clock tstates by value

func (*ClockDevice) Inc

func (c *ClockDevice) Inc()

Inc increases clock tstates by one

func (*ClockDevice) Init

func (c *ClockDevice) Init()

Init initializces the clock

func (*ClockDevice) Reset

func (c *ClockDevice) Reset()

Reset the clock

func (*ClockDevice) Restart

func (c *ClockDevice) Restart(tstates int)

Restart restarts clock to tstates

func (*ClockDevice) SetTstates

func (c *ClockDevice) SetTstates(tstates int)

SetTstates sets the clock tstates

func (*ClockDevice) Total

func (c *ClockDevice) Total() int64

Total gets total tstates since last reset

func (*ClockDevice) Tstates

func (c *ClockDevice) Tstates() int

Tstates obtains the clock tstates

type Components

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

Components is a set of Devices

func NewComponents

func NewComponents(size int) *Components

NewComponents creates a collection

func (*Components) Add

func (collection *Components) Add(device Device)

Add adds device at current index

func (*Components) Get

func (collection *Components) Get(index int) Device

Get gets device at index

func (*Components) Init

func (collection *Components) Init()

Init initializes all devices

func (*Components) Reset

func (collection *Components) Reset()

Reset resets all devices

func (*Components) Set

func (collection *Components) Set(index int, device Device)

Set sets device at index

type Device

type Device interface {
	// Init initializes the device
	Init()
	// Reset resets the device
	Reset()
}

Device is the base device component

type Event

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

Event is the base device event

func CreateEvent

func CreateEvent(code int) Event

CreateEvent creates new event

func (*Event) Code

func (e *Event) Code() int

Code the event code

type EventBus

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

EventBus callback functions

func NewEventBus

func NewEventBus() *EventBus

NewEventBus a new device event bus

func (*EventBus) Bind

func (bus *EventBus) Bind(c EventCallback)

Bind a new callback

func (*EventBus) Emit

func (bus *EventBus) Emit(e IEvent)

Emit an event

type EventCallback

type EventCallback func(IEvent)

EventCallback is a device event callback

type IEvent

type IEvent interface {
	Code() int // Event code
}

IEvent is the Event interface

type ReadCallback

type ReadCallback func() byte

ReadCallback line read byte callback

type WriteCallback

type WriteCallback func(byte)

WriteCallback line write byte callback

Directories

Path Synopsis
cpu
Package cpu contains common components for CPU emulators
Package cpu contains common components for CPU emulators
z80
Package z80 a Zyxel Z80 CPU emulator
Package z80 a Zyxel Z80 CPU emulator
io
Package io contains IO devices
Package io contains IO devices
Package memory defines memory components
Package memory defines memory components
Package video contains video components and devices
Package video contains video components and devices

Jump to

Keyboard shortcuts

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