formal: add SymbiYosys proof for cc_heaviside - #351
Conversation
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
left a comment
There was a problem hiding this comment.
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).
|
@phsauter, I addressed your review in commit
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 Could you please review again when convenient? Thanks! |
phsauter
left a comment
There was a problem hiding this comment.
Looks good to me, thanks for the help!
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 |
Summary
Add open-source formal verification for
cc_heaviside(Closes #350, subtask of #288).Changes
Formal verification
formal/cc_heaviside_properties.sv, a bound property checker that proves full functionalequivalence against a loop-based reference model.
formal/cc_heaviside_formal.sv, an elaboration harness covering widths 1 through 33,including power-of-two and non-power-of-two configurations.
formal/heaviside.sby, a depth-1 SymbiYosys proof using thesmtbmcengine.heaviside.checktoformal/Makefile.Documented behavior
Widthsaturatemask_oto all ones.How to run
cd formal make heaviside.checkValidation
non-power-of-two widths.