This file provides context and engineering guidelines for the XLS project.
Core Information:
- What is XLS: XLS is a 'Mid-Level' Synthesis toolchain for hardware development. It shares goals with High-Level Synthesis (HLS) tools but operates at a lower level to improve development velocity, quality, reliability, and security.
- Open Source: The core XLS toolchain and base libraries are open-sourced
under an Apache 2.0 license at
https://github.com/google/xls, with
documentation at
https://google.github.io/xls/ (source in
docs_src/, includingdocs_src/dslx_reference.md,docs_src/dslx_std.md, anddocs_src/tutorials/). - Bugs & Issues: Public bugs are tracked on
GitHub Issues. Use keywords like
Fixes google/xls#NNNin commit messages to close issues.
Style Guides & Code Quality:
- Style Guides: Always follow the Google style guides
(C++,
Python,
Shell), which take
precedence, and the XLS Style Guide
(https://google.github.io/xls/style_guide,
docs_src/xls_style.md). - Optional Non-Owning References (
absl::optional_ref): Useabsl::optional_ref<T>instead ofstd::optional<T*>(or nullableT*) for optional non-owning references, except for IR, AST, and VAST node/element types (Node*,FunctionBase*,dslx::AstNode*,verilog::VastNode*), which are uniformly passed as pointers and usestd::optional<T*>(seedocs_src/xls_style.mdforXLS_ASSIGN_OR_RETURNusage and naming). - Conceptual Simplicity & Reuse: Prefer the simplest code that solves the
general problem at the root cause rather than patching a single caller or
pass. Reuse existing XLS/Abseil utilities (
DecoratingDelayEstimator,AstNodeRecursiveVisitor,absl::FunctionRef/AnyInvocableoverstd::function,absl::SimpleAtoi,ABSL_FLAG) and factor multi-statement lambdas or local classes into module-scope helpers. - Error Handling: Never silently saturate on integer overflow in
scheduling/delay math or ignore statuses with
.IgnoreError()when failure indicates a broken invariant; returnabsl::InvalidArgumentErroror useXLS_RET_CHECK/XLS_ASSIGN_OR_RETURN. - Codegen 1.5 Default: Target Codegen 1.5 (
xls/codegen_v_1_5/) for all new codegen bug fixes and features. Do not modify Codegen 1.0 (xls/codegen/) unless trivial or explicitly requested. - Idiomatic DSLX (Don't Transliterate Verilog): Follow the DSLX section in
docs_src/xls_style.md(booloveru1,x[i+:bool],std::msb(x),enums,pub struct+implover >3-element tuples, pure datapath functions separated fromprocFSM state,PascalCaseprocnames, anddslx_fmt --simplify_type_annotations -i). - Verification & Hermetic Tests:
- Build & CI: Use
bazeliskfor building and testing; GitHub Actions runs CI. - Fail on base: Verify that every new regression test fails without the fix and passes with it. Keep each change to one logical concern and include regression tests/crashers in the same change as the fix.
- Builder IR & equivalence checks: Build unit-test IR with
FunctionBuilder/ProcBuilder/BlockBuilder(notParser::ParsePackage). When usingScopedVerifyEquivalence, prefer smaller bit-widths where practical so the equivalence solver stays fast, rather than working around slow solver checks by inflating timeouts or adding retries. - Testbench X-prop:
ModuleTestbenchintentionally drives'xwhenvalidis deasserted to verify X-propagation; do not weaken this in tests.
- Build & CI: Use
- Comments: Add concise comments explaining why non-obvious invariants
exist, and keep transient synthesis/benchmark tables in commit messages
rather than source or
BUILDcomments (using 50 seeds for seeded synthesis comparisons).