Skip to content

TT/CMOS5L bundle emission

Emission turns one validated chip target declaration into an immutable Tiny Tapeout project directory (a bundle). It never runs synthesis or hardening, invokes EDA tools or reads a PDK. Running a bundle is covered in execution and results.

Chip target entry point

The consumer owns a chip target constructor. The shared emission orchestration belongs to Hardcaml_asic.Chip_target.emit_bundle.

OCaml consumer code (inside a function with source_root and output_dir arguments):

let open Core.Or_error.Let_syntax in
let%bind chip_target = make_chip_target () in
Hardcaml_asic.Chip_target.emit_bundle chip_target ~source_root ~output_dir

The consumer can expose a declaration-only describe command and a separate emit command. See chip targets for a generated standalone project CLI.

Chip_target.create ?source_inputs defaults to []; Chip_target.source_inputs returns the declaration unchanged, including order and duplicates. Source paths belong to the project; the source root and output directory are execution arguments. Creation does not read or validate source files, and ordinary elaboration needs no inventory.

Chip_target.emit_bundle ?inputs ?include_simulation t ~source_root ~output_dir rejects an empty inventory before invoking the design. It then performs implementation elaboration/resolution (forwarding optional Target.Inputs.t), optional Simulation elaboration, Bundle.render, and finally Bundle.write. include_simulation defaults to true; false skips Simulation construction and uses the synthesis source set for simulation, without a separately elaborated simulation file. The example CLI uses the default. Rendering owns source canonicalization, Git provenance and input validation. No output is written before rendering succeeds. Writing requires a new/empty destination and is non-atomic: a write failure can leave partial output. No external flow tools or PDK reads occur during emission.

Identity-addressed publication

The library entry for a caller-owned results store is:

Chip_target.emit_bundle_to_store ?inputs ?include_simulation chip_target
  ~source_root ~store_dir
(* (Bundle.t * Bundle.Publication.t) Core.Or_error.t *)

The caller supplies store_dir, typically <results-root>/bundles; the library does not infer a results root or search the working directory. Relative explicit roots are accepted, and Publication.directory is the absolute public path <store_dir>/<Bundle.identity bundle>. Publication.t is a private record with readable directory : string and reused : bool fields. The project entry owns the same implementation/resolution, optional Simulation and render sequence as explicit emission, with the same early empty-inventory rejection and defaults. Consumers call this entry once rather than duplicating elaboration. Lower-level callers with an already rendered bundle can use Bundle.publish bundle ~store_dir : Bundle.Publication.t Core.Or_error.t. The example CLI defaults to ROOT/_flow_results/bundles; the installed provider separately defaults to the caller's cwd for run/operation storage. Chip_target.emit_bundle ~output_dir and Bundle.write retain their explicit new/empty-directory semantics.

On local POSIX filesystems the backing layout is:

<store_dir>/
  .objects/<identity>.<unique>/   complete bundle, no additional receipt
  <identity> -> .objects/<identity>.<unique>

An exclusively allocated object is fully written and verified before an exclusive symlink creates the public identity name. That operation never replaces an existing file, link or directory, even an empty directory. Concurrent publishers of the same bundle produce one creation and verified reuse; losers clean up only their own unpublished objects. Published objects must be retained. Exceptions during writing leave no public partial bundle. There is no store cleanup/GC (including objects left by an abruptly killed process), mutable current pointer, physical cache or resume.

Reuse compares the entire path set and exact bytes, including manifest.json. Extra files, extra empty directories, missing/corrupt bytes and symlinked members are rejected without changing the existing destination. Exact pre-existing plain directories are supported. Existing root links must point directly to a real, identity-prefixed child of .objects; escaping/dangling links, linked backing objects, symlinked store ancestors and file-valued parents fail with diagnostics. Store contents must remain stable against external mutation while publishing or verifying. This API makes no fsync/power-loss durability or NFS guarantees and adds no runtime Python or EDA requirement. Generated bytes, identity and schemas are identical to explicit emission. Preflight and run canonicalize the root link before use, and the archiver verifies and packages the underlying bundle files.

Lower-level composition and provider examples

Chip_target.elaborate returns an abstract Elaborated_project.t containing the Hardcaml circuit, metadata, intent and resources. Chip_target.elaborate_for_flow performs implementation elaboration and Resolved_flow.resolve, producing validated concrete TT/LibreLane facts plus the elaborated_project field. Bundle.render ~source_root ~input_paths resolved_flow renders that result; its optional ~simulation_project takes a separate Simulation elaboration. Bundle.write writes the bundle, and execution happens separately. (These names replaced Build/Resolved_build without changing persisted keys, schema or hashing.)

From this repository's root:

dune build
dune exec examples/tt_bundle_example.exe -- observable /tmp/asic-observable
dune exec examples/tt_bundle_example.exe -- memory /tmp/asic-memory
dune runtest

Each output directory must be new or empty. The optional third CLI argument is the source root; it defaults to the current directory. The command reads Git HEAD and every .ml/.mli under that root's lib/, including its group subdirectories, plus the example and Dune declarations. Missing source inputs and a source root without a Git commit fail before files are written. The command names no sibling checkout.

The memory example uses an explicitly selected four-word, eight-bit flop RAM. ui_in[1:0] is its address, ui_in[2] is write enable, uio_in is whole-word write data, ena enables access, and uo_out is registered read data. It has no reset or validity port on the RAM; reads of unwritten words are unspecified. The observable example registers ui_in on clk, clears on active-low rst_n, and drives zero to uo_out when ena is low. Its declared input and output delays (minimum 0 ns; maximum 1 ns on ui_in, rst_n and ena, 2 ns on uo_out) demonstrate typed SDC emission; these are example assumptions, not values inferred from the TT board. The minimum of 0 ns is the hold-pessimistic choice for inputs driven asynchronously to clk.

Bundle layout

Schema-1 manifests include requested_tools.runtime_policy in the hashed payload: host exact-minor Python 3.11 (also used for native execution), and the official LibreLane 3.1.0.dev3 Docker image with Python 3.10..3.14 (Requires-Python >=3.10). Older bundles without it keep strict 3.11 for both roles. To get the current semantics, emit a fresh bundle; never edit a preserved one. See runtime policy.

OUTPUT/
  info.yaml                 TT metadata, pinout, top, clock and source list
  src/config.json           resolved LibreLane settings
  src/<top>.v               synthesis RTL
  simulation/<top>.v        separately elaborated behavioral simulation RTL
  constraints/top.sdc       typed clock, target constraint environment, and
                            optional min/max I/O delays
  inputs/...                exact copies of declared generator source inputs
  manifest.json             schema version 1, identity and SHA-256 inventory

info.yaml names the single file under src/. VERILOG_FILES uses dir::<top>.v, relative to src/config.json. The SDC paths use dir::../constraints/top.sdc; the floorplan path uses dir::../tt/tech/ihp-sg13cmos5l/def/tt_block_6x4_pgvdd.def. The pinned TT project.py at the pinned TT revision expects a checkout linked at OUTPUT/tt when the physical flow runs. That checkout, the PDK, LibreLane and the flow runner are external prerequisites for execution; the bundle itself needs none of them. TT's create_user_config may regenerate derived settings from info.yaml; they originate from the same declaration and must agree with src/config.json. LibreLane's PnR and signoff SDC variables consume the generated timing file.

Generated SDC

Because PNR_SDC_FILE and SIGNOFF_SDC_FILE point at constraints/top.sdc, LibreLane's FALLBACK_SDC never runs, so this file is the whole timing environment. It is written in a fixed order, with every number formatted to round-trip exactly, so the same declaration always produces the same bytes:

create_clock -name clk -period 20.833333333333336 [get_ports {clk}]
set_clock_uncertainty 0.25 [get_clocks {clk}]
set_clock_transition 0.14999999999999999 [get_clocks {clk}]
set_timing_derate -early 0.94999999999999996
set_timing_derate -late 1.05
set_max_fanout 10 [current_design]
set_driving_cell -lib_cell sg13cmos5l_buf_4 -pin X [get_ports {ena rst_n ui_in uio_in}]
set_driving_cell -lib_cell sg13cmos5l_buf_4 -pin X [get_ports {clk}]
set_load 0.0060000000000000001 [get_ports {uio_oe uio_out uo_out}]
set_input_delay -max 1 -clock clk [get_ports {ena}]
set_input_delay -min 0 -clock clk [get_ports {ena}]
...

The clock and the per-port delays come from the chip target declaration; everything between them comes from the resolved target's constraint environment and is documented in the target reference. set_load is in the Liberty capacitive_load_unit, which is picofarads for sg13cmos5l, so the 6 fF OUTPUT_CAP_LOAD is divided by 1000 exactly as base.sdc does. The six LibreLane variables behind those lines are also emitted into src/config.json as Target-owned settings, so synthesis — which reads SYNTH_DRIVING_CELL, OUTPUT_CAP_LOAD and MAX_FANOUT_CONSTRAINT outside the SDC — optimises against the same environment that timing analysis assumes. All of them, plus IO_DELAY_CONSTRAINT, SYNTH_CLK_DRIVING_CELL, MAX_TRANSITION_CONSTRAINT and MAX_CAPACITANCE_CONSTRAINT, are protected keys: a raw override of one would either do nothing or move synthesis away from what the SDC analyses.

No set_propagated_clock or unset_propagated_clock appears, on purpose. LibreLane's read_current_sdc greps the file for both and, finding neither, unpropagates clocks for pre-CTS analysis and propagates them afterwards.

The two RTL source sets have separate paths and are compiled independently. For the memory example, the synthesis set contains flop storage without behavioral poison initialization; the simulation set contains diagnostic initialization. No consumer should compile both sets together. The manifest lists each set explicitly and records the resource request, selection reason, source roles, resolved settings and override reasons.

The manifest identity is SHA-256 of its canonical ordered payload, excluding the identity field itself. Its file inventory hashes every emitted file except the manifest. Each declared input has a content hash, Git status, and a copy under inputs/, so dirty and untracked source bytes remain retrievable. Target references record their role, path, revision, corner and any known hash. The floorplan has a pinned SHA-256; standard-cell PDK views are external references whose installed bytes are checked by preflight. Actual run versions, logs and reports belong to separate execution records.

dune runtest regenerates both examples in a temporary Git repository, checks stable output and content hashes, changes a tracked source and adds an untracked source to prove manifest identity changes, checks missing-input diagnostics, and compiles and simulates each RTL source set with Icarus when it is installed. The testbench is test/tt_bundle_tb.v. The Flow guide covers preflight, isolated execution, result collection, and physical acceptance evidence.

Project API regression commands and coverage

From the provider checkout with the existing OCaml tools available:

python3 test/check_project_api.py --provider-checks
# External integration only, after dune build @install:
python3 test/check_project_api.py

--provider-checks runs dune build @install, full dune runtest --force, the external Resolved_flow checker (eight private-record rejection checks), and the external Project consumer. It does not install into a shared prefix. The runner preserves normal PATH, including available iverilog and vvp; the existing bundle suite skips optional RTL replay only when those tools are absent. Git configuration/identity are isolated and inherited Git selectors removed. Temporary fixture commits use author and committer Bundle test <bundle@test.invalid>, with no remotes. Neither external compiler checker is a Dune runtest action: each builds unrelated consumers against _build/install/default/lib.

  • test/test_project.ml: default empty inventory, declaration-only description, pre-design emission rejection, and ordinary elaboration afterward.
  • test/project_api_consumer.ml: public signatures, exact inventory retention, default/explicit-true equivalence, false skipping a rejecting Simulation constructor, synthesis-source fallback, construction/resolution/simulation/ render/write failures, no premature output, and nonempty-output preservation.
  • Target overrides cover revisions, floorplan hash and constraints. Observable and memory designs each compare high-level emission with manual lower-level composition, both with and without Simulation: four complete on-disk bundle comparisons, including identity. examples/tt_bundle_example.ml remains the low-level oracle; the checker copies its declarations and injects test arguments only in a temporary consumer. Its separate let simulation_project = construction remains intact for the existing lower-level checker.
  • Those same four bundles also compare emit_bundle_to_store against explicit emission and manual composition, byte for byte. Publication default/false options retain design call counts, and both public record construction and update are rejected by the external compiler. Explicit roots and source names include spaces.
  • check_project_api.py verifies first publication, inode/mtime-preserving repeat reuse, exact plain-directory reuse, preserved corrupt/missing/extra/file/empty-dir and symlink collisions, store/parent corruption, and forced real write failure using POSIX RLIMIT_FSIZE. Two independent OCaml processes render before a gate releases them into a real publication race, requiring one created result and one verified reuse with only one retained object. Preflight/run canonicalization and archive bundle selection, hash validation and input-tarball verification exercise the root-link layout without executing EDA.

Renaming or copying source inputs legitimately changes bundle identity through provenance, even when the hardware is byte-identical.