Skip to content

feat(rtl): add load_blackbox_wrapper for NDA hard macros#163

Open
lanserge wants to merge 1 commit intomainfrom
feat/blackbox-wrapper
Open

feat(rtl): add load_blackbox_wrapper for NDA hard macros#163
lanserge wants to merge 1 commit intomainfrom
feat/blackbox-wrapper

Conversation

@lanserge
Copy link
Copy Markdown
Contributor

@lanserge lanserge commented Apr 22, 2026

Summary

  • New load_blackbox_wrapper(logical_name, clocks=..., resets=...) loads a hard macro declared under [chipflow.silicon.macros] from a *.blackbox.json produced by macrostrip, and returns a BlackboxWrapper (subclass of RTLWrapper) ready to drop into a design.
  • SiliconPlatform.add_macro() registers each instantiated macro with the platform.
  • At submit time, registered macros are packed inside the existing bundle.zip (not as a separate field). Each macro's companion files (LEF, Liberty, frame/real GDS, Verilog stub, blackbox JSON) live under macros/<logical_name>/ and surface in manifest.json as a dict keyed by logical name with _file-suffixed paths so the chipflow-backend's existing recursive _bundle_files_from_manifest extractor picks them up — purely additive on the receiving side.
  • RTLWrapper._validate_signal_bindings now accepts either i_<name> / o_<name> or bare <name> Verilog port-declaration conventions (LEF-derived hard-macro stubs use the bare form).
  • Docs: new [chipflow.silicon.macros] section in chipflow-toml-guide.rst; rtl-wrapper.rst gains NDA + non-NDA workflow subsections; CLAUDE.md reflects the new config section and chipflow/rtl/ surface.

The same path covers non-NDA macros: run macrostrip blackbox --frame-gds=<real.gds> instead of macrostrip frame, and skip macrostrip swap on return — chipflow-lib treats frame_gds as "the GDS to include," frame-view or real.

Manifest shape (added on top of the existing bundle keys)

{
  "version": "1",
  "project": "...",
  "process": "...",
  "package": "...",
  "design_file": "top.il",
  "pins_lock_file": "pins.lock",
  "macros": {
    "sram_64x64": {
      "name": "sram_64x64",
      "lef_file":           "macros/sram_64x64/sram_64x64.lef",
      "liberty_file":       "macros/sram_64x64/sram_64x64.lib",
      "frame_gds_file":     "macros/sram_64x64/sram_64x64.gds",
      "verilog_stub_file":  "macros/sram_64x64/sram_64x64.v",
      "blackbox_json_file": "macros/sram_64x64/sram_64x64.blackbox.json"
    }
  }
}

No wire-format change vs the bundle PRs already in production: API still receives one bundle multipart part, backend extracts every _file-suffixed manifest leaf into the working dir.

Why a single bundle (recap)

The earlier iteration of this PR posted a separate macros.tar.gz as a third multipart field. That was reworked to use the bundle approach instead — see the merged transport work for context:

Adding macros becomes additive: new manifest keys + new folders inside the same zip. No changes needed in chipflow-api or chipflow-backend.

Test plan

  • pytest --ignore=tests/test_cli_integration.py — 73 passed, 10 skipped (pre-existing CLI-integration skips).
  • ruff check clean on chipflow/ and tests/.
  • New tests/test_blackbox_wrapper.py::BuildBundleWithMacrosTestCase covers: macros omitted when none registered; macros present produce dict-keyed manifest entries with _file-suffixed paths under macros/<logical_name>/....
  • End-to-end against chipflow-api-staging once a real macro is wired into chipflow-test-socs.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

Tests Skipped Failures Errors Time
94 10 💤 0 ❌ 0 🔥 34.852s ⏱️

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://chipflow-lib.docs.chipflow-infra.com/pr-preview/pr-163/

Built to branch gh-pages at 2026-04-30 07:24 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Adds a tool-agnostic path for integrating hard macros (NDA SRAMs, vendor
IP, PLLs) into a ChipFlow design via a `*.blackbox.json` produced by the
sibling `macrostrip` tool. Macros are declared by logical name under
`[chipflow.silicon.macros]` and instantiated from Python with
`load_blackbox_wrapper(name, clocks=..., resets=...)`, which synthesizes
an `ExternalWrapConfig` from the JSON's pin list and returns a
`BlackboxWrapper` (subclass of `RTLWrapper`).

At submit time the platform bundles each macro's companion files (LEF,
Liberty, frame-view or real GDS, Verilog stub, blackbox JSON) into a
`macros.tar.gz` with a root `manifest.json` and posts it as a third
multipart field alongside `rtlil` and `config`, so the ORFS-based
backend can ingest them via `ADDITIONAL_LEFS` / `ADDITIONAL_LIBS` /
`ADDITIONAL_GDS_FILES` without the real macro layout ever leaving
customer premises.

Also widens `RTLWrapper._validate_signal_bindings` to accept either the
`i_<name>` / `o_<name>` or bare `<name>` port-declaration conventions —
LEF-derived hard-macro stubs use the bare form.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant