bloqade_lanes_bytecode_core/arch/
mod.rs

1//! Architecture specification types, address encoding, and validation.
2//!
3//! This module defines the physical topology of a Bloqade quantum device:
4//! words, grids, transport buses, zones, and the `ArchSpec` that ties them
5//! together. It also provides bit-packed address types used by bytecode
6//! instructions and comprehensive structural validation.
7//!
8//! # Key types
9//!
10//! - [`ArchSpec`] — top-level device specification (loadable from JSON)
11//! - [`Word`], [`Grid`], [`Bus`], [`Zone`] — building blocks
12//! - [`LocationAddr`], [`LaneAddr`], [`ZoneAddr`] — bit-packed addresses
13//! - [`Direction`], [`MoveType`] — transport enums
14
15pub mod addr;
16pub mod query;
17pub mod types;
18pub mod validate;
19
20pub use addr::{Direction, LaneAddr, LocationAddr, MoveType, ZoneAddr};
21pub use query::ArchSpecLoadError;
22pub use types::{ArchSpec, Bus, Buses, Geometry, Grid, TransportPath, Word, Zone};
23pub use validate::ArchSpecError;
24
25/// Example arch spec from the bytecode design doc, for use in tests.
26#[cfg(test)]
27pub(crate) fn example_arch_spec() -> ArchSpec {
28    let json = r#"{
29        "version": "1.0",
30        "geometry": {
31            "sites_per_word": 10,
32            "words": [
33                {
34                    "positions": { "x_start": 1.0, "y_start": 2.5, "x_spacing": [2.0, 2.0, 2.0, 2.0], "y_spacing": [2.5] },
35                    "site_indices": [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1]],
36                    "has_cz": [[0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]
37                },
38                {
39                    "positions": { "x_start": 1.0, "y_start": 12.5, "x_spacing": [2.0, 2.0, 2.0, 2.0], "y_spacing": [2.5] },
40                    "site_indices": [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1]],
41                    "has_cz": [[1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4]]
42                }
43            ]
44        },
45        "buses": {
46            "site_buses": [
47                { "src": [0, 1, 2, 3, 4], "dst": [5, 6, 7, 8, 9] }
48            ],
49            "word_buses": [
50                { "src": [0], "dst": [1] }
51            ]
52        },
53        "words_with_site_buses": [0, 1],
54        "sites_with_word_buses": [5, 6, 7, 8, 9],
55        "zones": [
56            { "words": [0, 1] }
57        ],
58        "entangling_zones": [0],
59        "measurement_mode_zones": [0],
60        "paths": [
61            {"lane": "0xC000000000000005", "waypoints": [[1.0, 15.0], [1.0, 10.0], [1.0, 5.0]]}
62        ]
63    }"#;
64    serde_json::from_str(json).unwrap()
65}