From 0494d0f8bfbf6bfd7449646d7b0bad9b2056db52 Mon Sep 17 00:00:00 2001 From: jalcim Date: Mon, 2 Mar 2026 19:53:50 +0100 Subject: [PATCH 1/2] Add --func-recursion-depth CLI option CONST_FUNC_RECURSION_MAX was hardcoded to 1000 in V3Simulate.h. When a recursive constant function exceeds this depth, Verilator silently gives up on constant folding with no way to increase the limit. Add --func-recursion-depth (default 1000) so users can raise it without patching the source. --- bin/verilator | 1 + docs/guide/exe_verilator.rst | 8 ++++++++ src/V3Options.cpp | 1 + src/V3Options.h | 2 ++ src/V3Simulate.h | 5 ++--- test_regress/t/t_func_recurse_depth.py | 18 ++++++++++++++++++ test_regress/t/t_func_recurse_depth.v | 24 ++++++++++++++++++++++++ 7 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 test_regress/t/t_func_recurse_depth.py create mode 100644 test_regress/t/t_func_recurse_depth.v diff --git a/bin/verilator b/bin/verilator index a94b7fe56..6b1dde45a 100755 --- a/bin/verilator +++ b/bin/verilator @@ -390,6 +390,7 @@ detailed descriptions of these arguments. -f Parse arguments from a file -FI Force include of a file --flatten Force inlining of all modules, tasks and functions + --func-recursion-depth Maximum recursive constant function depth --future0