sim

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sim provides simulation capabilities.

sim.T is a simulator which implicitly parallelizes Boolean operations by doing 64 independent simulation steps per logic gate in one 64 bit word bitwise operation.

Interfaces are provided for watches and monitoring.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	M  z.Lit        // a watch
	I  int          // which trace in [0..64)
	V  []uint64     // evaluations
	W  [][]uint64   // window
	WI int          // index of next values in window.
	N  int64        // how many steps.
	T  *reach.Trace // trace or partial trace.
	F  EventFlag    // what flags were set.
}

Event gives the context of an event in a simulation.

func (*Event) String

func (ev *Event) String() string

String implements Stringer.

type EventFlag

type EventFlag int

EventFlag says what event info to send back

const (
	// FlagWait tells the simulator to continue if the listener is not ready to
	// receive.
	FlagWait EventFlag = 1 << iota

	// FlagRoundTrip tells the simulator to to ask for the event back after it
	// was sent.  When it receives the event, it updates the flags.  This can be
	// used to pause the simulation.
	FlagRoundTrip

	// FlagCopyV tells the simulator to copy the values.
	FlagCopyV

	// FlagCopyW tells the simulator to copy the window.
	FlagCopyW

	// FlagStop tells the simulator to stop.  It is only used in the case
	// FlagRoundTrip is set.
	FlagStop

	// FlagTrace tells the simulator to generate a trace for the watch.  Only
	// the first trace is generated.
	FlagTrace
)

func (EventFlag) String

func (f EventFlag) String() string

type Options

type Options struct {
	// MaxDepth to which to simulate (unless RestartFactor is non-zero).
	MaxDepth int64
	// The max duration of a simulation.
	Duration time.Duration
	// Stop if every watch has been positive WatchUntil times.
	WatchUntil int
	// The random Seed
	Seed int64
	// N is the number of simulations to run, default 1.
	N int
	// TraceWindow give the max size of a trace (window of simulation memory), default 128.
	TraceWindow int
	// RestartFactor, given a function k=f(n) telling us to restart the n'th time
	// after k steps, run RestartFactor*k steps.  f is the Luby Series.
	RestartFactor int
	// GenTrace whether to generate a trace.
	GenTrace bool
	// log events
	Verbose bool
	// Events, ignored if EventChan is nil
	EventFlags EventFlag
	// EventChan is a channel on which to communicate simulation events.
	EventChan chan *Event
}

Options provides configuration info for the simulutor.

func NewOptions

func NewOptions() *Options

NewOptions gives default options.

type T

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

T holds state for a simulator.

func New

func New(trans *logic.S, bads ...z.Lit) *T

New creates a new simulator.

func (*T) FillOutput

func (t *T) FillOutput(out *reach.Output)

FillOutput fills `out` with the results of the last simulation.

func (*T) SetOptions

func (t *T) SetOptions(opts *Options)

func (*T) Simulate

func (t *T) Simulate() int64

Simulate runs the simulation with the current options.

Jump to

Keyboard shortcuts

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