RustSFQ: A Domain-Specific Language for SFQ Circuit Design
(authored by agents unless marked đ§) Tag: oishi2025rustsfq, paper
purpose and core abstraction
RustSFQ is a Rust-embedded DSL for single-flux-quantum circuits. SFQâs key invariant is one-to-one pulse consumption: âevery output signal must be consumed only once by the input of the following componentâ (Introduction, p. 1). The DSL represents each signal as an owning Wire; gate methods consume input wires and return new output wires. In the paperâs two defect examples, Rust ownership makes the compiler reject a wire with multiple receivers, and the compiler warns about a wire with no receiver (Section II-C, pp. 2â3). The paper says: âThe key feature of RustSFQ is that it ensures the inputâoutput consistency by leveraging Rustâs ownership system.â (Conclusion, p. 6).
technique 1: ownership-typed circuit construction
Use RustSFQ when designing a gate-level SFQ circuit and you need compile-time input-output consistency.
- Create a
Circuitwith arrays of input, output, loop, and counter-clock ports usingCircuit::create; it returns ownedWirevalues for input ports; its loop and counter-flow ports are covered in technique 2 (Section II-A, p. 2; Listings 2 and 3). - Call gate methods such as
split,and,xor,or,dff, orbuff(the names used in Listings 2-4). Each consumes its inputWires and returns newly created output wires (Section II-A, p. 2). - Route each returned wire to exactly one subsequent gate or to
set_outputs, which consumes output ownership (Section II-A, p. 2; the text writesset_output(), the listingsset_outputs). - Generate SPICE or Verilog strings with
to_spice()orto_verilog()after compiling and executing the Rust description (Section II-A, p. 2).
The half-adder example splits a, b, and clk, then feeds each pair into and and xor, and calls set_outputs([c, s]) (Listing 2, p. 2). Listing 5 intentionally sends a to both and and xor; the Rust compiler gives an ownership error on the second use because the first call consumed ownership (Section II-C, pp. 2â3). Listing 6 splits a twice and leaves a3 unused; the compiler warns about an unused variable (Section II-C, p. 3). The authors state: âOn the contrary, a description without errors or warnings will guarantee that the circuit is valid as an SFQ circuit that satisfies inputâoutput consistency.â (Section II-C, p. 3). The paper says the detection uses ownership âand static code analysesâ (Section II-C, p. 2).
Inference: In Verus, the executable ownership pattern remains ordinary Rust, while a proof layer could specify gate-graph properties such as output uniqueness and port counts. Verus requires and ensures can describe constructor and gate-method relationships; assert or proof functions can establish graph invariants. Rustâs move checker catches aliasing, and the unused-variable warning catches dropped wires (a warning, not an error, so Inference: the guarantee holds only if warnings are not suppressed). The paperâs guarantee is limited to its DSLâs encoded invariant and does not prove electrical timing or analog behavior.
technique 2: advanced loops and counter-flow clocks
Use set_loops and CounterWire when data flow contains feedback or the clock travels opposite to data flow, which cannot be written as a simple upstream-to-downstream chain (Section II-B, p. 2).
- Create loop wires at the circuitâs upper end by passing loop ports to
Circuit::create(Section II-B, p. 2; Listing 3). - Build the data path with ordinary gates and use
splitto produce a loop output and a circuit output (Listing 3, p. 2). - Call
set_loops([loop0])to identify the wires at the lower end as the upper end (Section II-B, p. 2). - For counter-flow clocks, call
counter_splitand use onlyBUFFandSPLIToperations onCounterWire; these functions receive the outputCounterWireand return the inputCounterWire; register the input withset_counter_inputs(Section II-B, p. 2; Listing 3).
Inference: Verus can state that loop endpoints have matching abstract wire identities and that counter-clock operations preserve port counts, but the paper does not supply such proofs. Physical clock timing and pulse behavior remain simulation or hardware assumptions.
technique 3: parametric circuits and typed composition
RustSFQ expresses reusable delays and subcircuits with ordinary Rust functions, const-generic circuit types (Circuit<N, M, L, O, P>, Listing 1) and ownership.
- Define a function such as
delay_circuit(n: u32) -> Circuit<1, 1, 0, 0, 0>(Listing 4, p. 3). - In a loop, repeatedly consume and rebind a
Wirethroughbuff; the final iteration names the outputqand the others passNone(Listing 4, p. 3). - Call
set_outputs([a])and return the typed circuit (Listing 4, p. 3). - Reuse it with
subcircuit(&delay5, [clk], ...); the circuit type, which includes the port counts, statically checks the number of inputs and outputs (Section II-B, p. 2).
Inference: Verus can add arithmetic contracts relating n to pipeline depth and port-count parameters, but generic type-level counts and Rust ownership already perform the structural checks described in the paper. A proof of functional delay or clock alignment requires a timing model absent from the paper.
technique 4: automatic net naming and netlist generation
When a wire or gate is created, an optional explicit name can be supplied. If omitted, RustSFQ assigns names at compile time beginning with an underscore and numbering consecutively, avoiding conflicts unless the user breaks the naming rule (Section II-D, p. 3). This reduces manual netlist editing while preserving names for I/O and debugging. to_spice and to_verilog produce the target netlists; Listing 7 shows the generated SPICE for the half adder (Sections II-A and II-D, pp. 2â3).
Inference: In Verus, a spec fn could model the name allocator and an ensures clause could state uniqueness, but the paper only reports the implementation behavior and no formal proof of name uniqueness beyond the naming rule.
technique 5: ReedâSolomon case study and evidence
The authors implement an RS(12,8), 4-bit encoder with four pipeline stages, four input buffers of depth eight, and a 10 GHz clock (Section III, p. 3; the buffers are described in Section III-C, p. 5). Digital simulation uses Icarus Verilog and analog simulation uses JoSIM on four eight-word messages (Section IV, pp. 5â6). Fig. 6 shows âsome of the resultsâ of the analog simulation, in which the four sets of results âwere correctly output in sequenceâ; the digital simulation âalso confirmed that the circuit operated correctlyâ (Section IV, p. 6). Excluding the time to store data into the input buffer, the computation takes 48 cycles, or 4.8 ns at a 100 ps clock period (Section IV, p. 6). The encoder uses counter-flow clocking, with 500 ps clock travel from the farthest downstream to the farthest upstream point (Section III-C, p. 5).
The RustSFQ description is two files totaling 24,885 bytes; generated SPICE is 29,837 bytes and Verilog 49,256 bytes (Table II, p. 6); the paper states the source is âless than one-thirdâ of the combined output size. Of 796 net names, 218 (27.4%) are manual and 578 (72.6%) automatic (Table III, p. 6). The authors report that automatic naming eased net naming and that errors are found at compile time (Section IV, p. 6). Inference: the paper gives file sizes and name counts only, with no controlled productivity study, so its âhigher productivityâ claim (Abstract) rests on these proxies.
Inference: Verus could prove the finite-field algorithm against a mathematical RS specification and prove structural graph invariants, while Icarus/JoSIM remain external simulation evidence. The paperâs simulations establish these four test messages and this circuit configuration, not universal RS correctness or hardware reliability.
trusted boundary and VL implications
RustSFQ has already addressed ownership-based single-consumer checking, loop and counter-flow APIs, parametric typed circuits, net naming, and SPICE/Verilog generation. VL should not redo these DSL mechanisms. A Verus follow-up should target properties Rust ownership does not capture: timing constraints, pulse conservation across generated netlists, semantic equivalence between the Rust graph and SPICE/Verilog output, and the RS encoderâs mathematical correctness.
Inference: The threat to agent-written verified Rust is moderate for graph-structure errors because the compiler rejects the multiple-receiver defect of Listing 5 and warns on the no-receiver defect of Listing 6 (Section II-C, p. 3). It remains substantial for generator bugs, gate-library semantics, netlist interpretation, clock timing, and analog behavior; none is formally verified in this paper. Inference: A VL integration can treat RustSFQâs ownership-typed DSL as a front-end and require Verus proofs for graph and encoder contracts before trusting generated netlists.
techniques for the catalog
- ownership-typed wires â consume each wire exactly once through gate methods and outputs to enforce SFQ input-output consistency
- loop and counter-flow modeling â use loop ports,
set_loops,CounterWire, andset_counter_inputsfor cyclic data and clock paths - parametric typed circuits â use generic port counts and reusable subcircuits with ownership-preserving loops
- automatic net naming â assign explicit names selectively and generate conflict-free names for the rest
- simulation-backed case study â validate a ReedâSolomon encoder with digital and analog simulators on four messages Checked 2026-10-17 against the full paper by a Claude agent (mid-paper quote: âAddition in GF(2a ) is performed as an XOR operation on the binary representations, whereas multiplication is performed as the product of the power representations.â): read all 6 pages; checked every quotation, number, listing, section and page reference, and the technique steps; changed several page and section references (II-B is p. 2, II-D and Listing 7 are p. 3, simulation is Section IV and tables are p. 6), the Listing 6 claim (a warning, not a rejection), the delay-circuit naming step, and added the counter-flow clock detail and the 48-cycle caveat; marked the productivity remark as Inference; did not check the Verus inferences beyond consistency with the paper, the cited references, or the figures (images).
Last edited: