Skip to content

Fix verilog_reader importing NOR and XNOR assignments as constant zero - #713

Open
vera-rubin wants to merge 4 commits into
lsils:masterfrom
vera-rubin:fix/verilog-reader-nor-xnor
Open

vera-rubin wants to merge 4 commits into
lsils:masterfrom
vera-rubin:fix/verilog-reader-nor-xnor

Conversation

@vera-rubin

@vera-rubin vera-rubin commented Oct 13, 2026 •

Copy link
Copy Markdown

The reader's missing NOR and XNOR callbacks imported these assignments as constant zero. We add the callbacks and use native NAND, NOR and XNOR creation when available, with equivalent fallbacks otherwise. Tests cover native and fallback paths in AIG, k-LUT, MIG and the other reader networks, and the full suite passes before and after.

Fixes #712

— ChipLab

lorina dispatches `assign y = ~( a | b );` and `assign y = ~( a ^ b );`
to `on_nor` and `on_xnor`, but `verilog_reader` did not override them,
so the inherited empty callbacks left the left-hand side undefined and
the outputs were later created as constant 0.

Add `on_nor` and `on_xnor` following `on_nand`. They negate `create_or`
and `create_xor`, since not every network implements `create_nor` or
`create_xnor` (e.g. `klut_network`, `mig_network`).
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.08%. Comparing base (1c9c3af) to head (68b4291).

Files with missing lines Patch % Lines
include/mockturtle/io/verilog_reader.hpp 75.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #713      +/-   ##
==========================================
- Coverage   84.10%   84.08%   -0.02%     
==========================================
  Files         191      191              
  Lines       29579    29608      +29     
==========================================
+ Hits        24876    24895      +19     
- Misses       4703     4713      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@myskyko

myskyko commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the PR. Why don't we use create_nor and create_xnor? Probably we don't need the function description comment for this file.

mig_network has no create_xnor and klut_network has neither, so fall back to create_not of create_or/create_xor when has_create_nor_v / has_create_xnor_v is false.
@vera-rubin

Copy link
Copy Markdown
Author

Thanks! Done: it now uses create_nor/create_xnor when the network provides them and falls back for networks that don't (mig_network has no create_xnor, klut_network has neither). I also dropped the function comments.

@myskyko

myskyko commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

If we support those network types then probably we should also add a fallback for the earlier create_nand. It would be also nicer if test covers other network types (klut and perhaps aig) to check both regular and fallback paths.

Use create_nand when available, otherwise negate create_and in the same
style as the NOR and XNOR callbacks. Run the assignment regression on AIG,
XAG, MIG, k-LUT, XMG and MuxIG, plus a test-only k-LUT variant without
create_nand to exercise the fallback.
@vera-rubin

Copy link
Copy Markdown
Author

@myskyko The new commit adds the create_nand fallback and tests that read NAND/NOR/XNOR into aig and klut, covering both native and fallback paths. A test-only klut variant without create_nand exercises the NAND fallback too.

— ChipLab

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.

Verilog reader imports NOR and XNOR assignments as constant zero

2 participants