Skip to content

hardcaml_asic architecture

This document describes public boundaries, responsibility and dependency direction. The memory contract is normative for Single_port_ram.

1. Purpose and implemented scope

Help independent Hardcaml projects declare ASIC intent, emit reproducible inputs, execute an implementation flow and inspect traceable results. The supported path is Tiny Tapeout 6x4 / IHP CMOS5L / LibreLane, with behavioral and explicitly selected flop memory, plus the exact 256×16 SRAM backend through fresh synthesis and full implementation with the checked stock R0 physical profile. Limited same-workspace macro checkpoints through Timing are supported; see segmented SRAM. Timed-model conformance is not claimed. There is no general multi-target or multi-backend implementation. A successful process is not a signoff verdict.

Implemented:

  • Declaration and inspection, elaboration, target/constraint resolution, and immutable identity-addressed bundles.
  • The installed native OCaml CLI (contract 4) with default result stores, standalone preflight receipts, and human or explicit---json output.
  • Coarse Classic runs with separate execution IDs, run.json/results.json, postcheck attempts, operation-aware acceptance and integrity-checked archives.
  • Explicit seven-stage execution with path-bound checkpoints, default per-attempt journals, foreground watch and separate finalization.
  • Named, project-owned flow catalogs and typed parameter profiles with preview/plan-identity enforcement.

Not implemented: a store-wide catalog with idempotency, backend-step observation, execution recovery, configuration-changing checkpoint reuse, source-artifact stamping.

2. Responsibilities and dependency direction

Layer Responsibility
Hardware library hardcaml_asic (lib/) Resource semantics, project declarations, validated design intent and input emission. Qualified groups Resource, Flow, Platform and Elaboration; lib/hardcaml_asic.ml is the curated public surface
Flow domain hardcaml_asic.flow_domain (flow_domain/) Stage/operation contracts, standard compositions, checked LibreLane mapping, catalogs, methodologies, profiles and parameters
Execution library hardcaml_asic.execution (execution/) and native commands (bin/) Public CLI parsing, defaults, identity, routing and rendering; all computation services, supervision, publication, records, observation and watch
Installed Python runtime (flow/hardcaml_asic_flow/) Thirteen modules (__init__, backend_protocol, librelane_bridge, stage_metadata_probe, probe, runtime_observation, runtime_contract, managed_python, paths, macro_flow, physical_runtime, timing_intent_runtime, timing_physical_runtime) plus four data files. Calls the official LibreLane API, probes runtimes, provisions, and implements checked physical-macro and linked pre/post-PNR timing adaptations
Retired Python sources Sixteen former service modules kept in the checkout only as references and test oracles. Their installed imports are a deliberate Python API break
Hardware project (e.g. the example) Design and wrapper semantics, testbenches, declaration, flow catalog, dependency pin and chosen evidence stores
Silver ASIC adapter Consumes the project's public provider interface and translates it into feature data
Silver application Job supervision, derived catalog/cache, workspace/window/tile state and presentation

Dependencies run one way: hardware project → ASIC library/CLI, and Silver adapter → the project/provider entry point. ASIC never imports Silver types and needs no Silver daemon. The hardware library does not depend on the execution library. Ordinary Dune builds and project regressions need not route through ASIC. Versioned structured data lets Silver decode typed values independently of the provider's implementation language.

ASIC owns canonical bundles, runs, snapshots, raw evidence, check attempts and archives. Silver owns a rebuildable index, bounded caches, saved selections and layouts; its daemon owns its own process handles. Readers of one run are independent: selection, tile lifetime and client detach never control a flow.

No workbench is required for library, execution or inspection operations.

Current native execution source map

execution/dune defines one public hardcaml_asic.execution library with (include_subdirs unqualified). The directories organize source only; they are not namespaces, and every Hardcaml_asic_execution.* module name is unchanged.

Source directory under execution/ Modules / responsibility
Root Runner, Execution_plan, Coarse_execution_service, Coarse_run_service, Methodology_execution_service, Methodology_execution_record: planning and orchestration
storage/ Checkpoint, Checkpoint_publisher, Result_store: validation, publication and allocation
observation/ Observation, Observation_writer: persisted reader and writer
results/ Collect_service, Evidence_json, Report_service, Stage_report_service, Postcheck_service, Finalization_record, Finalization_service, Run_record, Stage_execution_record, Historical_methodology, Yosys_stat_evidence: collection, evidence decoding, acceptance, reporting and records
archive/ Archive_service, Archive_encoding, Evidence_tar: archive selection and encoding
runtime/ Identity_json, Runtime_contract, Runtime_evidence, Runtime_probe, Execution_transport, Process, Process_supervisor, Preflight_service: identity, readiness, launch and supervision
backends/librelane/ Backend_protocol, Backend_state, Classic_contract, Segment_report, Segment_service, Stage_preparation: narrow native-backend integration

The three C stubs sit at the library root beside the foreign-stub stanza. Stage domains live in flow_domain/stages/. Installed resource paths and runtime output layouts do not depend on this source layout.

Tool environment ownership

The installed provider works without its source checkout. Storage has separate owners:

  • the provider installation prefix (library, CLI, runtime modules and pins);
  • a configurable collateral root, selected by provision --toolchain PATH or TOOLCHAIN. It holds the managed python, tt, pdk, .venv and .venv-precheck children. The example defaults to absolute _flow_tools/; provider development adapters fall back to .toolchain/;
  • host prerequisites and the Docker/Podman/Nix stores;
  • the consumer's bundle, run and archive stores.

A thin consumer bootstrap delegates to the installed provider, with no copied pins, no source fallback and no automatic provider refresh. Refreshing the provider and provisioning tools are separate operations. Provisioning verifies the installed archive pin's digest before extraction, then probes the result and keeps final generations without replacing them. provision --python BASE overrides the managed base; execution --python keeps its lexical path, so venv symlinks are honored. --check is bounded and read-only.

Initial managed-runtime support is Linux glibc x86_64 ≥ 2.17 with renameat2. That is not a universal platform guarantee or a source attestation. Native EDA capability checks and generalizing the runner to Podman remain open. See tool-directory ownership.

Runtime policy and launch binding

Manifests record requested_tools.runtime_policy:

  • Host flow Python is exact-minor 3.11, and native execution uses it.
  • Dockerized implementation uses the official LibreLane 3.1.0.dev3 image, whose Python must satisfy Requires-Python >=3.10.
  • An absent policy keeps the legacy strict 3.11 for both roles, and a malformed one fails closed.

Installed provisioning defaults never override what the bundle requests.

Docker transport binds the observed engine, interpreter flags and immutable local image ID (recorded separately from RepoDigests), mounts the staged project read-write and the PDK read-only, and owns bounded cleanup. Direct transport is needed because LibreLane's image_exists rejects IDs and digests. The LibreLane flow engine itself is unchanged. This binding is per attempt; it is not a cross-machine digest pin or runtime attestation. See policy and limits.

3. Target and flow selection

Keep harness, technology and flow separate. The harness specifies the interface, geometry and submission constraints; the technology supplies cells and collateral; the flow adapter validates compatibility and renders and invokes the tools.

Resolution and rendering are deliberately TT/LibreLane-specific. Keep that honest scope: a general adapter framework should be extracted only when a second real target or backend demands it. The target reference lists the exact supported facts.

4. Project lifecycle

Project declaration
  → fresh Elaboration.Context for one elaboration
  → construct/register resources and validate policy
  → finalize abstract Elaborated_project (circuit + metadata/intent/resources)
  → resolve concrete TT/LibreLane facts into Resolved_flow
  → Bundle.render / Bundle.write / Bundle.publish
  → separate execution(s), observations and results

Elaboration constructs a Hardcaml circuit, not a synthesis result. Chip_target.elaborate returns Elaborated_project.t. Chip_target.elaborate_for_flow adds validation and returns Resolved_flow.t, which keeps that project in its elaborated_project field. Rendering emits inputs; execution invokes tools separately.

The consumer owns each chip target's constructor, declaration, wrapper and source inventory. Chip_target.create ?source_inputs defaults to []. Chip_target.describe returns declaration facts as an S-expression with no design construction, resolution or I/O. It is not a Silver protocol. Root and output paths are execution arguments, not declaration fields.

Chip_target.emit_bundle ?inputs ?include_simulation t ~source_root ~output_dir owns the shared orchestration:

  1. Reject an empty inventory before constructing the design.
  2. Elaborate and resolve for implementation.
  3. Optionally elaborate for simulation. This is on by default; turning it off reuses the synthesis sources.
  4. Render, then write.

Nothing is written until rendering succeeds. Bundle.write needs a new or empty directory and is not atomic. Chip_target.emit_bundle_to_store uses Bundle.publish instead: complete private .objects data is verified first, then exposed through an exclusive identity symlink. Reuse validates the exact tree and bytes.

Store defaults: the library requires an explicit store. The project CLI uses ROOT/_flow_results/{bundles,runs,operations}, and the generic installed CLI uses the caller's _flow_results for runs and operations. _flow_tools is separate. Collect and report always select an explicit existing run, never the newest one. See the command/storage matrix and the entry-point guide.

Invariants:

  • Dependencies are acyclic. Project composes Bundle and Resolved_flow, which use Elaborated_project rather than calling back into Chip_target.
  • Contexts close on success or failure, so registration cannot leak into another elaboration. Resource identities use explicit names and scope paths, and inventories are sorted.
  • Simulation and implementation elaboration stay separate; bundle source sets must never mix behavioral models with implementation definitions.
  • Resolved_flow.t, Resolved_flow.Setting.t and Resolved_flow.Delay_ns.t are private records that only resolve constructs. Field reads and pattern matching work; construction and record updates are compiler errors. There is no unchecked constructor or deserializer.

The private records enforce the resolution boundary only. They do not make Hardcaml circuit internals deeply immutable, and external target files remain references, not verified physical evidence.

5. Resources and policies

Resource preparation is a first-class overall-workflow preparation operation, not a member of the LibreLane physical-stage sequence. A project-owned executable constructs its chip target and invokes Chip_target.prepare_resources; the execution service records its lifecycle and immutable successful snapshot. The generic CLI inspects retained attempts without project code, current source files or tools. See the CLI guide.

Preparation covers source/configuration/actual-circuit/resource identities and explicit selection explanations. Collateral and physical intent remain declared references, not readiness or measured implementation evidence. A source observation is not a compiled-source stamp. Preparation creates no bundle identity; comparison with an explicit current preparation identity leaves old results unchanged.

Retain the behavioral/flop RAM contract and its independent conformance tests. Selection is explicit: exact mapping, flops, or an explicitly permitted fallback. Never silently change shape, latency or behavior to fit hardware.

User hardware owns architectural registers, memory latency and arbitration. Implementation tooling may perform recorded, behavior-preserving combinational buffering, sizing, placement and routing; it must not add pipeline stages or retime across the SRAM contract to repair violations. Failed electrical closure is reported rather than repaired by weakening limits or changing architecture.

Resource IDs map to verified emitted macro names; arbitrary source nets may still be optimized, merged or renamed.

Resource.Request.contract currently uses structural S-expression equality, so field order affects matching. It merits a typed/canonical representation before broader backend authoring. No SRAM or public macro framework is a blanket prerequisite for other work.

6. Configuration ownership and constraints

The project declaration owns target, clock, resources and supported timing intent. Optional checked Hardware_variant assignments pass through Chip_target.of_variant to the factory and into existing bundle/plan identity. They are distinct from resource policy and backend flow profiles. Identity establishes declared association, not semantic parameter use or compiled-source attestation. The headless Variant_comparison service reuses verified bundle/run/execution evidence, reports domain differences and per-metric eligibility, and never launches experiments or selects a winner. Checked bounded memory workload association is also supported; see the variant/comparison guide. Derived source lists, target geometry, clock facts, SDC and resource collateral are protected from conflicting overrides. LibreLane escape-hatch values carry nonempty reasons. Tt_cmos5l supplies overridable template defaults with provenance; the consumer still owns reset, enable, pin arbitration and testbench behavior.

Timing supports one primary clk and optional minimum and maximum I/O delays. Timing intent extends that same declaration with registered scalar Q anchors and reasoned first-stage capture/enumerated asynchronous-reset exceptions. Exact native mapped resolution fails closed before application; no hardware is inserted. The first qualified CMOS5L subset and standalone synthesized-netlist audit CLI are documented in the timing-intent guide. Requested intent, producer-reported resolution and command-completed application stay separate. Native inspection adds native stored-exception comparison, category-bound diagnostic enumeration and endpoint inventory, with ordinary macro-free coarse-synthesis linked STAPrePNR production and collect/report/archive source replay. The analysis is separate from the physical-stage recipe and uses only its explicitly selected default corner. Fresh macro-free named synthesis now binds required linked analysis to the exact frozen methodology, attempt, occurrence and promoted checkpoint State, with early expectation persistence and shared report/inspection validation. Checkpoints remain unchanged and named evidence remains path-bound; named archives/physical endpoints are unsupported. Explicit physical opt-in separately supports fresh macro-free coarse full execution, checked combinational repair transforms, all-configured cell corners and linked extracted post-PNR evidence. The five-stage example closes routed timing with normal physical/postchecks under the recorded nominal-RC profile; exhaustive effects/per-check and analog consumer qualification remain open. See timing intent. Resolved target constraints include drive/load and timing margins. Expose those facts and the emitted constraint identity to observers rather than creating a second editable configuration in Silver. Generated clocks and CTS (clock-tree synthesis) analytics are later capabilities.

Named flow profiles (§9) may set only typed, explicitly exposed backend parameters, and only before bundle publication.

7. Build artifacts and provenance

Keep immutable build identity separate from execution, operation and UI job IDs. Bundle identity covers generated files, copied declared sources and their Git state, target references, settings and requested tool pins. The hash uses an ordered manifest representation, so reordering fields changes identity. Old manifests and archived evidence must stay readable without rewriting.

Generator/source-artifact stamping and generator/executor/expectation comparisons are not implemented. Pin an exact provider revision and record installation provenance separately. Local receipts and checksums are not embedded source stamps or proof of linked-library identity.

Bundle.publish gives atomic visibility, verified immutable reuse and no-clobber concurrent publication on local POSIX filesystems. Published objects must be retained. No GC, mutable current pointer, NFS or power-loss durability is promised (publication details).

8. Provider observation direction

Execution model

The public native CLI runs all execution itself. stages and checkpoint and observation queries go to native services, and there is no silent fallback to Python stage execution. Coarse Classic execute uses Coarse_execution_service, binding implementation, optional postcheck, collection, acceptance and optional archive to a checked plan and the shared Runner. Coarse collection is best-effort after failure and never replaces the primary failure.

Flow.Stage / Flow.Recipe are pure typed OCaml declarations. The native execution models validate the current schema-4 contract; historical six-stage schema-3 plans remain readable. Stage modules describe all 80 Classic occurrences, and preparation checks the selected runtime's inventory and settings.

Boundary Classic endpoint Standalone restart targets
synthesis Yosys.Synthesis floorplan, placement
floorplan OpenROAD.Floorplan placement
placement OpenROAD.DetailedPlacement cts
cts OpenROAD.CTS routing
routing OpenROAD.DetailedRouting timing
timing OpenROAD.STAPostPNR signoff
signoff Misc.ReportManufacturability none

Recipes are contiguous: either fresh from synthesis or resumed immediately after an explicit checkpoint. They include every intervening boundary; going directly from synthesis to placement is only a standalone segment capability. Official Classic successors, checkers and configured gates are retained: CTS's later STA/repair belongs to routing, and routing's checkers/fill/extraction and extracted STA belong to Timing. Boundary names group steps. They do not license skipping checks and are not acceptance verdicts. Arbitrary DAGs, custom steps and per-stage settings are not exposed.

Checkpoints

stages binds the exact tested Docker image and engine and rechecks them around backend calls. A versioned request/reply protocol invokes librelane_bridge, which uses the official State.loads / Flow.start without copying backend orchestration. Per-call transport records keep argv, resources, process and cleanup outcomes.

The checkpoint publisher copies all state views, configuration and the hashed host/image-only closure. It validates them in the bound runtime, removes write bits and atomically promotes a unique no-clobber publication before announcing readiness. Schema-2 checkpoints declare exact restart targets and path-bound compatibility: copied views remove dependencies on the producer run, not on the original input, support or PDK roots. checkpoint-inspect is host-only validation, not runtime readiness. Schema-1 physical checkpoints are not upgraded.

Journals and readers

CLI stages journals each fresh or resumed attempt by default to <workspace-parent>/observations (--observation-store overrides it and --no-observation disables it). The journal provides:

  • early allocation and hash-chained atomic records under advisory writer locks;
  • describe, inspect, cursor read-updates and foreground incremental watch;
  • schema-2 producer UTC timestamps and monotonic elapsed seconds, while schema-1 journals stay readable.

Publication precedes stage finish. Physical completion, outer outcome and acceptance are distinct facts. Readers can reconnect after the process exits. Writer loss leaves unresolved facts and never invents recovery or completion. Liveness evidence is best-effort, based on the filesystem and flock, and assumes a trusted local store of immutable records. Classic run/execute do not journal. See execution and results.

Machine callers request --json (contract 4). Observed stages and finalization emit flushed allocation and terminal JSONL; watch uses separate updates/status envelopes. Reader exit 0 means a terminal outcome was recorded, not that the flow was accepted.

Finalization

finalization allocates a separate operation snapshot that selects one completed fresh complete non-macro execution (seven stages for current plans; six for historical plans). It maps actual synthesis and signoff evidence and validates the retained runtime closure without repeating implementation. It can optionally run TT precheck, gate replay and the existing acceptance policy. Stage streams stay terminal and checkpoints keep acceptance: not_evaluated.

Not eligible: stitched resumed attempts and standalone signoff checkpoints. Not delivered: segmented artifact archive/GC, other images and cross-machine relocation.

Proposed store-wide protocol

Not implemented. A provisional synthetic fixture models the intended logical semantics: store-wide cursors, request idempotency, BUSY ownership through outer outcome, generation fencing, transitive readiness and retention. Those are logical decisions, not proven locking or durability.

The broader contract would:

  • describe capabilities and versions, and list or inspect explicit stores;
  • correlate a request with an early allocated operation or run;
  • inspect step occurrences, replay updates, and read versioned snapshots and evidence references.

Events describe allocation, lifecycle, publication and outcomes, never UI actions. Domain rules for any implementation:

  • One build may have several runs. Display names and numbered directories are not identities. Collecting or postchecking creates another operation attempt, not a new run; rerunning implementation normally creates a new run.
  • Preserve legacy run.json.status; add the requested-operation outcome separately. A step finishing and its results being published are separate facts. Earlier results stay available after a later failure. A result snapshot is not a resumable checkpoint.
  • Choose one coordinated write path for execute and standalone operations. Settle ordering, writer locks, snapshot/cursor consistency, retry semantics, incomplete writes and crashed producers first. Serialize conflicting mutations rather than adding a scheduler. Disconnected readers never block execution. Storage failure must be visible, and stale observation does not prove that a tool stopped.
  • Publish complete snapshots before advertising them. Measurements keep producer step/attempt, tool, stage, corner, units, constraints and raw source. LibreLane metrics accumulate, so an unchanged number cannot distinguish inherited evidence from a new equal measurement: keep origin explicit.
  • Archive policy must cover advertised history and evidence. Failed-run diagnostic export needs its own contract.

LibreLane integration constraints

From source inspection: SequentialFlow.run calls step.start directly and Step.start is final, so overriding Flow.start_step is not a lifecycle hook. Step substitutions and Step.run are extension points. Step.run returns metric updates before they merge with inherited state, but it does not cover gated steps or failures before or after computation. Per-step state files do not expose every lifecycle fact. Fine-grained observation therefore needs supported hooks with stated limits, or narrow upstream instrumentation, and must never copy the engine's orchestration. Full-flow acceptance must test the Dockerized path and real descendant cancellation.

9. Named methodologies and profiles

Projects declare which methodology and configuration to run as data. They do not script their own stage sequence.

Owner Responsibility
Consumer project Declares its flows, profiles and default selection in ordinary OCaml modules (the example: asic/flow_catalog.ml, asic/flow_profiles.ml), which are declared inputs
hardcaml_asic Typed Catalog, Methodology, Profile and Parameter APIs; resolution, validation, execution and authoritative evidence
Workbench client Displays choices, remembers a project-scoped {flow_id, profile_id} reference, launches and presents. It never holds a second copy of the methodology
LibreLane Keeps its backend engine, step implementations and physical checks

The current backend recipe is librelane.classic.v1, run as fresh, contiguous stage prefixes. The typed parameter surface is SYNTH_STRATEGY and SYNTH_ABC_BUFFERING; other parameters need an explicit backend contract first.

Preview resolves the selection, renders the bundle in memory and returns effective settings, provenance and a plan identity. It publishes nothing and runs no tools. Run resolves again, rejects a stale --expected-plan-identity, publishes the exact bundle and invokes the provider. The provider validates the plan against the bundle itself rather than trusting a profile label. Execution records freeze the flow and profile IDs, settings and identities, so later catalog changes never reinterpret history. Changing the active selection affects only future requests.

See named flows.