Skip to content

formal: add SymbiYosys proof for cc_heaviside - #351

Merged
phsauter merged 2 commits into
pulp-platform:masterfrom
briann-bui:formal/cc_heaviside
Jul 28, 2026
Merged

formal: add SymbiYosys proof for cc_heaviside#351
phsauter merged 2 commits into
pulp-platform:masterfrom
briann-bui:formal/cc_heaviside

Conversation

@briann-bui

@briann-bui briann-bui commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Add open-source formal verification for cc_heaviside (Closes #350, subtask of #288).

Changes

Formal verification

  • Add formal/cc_heaviside_properties.sv, a bound property checker that proves full functional
    equivalence against a loop-based reference model.
  • Add formal/cc_heaviside_formal.sv, an elaboration harness covering widths 1 through 33,
    including power-of-two and non-power-of-two configurations.
  • Add formal/heaviside.sby, a depth-1 SymbiYosys proof using the smtbmc engine.
  • Add heaviside.check to formal/Makefile.

Documented behavior

  • Document that inputs greater than or equal to Width saturate mask_o to all ones.
  • Capture the same saturation behavior explicitly in the formal reference model.

How to run

cd formal
make heaviside.check

Validation

  • The property covers widths 1 through 33, including out-of-range encodings for
    non-power-of-two widths.
  • Verible lint passes.
  • The formal harness compiles and elaborates successfully with VCS X-2025.06.

Add a formal verification harness and property checker for cc_heaviside.

Properties proven:
- Full functional equivalence against a reference model
- Bit 0 is always asserted for any valid input
- All-ones mask when x_i == Width-1 (upper boundary)
- Only bit 0 set when x_i == 0 (lower boundary)
- Monotonicity: bit at position x_i is always set
- Upper bits (above x_i) are always zero

The elaboration harness (cc_heaviside_formal) exercises widths from 1
to 33 inclusive, covering both power-of-two and non-power-of-two
parametrizations.

The new heaviside.check target is integrated into the existing
formal/Makefile and follows the same conventions as the lzc target.

Closes pulp-platform#350

@phsauter phsauter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell Property 1 already proves the complete function, Properties 2–6 are logically redundant.
It can make sense to add redundant checks but really only if one property would be difficult to debug due to complex temporal effects. For this small, combinational proof I do not think they are needed.

Please also clarify the behavior for non-power-of-two Width values. Since idx_width(Width) can represent values greater than or equal to Width, the current unconditional equivalence property effectively makes it so that all out-of-range indices produce an all-ones mask. I actually think this saturation is good and makes it more like a finite-width heaviside function and it preserves monotonicity but it should be documented (in the module as well, we should just make the behavior explicit).

@briann-bui

Copy link
Copy Markdown
Contributor Author

@phsauter, I addressed your review in commit 337ff0d:

  • removed the redundant Properties 2–6, leaving the full functional equivalence property;
  • documented that x_i >= Width saturates mask_o to all ones in cc_heaviside;
  • documented the same behavior in the formal checker and reference model;
  • updated the PR description to match the revised proof.

Validation: Verible lint passes, and the formal harness compiles/elaborates successfully with VCS X-2025.06. The local SymbiYosys run could not be repeated because this environment does not provide the required sby/Yosys-Slang toolchain.

Could you please review again when convenient? Thanks!

@phsauter phsauter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for the help!

@phsauter

Copy link
Copy Markdown
Collaborator

The local SymbiYosys run could not be repeated because this environment does not provide the required sby/Yosys-Slang toolchain.

Btw you can get all the open-source tools even with the open-source PDKs in a nice docker container, see here: https://github.com/iic-jku/IIC-OSIC-TOOLS
This is super useful for local work on laptops etc and also very useful to give AI agents etc.

@phsauter
phsauter merged commit c63eada into pulp-platform:master Jul 28, 2026
3 checks passed
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.

Add formal verification for cc_heaviside

2 participants