Expand description

MCircuit (pronounced mc-urkit) provides a series of types and traits for working with circuits. Specifically, arithmetic circuits on GF2 and Z64, the former of which are effectively boolean circuits. It is used by Reverie.

MCircuit includes:

  • A circuit parsing library for BLIF files
  • Code for evaluating circuits in its gate format
  • Traits for constructing, translating, and iterating over gates
  • Code to export circuits in the Bristol Fashion format

Re-exports

pub use parsers::Parse;

Modules

Structs

Enums

Wraps Operation to define a field for each gate. Also supports conversions and metadata.

Defines the individual logic gate operations we can support

Traits

Conglomerate trait that wraps all the other useful traits defined in this module.

Applies to all gates, allows access to the input and output wire IDs of the gates

Trait related to buffer gates. If the gate doesn’t change its input value (ie adding zero, multiplying by one), then we say this is an “identity” gate, eligible to be folded out. !

Defines a number of helper methods for replacing the I/O wires on a gate with new ones

Implemented for acceptable types to use as wire values. It would be nice if this could just be a set of required traits, but num_traits::is_zero isn’t implemented for bool.

Functions

Copies most of the code from evaluate_composite_program, but takes a VcdDumper and dumps the value of each destination wire after evaluating a gate.

Evaluates a composite program (in the clear). Uses assert! to check AssertZero gates

Get the largest (arithmetic, boolean) wires in a program so we know how much memory to allocate. Respects size hints, if present at the start of the circuit

Get the largest (arithmetic, boolean) wires in a program so we know how much memory to allocate. Does NOT respect size hints.