hwlib

package
v0.0.0-...-dfe2263 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package hwlib provides a library of reusable parts for hwsim.

Copyright 2018 Denis Bernard <db047h@gmail.com>

This package is licensed under the MIT license. See license text in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(w string) hwsim.Part

And returns a AND gate.

Inputs: a, b
Outputs: out
Function: out = a && b

func AndN

func AndN(bits int) hwsim.NewPartFn

AndN returns a N-bits AND gate.

Inputs: a[N], b[N]
Outputs: out[N]
Function: for i := range out { out[i] = a[i] && b[i] }

func AndNWay

func AndNWay(ways int) hwsim.NewPartFn

AndNWay returns a N-Way OR gate.

Inputs: in[n]
Outputs: out
Function: out = in[0] && in[1] && in[2] || ... && in[n-1]

func DFF

func DFF(c string) hwsim.Part

DFF returns a clocked data flip flop.

Works like a gated D latch where E is the inverted clock signal and D the input.

Inputs: in
Outputs: out
Function: out(t) = in(t-1) // where t is the current clock cycle.

func DFFN

func DFFN(bits int) hwsim.NewPartFn

DFFN creates a N bits DFF.

func DMux

func DMux(w string) hwsim.Part

DMux returns a demultiplexer.

Inputs: in, sel
Outputs: a, b
Function: if sel == 0 { a = in; b = 0 } else { a = 0; b = in }

func DMuxMWayN

func DMuxMWayN(ways int, bits int) hwsim.NewPartFn

DMuxMWayN returns a N-Way demuxer.

Inputs: in[bits], sel[selBits]
Outputs: a, b, ... , z, A, ...
Function: if sel[0..selBits] == 0 { a == in; b,c,d... = 0 } else if sel == 1 { a = 0; b == in; c,d = 0... } ...

func DMuxN

func DMuxN(bits int) hwsim.NewPartFn

DMuxN returns a N-bits demultiplexer.

Inputs: in[bits], sel
Outputs: a[bits], b[bits]
Function: if sel == 0 { a = in; b = 0 } else { a = 0; b = in }

func DMuxNWay

func DMuxNWay(ways int) hwsim.NewPartFn

DMuxNWay returns a N-Way demuxer.

Inputs: in, sel[selBits]
Outputs: a, b, ... , z, A, ...
Function: if sel[0..selBits] == 0 { a == in } else if sel == 1 { b == in } ...

func GateN

func GateN(name string, bits int, f func(bool, bool) bool) hwsim.NewPartFn

GateN returns a N-bits logic gate.

Inputs: a[bits], b[bits]
Outouts: out[bits]
Function: for i := range out { out[i] = f(a[i], b[i]) }

func Input

func Input(i *bool) hw.NewPartFn

Input returns a 1-bit input updated with the value of i.

func Input16

func Input16(i *uint16) hw.NewPartFn

Input16 returns a 16-bit input updated with the value of i.

func Input32

func Input32(i *uint32) hw.NewPartFn

Input32 returns a 32-bit input updated with the value of i.

func Input64

func Input64(i *uint64) hw.NewPartFn

Input64 returns a 64-bit input updated with the value of i.

func Mux

func Mux(w string) hwsim.Part

Mux returns a multiplexer.

Inputs: a, b, sel
Outputs: out
Function: if sel == 0 { out = a } else { out = b }

func MuxMWayN

func MuxMWayN(ways int, bits int) hwsim.NewPartFn

MuxMWayN returns a M-Way N-bits Mux

Inputs: a[bits], b[bits], ... , z[bits], A[bits], ..., sel[selBits]
Outputs: out[bits]
Function: for i := range out { if sel == 0 { out[i] = a[i] } else { out[i] = b[i] }... }

func MuxN

func MuxN(bits int) hwsim.NewPartFn

MuxN returns a N-bits Mux

Inputs: a[bits], b[bits], sel
Outputs: out[bits]
Function: for i := range out { if sel == 0 { out[i] = a[i] } else { out[i] = b[i] } }

func Nand

func Nand(w string) hwsim.Part

Nand returns a NAND gate.

Inputs: a, b
Outputs: out
Function: out = !(a && b)

func NandN

func NandN(bits int) hwsim.NewPartFn

NandN returns a N-bits NAND gate.

Inputs: a[N], b[N]
Outputs: out[N]
Function: for i := range out { out[i] = !(a[i] && b[i]) }

func Nor

func Nor(w string) hwsim.Part

Nor returns a NOR gate.

Inputs: a, b
Outputs: out
Function: out = !(a || b)

func NorN

func NorN(bits int) hwsim.NewPartFn

NorN returns a N-bits NOR gate.

Inputs: a[N], b[N]
Outputs: out[N]
Function: for i := range out { out[i] = !(a[i] || b[i]) }

func Not

func Not(w string) hwsim.Part

Not returns a NOT gate.

Inputs: in
Outputs: out
Function: out = !in

func NotN

func NotN(bits int) hwsim.NewPartFn

NotN returns a N-bits NOT gate.

Inputs: in[bits]
Outputs: out[bits]
Function: for i := range out { out[i] = !in[i] }

func Or

func Or(w string) hwsim.Part

Or returns a OR gate.

Inputs: a, b
Outputs: out
Function: out = a || b

func OrN

func OrN(bits int) hwsim.NewPartFn

OrN returns a N-bits OR gate.

Inputs: a[N], b[N]
Outputs: out[N]
Function: for i := range out { out[i] = (a[i] || b[i]) }

func OrNWay

func OrNWay(ways int) hwsim.NewPartFn

OrNWay returns a N-Way OR gate.

Inputs: in[n]
Outputs: out
Function: out = in[0] || in[1] || in[2] || ... || in[n-1]

func Output

func Output(o *bool) hw.NewPartFn

Output returns a 1-bit output that updates o.

func Output16

func Output16(o *uint16) hw.NewPartFn

Output16 returns a 16-bit output that updates o.

func Output32

func Output32(o *uint32) hw.NewPartFn

Output32 returns a 32-bit output that updates o.

func Output64

func Output64(o *uint64) hw.NewPartFn

Output64 returns a 64-bit output that updates o.

func Xnor

func Xnor(w string) hwsim.Part

Xnor returns a XNOR gate.

Inputs: a, b
Outputs: out
Function: out = a && b || !a && !b

func Xor

func Xor(w string) hwsim.Part

Xor returns a XOR gate.

Inputs: a, b
Outputs: out
Function: out = (a && !b) || (!a && b)

Types

This section is empty.

Jump to

Keyboard shortcuts

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