logic

package
v0.0.0-...-07010e4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Const  = "CONST"
	Route  = "ROUTE"
	And    = "AND"
	Or     = "OR"
	LShift = "LSHIFT"
	RShift = "RSHIFT"
	Not    = "NOT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AndGate

type AndGate struct {
}

func (AndGate) String

func (g AndGate) String() string

func (AndGate) Transform

func (g AndGate) Transform(in ...uint16) (uint16, error)

type Block

type Block struct {
	Scheme BlockScheme
	// contains filtered or unexported fields
}

func NewBlock

func NewBlock(scheme BlockScheme) *Block

func (*Block) Evaluate

func (b *Block) Evaluate(in ...uint16) (uint16, error)

func (*Block) Value

func (b *Block) Value() (uint16, bool)

type BlockScheme

type BlockScheme struct {
	Input  []string
	Gate   Gate
	Output string
}

func ParseBlock

func ParseBlock(s string) (BlockScheme, error)

func (BlockScheme) String

func (b BlockScheme) String() string

type Circuit

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

func NewCircuit

func NewCircuit(blocks []BlockScheme) *Circuit

func (*Circuit) ValueOf

func (c *Circuit) ValueOf(wire string) (uint16, error)

type ConstGate

type ConstGate struct {
	Value uint16
}

func (ConstGate) String

func (g ConstGate) String() string

func (ConstGate) Transform

func (g ConstGate) Transform(in ...uint16) (uint16, error)

type Gate

type Gate interface {
	fmt.Stringer
	Transform(in ...uint16) (uint16, error)
}

type LShiftGate

type LShiftGate struct {
	By uint16
}

func (LShiftGate) String

func (g LShiftGate) String() string

func (LShiftGate) Transform

func (g LShiftGate) Transform(in ...uint16) (uint16, error)

type NotGate

type NotGate struct {
}

func (NotGate) String

func (g NotGate) String() string

func (NotGate) Transform

func (g NotGate) Transform(in ...uint16) (uint16, error)

type OrGate

type OrGate struct {
}

func (OrGate) String

func (g OrGate) String() string

func (OrGate) Transform

func (g OrGate) Transform(in ...uint16) (uint16, error)

type RShiftGate

type RShiftGate struct {
	By uint16
}

func (RShiftGate) String

func (g RShiftGate) String() string

func (RShiftGate) Transform

func (g RShiftGate) Transform(in ...uint16) (uint16, error)

type RouteGate

type RouteGate struct {
}

func (RouteGate) String

func (g RouteGate) String() string

func (RouteGate) Transform

func (g RouteGate) Transform(in ...uint16) (uint16, error)

Jump to

Keyboard shortcuts

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