Skip to content

§ 1.4. Wiring and Constants

Wiring parts move bits without computing anything: they split a word into bits, join bits into a word, or route bits between pins of different shapes. They take no time in any timing profile, pass every value on unchanged (Z included), and have no compact form, because they are already leaves. A constant drives a fixed value from the start of a run.

Component Description Structural Behavioral
ConstantValue<W> Drives a fixed W-bit value Yes No
BitSplitter<W> Splits a W-bit word into W one-bit outputs Yes No
BitJoiner<W> Joins W one-bit inputs into a W-bit word Yes No
Rewire Routes chosen input bits to chosen output bits, between pins of any shape Yes No

The structural form of each is the leaf itself. W is the width of the word, 1 to 64 bits; the recorded examples use 8 bits.

1.4.1. ConstantValue<W>

ConstantValue<W> drives one fixed W-bit value. Circuits use it for tied inputs: a constant carry-in, a reserved mux input, a zero word.

IO pins

Pin Direction Width Description
OUT Output W The constant value

The value is a construction parameter (ConstantValue<W>(name, value); in the catalog, contract utility.constant.width<W> with parameter value).

Behavior

OUT holds the value from the start of the run: the constant publishes it when the simulation starts, with no delay, and never changes it. Bits of the value above W are ignored.

C++ example

#include <cstdint>

uint64_t constant_ref(uint64_t value, unsigned width) {
    return width >= 64 ? value : value & ((uint64_t{1} << width) - 1);
}

This binary function describes the driven value. It is not a registered implementation.

Unknown inputs

There are no inputs. The output is never X or Z once the run has started.

Implementation

Structural implementation

A leaf with no children: it schedules its value once, at the start of the run, with zero delay.

Examples

All 1 recorded rows of ConstantValue8Test, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.

Default scenario profile: fidelity-gate-v1 / structural (ed03f70afe360dba). Changing fidelity or the circuit can change these times.

Checkpointzero-based number · timeline label Timesimulator units OUTExpected output · 8 bit
#0output0 0xEF

Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.

Each row checks the value an 8-bit constant drives.

Embedded simulation

The constant-value8 scenario runs ConstantValue8Test.

Open ConstantValue<8> in the simulator

Source and tests

Test Coverage
ConstantValue1Test … ConstantValue32Test The value driven at widths 1, 2, 4, 8 and 32

1.4.2. BitSplitter<W>

BitSplitter<W> splits a W-bit word into its bits, so one-bit gates can use them.

IO pins

Pin Direction Width Description
IN Input W The word
OUT_0 … OUT_<W−1> Output 1 each OUT_i is bit i of IN (bit 0 the least significant)

Behavior

Each output copies its bit of the input. Nothing is computed, and the splitter takes no time in any timing profile: it is wiring.

C++ example

#include <cstdint>
#include <vector>

std::vector<bool> split_ref(uint64_t in, unsigned width) {
    std::vector<bool> bits;
    for (unsigned i = 0; i < width; ++i) bits.push_back((in >> i) & 1);
    return bits;
}

This binary function describes the settled outputs. It is not a registered implementation.

Unknown inputs

Each bit is copied as it is: an X or Z input bit gives an X or Z on its output, and the other outputs are not affected.

Implementation

Structural implementation

A leaf with no children. It publishes every output bit on each input change, with the splitter delay, which is zero in every timing profile.

Examples

All 5 recorded rows of BitSplitter8Test, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.

Default scenario profile: fidelity-gate-v1 / structural (ed03f70afe360dba). Changing fidelity or the circuit can change these times.

Checkpointzero-based number · timeline label Timesimulator units INInput · 8 bit OUT_0Expected output · 1 bit OUT_1Expected output · 1 bit OUT_2Expected output · 1 bit OUT_3Expected output · 1 bit OUT_4Expected output · 1 bit OUT_5Expected output · 1 bit OUT_6Expected output · 1 bit OUT_7Expected output · 1 bit
#0value-00 0x00 0 0 0 0 0 0 0 0
#1value-901 0x5A 0 1 0 1 1 0 1 0
#2value-2552 0xFF 1 1 1 1 1 1 1 1
#3four-state-unknown3 0b10ZX10ZX X Z 0 1 X Z 0 1
#4four-state-high-z4 0bX10ZX10Z Z 0 1 X Z 0 1 X

Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.

Each row drives one 8-bit word and checks every output bit.

Embedded simulation

The bit-splitter8 scenario runs BitSplitter8Test.

Open BitSplitter<8> in the simulator

Source and tests

Test Coverage
BitSplitter1Test … BitSplitter32Test Zero, an alternating pattern and all ones at widths 1, 2, 3, 4, 5, 8, 16 and 32

1.4.3. BitJoiner<W>

BitJoiner<W> joins W bits into one word, the inverse of BitSplitter<W>.

IO pins

Pin Direction Width Description
IN_0 … IN_<W−1> Input 1 each IN_i becomes bit i of OUT
OUT Output W The word

Behavior

Bit i of OUT copies IN_i. Nothing is computed, and the joiner takes no time: it is wiring.

C++ example

#include <cstdint>
#include <vector>

uint64_t join_ref(const std::vector<bool>& bits) {
    uint64_t out = 0;
    for (size_t i = 0; i < bits.size(); ++i) out |= uint64_t{bits[i]} << i;
    return out;
}

This binary function describes the settled output. It is not a registered implementation.

Unknown inputs

Each bit is copied as it is: an X or Z input gives an X or Z in its position of OUT.

Implementation

Structural implementation

A leaf with no children. It publishes the whole word on any input change, with zero delay.

Examples

All 6 recorded rows of BitJoiner8Test, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.

Default scenario profile: fidelity-gate-v1 / structural (ed03f70afe360dba). Changing fidelity or the circuit can change these times.

Checkpointzero-based number · timeline label Timesimulator units IN_0Input · 1 bit IN_1Input · 1 bit IN_2Input · 1 bit IN_3Input · 1 bit IN_4Input · 1 bit IN_5Input · 1 bit IN_6Input · 1 bit IN_7Input · 1 bit OUTExpected output · 8 bit
#0partial-unknown0 1 X X X X X X X 0bXXXXXXX1
#1value-01 0 0 0 0 0 0 0 0 0x00
#2value-902 0 1 0 1 1 0 1 0 0x5A
#3value-2553 1 1 1 1 1 1 1 1 0xFF
#4four-state-unknown4 X Z 0 1 X Z 0 1 0b10ZX10ZX
#5four-state-high-z5 Z 0 1 X Z 0 1 X 0bX10ZX10Z

Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.

Each row drives eight bits and checks the joined word.

Embedded simulation

The bit-joiner8 scenario runs BitJoiner8Test.

Open BitJoiner<8> in the simulator

Source and tests

Test Coverage
BitJoiner1Test … BitJoiner32Test Zero, an alternating pattern and all ones at widths 1, 2, 3, 4, 5, 8, 16 and 32

1.4.4. Rewire

Rewire routes bits between input and output pins of any number and width, following a list of bit mappings. Circuits use it to take a field out of a word, put fields together, spread one bit across a word, or pass a parent's input straight to its output, which a component may not wire directly (§ 1.1 Pins and wires).

IO pins

The pins are construction parameters:

Parameter Meaning
Input specs A name and a width (1 to 64) for each input pin
Output specs A name and a width for each output pin
Mappings (input, bit) → (output, bit) pairs
Unmapped value X (default), 0 or 1: what an output bit no mapping drives shows

An input and an output may share a name; they are still separate pins (<id>.input.<name> and <id>.output.<name>). In the catalog, the contract utility.rewire takes these four as parameters.

Behavior

Each mapped output bit copies its input bit; every other output bit holds the unmapped value. One input bit may feed several output bits; an output bit may have only one source. Rewire takes no time in any timing profile.

C++ example

#include <cstdint>

// The field of bits [first, first + count) of a word, moved down to bit 0.
uint64_t field_ref(uint64_t word, unsigned first, unsigned count) {
    return (word >> first) & ((uint64_t{1} << count) - 1);
}

This binary function describes one common mapping. It is not a registered implementation.

Unknown inputs

A mapped bit is copied as it is, X and Z included. An unmapped bit shows the unmapped value whatever the inputs are.

Implementation

Structural implementation

A leaf with no children. A construction check rejects a configuration with an empty or repeated pin name, an unsupported width, a mapping to a missing pin or bit, or two mappings to the same output bit. On each input change it publishes every output word with zero delay.

Examples

All 3 recorded rows of RewireTest, in checkpoint order. Outputs are test expectations verified against the simulation. Time is the absolute settled checkpoint time in simulator units, not milliseconds or CPU cycles.

Default scenario profile: fidelity-gate-v1 / structural (ed03f70afe360dba). Changing fidelity or the circuit can change these times.

Checkpointzero-based number · timeline label Timesimulator units BUSInput · 8 bit B0Expected output · 1 bit B1Expected output · 1 bit B2Expected output · 1 bit B3Expected output · 1 bit B4Expected output · 1 bit B5Expected output · 1 bit B6Expected output · 1 bit B7Expected output · 1 bit
#0row-00 0xA5 1 0 1 0 0 1 0 1
#1row-11 0x00 0 0 0 0 0 0 0 0
#2row-22 0xFF 1 1 1 1 1 1 1 1

Scroll within the table for all rows and pins. Buses use hexadecimal; values containing X/Z use MSB-first binary. Inputs show the declared values in effect at each checkpoint, including retained inputs. Sequential tests also replay preparation changes between checkpoints, such as lowering the clock. Use the matching checkpoint label in the simulation below.

The scenarios copy a word, copy four-state bits unchanged, and leave unmapped output bits unknown.

Embedded simulation

The rewire scenario runs RewireTest.

Open Rewire in the simulator

Source and tests

Test Coverage
RewireTest Copying, four-state copying and unmapped bits, as recorded scenarios
RewireValidationTest Same-named input and output pins keep separate identities; invalid configurations are rejected