Skip to content

Feat trigger cond expr#74

Merged
Makiras merged 7 commits intomasterfrom
feat_trigger_cond_expr
Jan 29, 2026
Merged

Feat trigger cond expr#74
Makiras merged 7 commits intomasterfrom
feat_trigger_cond_expr

Conversation

@Makiras
Copy link
Contributor

@Makiras Makiras commented Jan 29, 2026

Description

Summary of changes:

  • Add atClone() hook for post-fork state re-initialization and expose it across C++/Go/Java/Lua/Python/Scala bindings; also fix DutUnifiedBase/C++ wrapper memory leaks and add a null check in FlushWaveform.
  • Defer Verilator waveform pause until a dumper exists to avoid crashes when no dumper is present.
  • Add filelist include parsing to codegen and expand unit tests (new codegen/parser unit cases plus shared test utilities).
  • Streamline init workflow and build flags by adding scripts/init.sh and adjusting top-level/template Makefile and CMake flags.
  • Make xcomm dependency fetch more robust with an explicit refspec.

Motivation/Context:

  • Support robust multi-process simulation (e.g., Python multiprocessing) by re-initializing child process state after fork.
  • Improve build/init stability and increase test coverage for filelist parsing.

Dependencies:

  • None (xcomm dependency usage is unchanged; fetch behavior is now more robust).

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have added the appropriate labels
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Makiras and others added 6 commits January 23, 2026 11:05
This commit includes two main fixes:

1.  **fix(cmake): Prevent unnecessary recompilation with Verilator**
    Sets CMake policy CMP0058 to NEW in the Verilator configuration.
    This corrects an issue where CMake would incorrectly detect that
    Verilator-generated files were newer than the dependency database,
    causing unnecessary recompilations and slowing down the build process.

2.  **fix(makefile): Improve xcomm dependency branch handling**
    The Makefile logic for checking out the  dependency branch
    has been made more robust. It now correctly handles detached HEAD
    states (common in CI/CD environments) by safely falling back to the
    master branch. This prevents build failures in automated environments.
The previous 'git fetch' command was not specific enough, causing
failures when the local remote-tracking branch for the xcomm dependency
was stale or did not exist.

This change uses an explicit refspec ('<src>:<dst>') to ensure the
remote branch is fetched and the local remote-tracking ref is
correctly created or updated before the checkout command is run.
This makes the branch alignment logic more robust.
Add a new `atClone()` method to the simulation core and expose it through all language bindings.

This method is intended to be called in a child process after a fork() to re-initialize the state of the Verilated model. This is crucial for supporting robust multi-process simulation environments, such as Python's `multiprocessing`, where forking can lead to an inconsistent state in the simulator's child instances.

Additionally, this commit includes several stability and memory management improvements:
- Fix memory leaks in `DutUnifiedBase` and the C++ wrapper by ensuring allocated resources are properly deallocated.
- Add a null-pointer check in `FlushWaveform` to prevent crashes when a waveform dumper is not present.
- Expose the `atClone` functionality to C++, Go, Java, Lua, Python, and Scala wrappers.
@Makiras Makiras self-assigned this Jan 29, 2026
@Makiras Makiras added the enhancement New feature or request label Jan 29, 2026
Copilot AI review requested due to automatic review settings January 29, 2026 07:35
FrankOu2001
FrankOu2001 previously approved these changes Jan 29, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds comprehensive support for multi-process simulation through the atClone() API across all language bindings (C++, Go, Java, Lua, Python, Scala), fixes memory leaks in the C++ wrapper and DutUnifiedBase, improves waveform dump handling in Verilator, expands filelist parsing with include directory support, adds extensive unit tests for parser and codegen functionality, and streamlines the initialization workflow.

Changes:

  • Adds atClone() hook for post-fork state re-initialization across all language bindings and fixes memory leaks in C++ wrapper destructor
  • Enhances filelist parsing to handle include directories (+incdir+, -I flags) and adds related unit tests
  • Adds 10+ new unit tests covering parser (Verilator/gsim/SV/internal config) and codegen (filelist/SV params/recursive render) functionality with shared test utilities
  • Defers Verilator waveform pause until dumper exists to prevent crashes and adds null check in FlushWaveform
  • Refactors initialization workflow into scripts/init.sh with more robust xcomm dependency fetching and branch alignment logic

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
template/lib/dut_base.hpp Adds atClone() virtual method to DutBase and DutVerilatorBase; adds wave_pause_deferred and wave_pause_warned flags
template/lib/dut_base.cpp Implements atClone() for DutVerilatorBase and DutUnifiedBase; adds deferred wave pause logic; fixes argv memory leak; adds null check in FlushWaveform
template/cpp/dut.hpp Exposes AtClone() method in wrapper class
template/cpp/dut.cpp Implements proper cleanup in destructor for signal_map and xcfg; exposes AtClone()
template/python/dut.py Adds AtClone() method wrapper with documentation
template/java/dut.java Adds AtClone() method wrapper
template/scala/dut.scala Adds AtClone() method wrapper
template/golang/dut.go Adds AtClone() method wrapper
template/lua/dut.lua Adds AtClone() method wrapper
template/mem_direct/Makefile Reorders linker flags (CXXFLAGS moved to end)
template/lib/cmake/verilator.cmake Adds CMake policy CMP0058 and --MMD --MP flags to Verilator
src/codegen/lib.cpp Adds include directory parsing (+incdir+, -I) to gen_filelist and append_incdirs_to_vflag function
scripts/init.sh New script consolidating verible check and xcomm dependency management with branch alignment logic
Makefile Refactors init target to use scripts/init.sh; adds explicit build step to unit_tests target
CMakeLists.txt Adds enable_testing() guarded by is_top_level_project check
test/test_common.cpp New shared test utilities providing stubs for globals and functions needed by test executables
test/test_parser_verilator_root_unit.cpp New unit test for Verilator header parsing
test/test_parser_gsim_root_unit.cpp New unit test for gsim code parsing
test/test_parser_sv_collect_unit.cpp New unit test for SV file collection from filelists
test/test_parser_map_unit.cpp New unit test for parser factory functions
test/test_parser_internalcfg_unit.cpp New unit test for internal pin configuration parsing
test/test_codegen_filelist.cpp New unit test for filelist generation with include directory handling
test/test_codegen_sv_param.cpp New unit test for SV parameter generation
test/test_codegen_sv_param_multi.cpp New unit test for multi-instance SV parameter generation
test/test_codegen_recursive_render.cpp New unit test for recursive template rendering
test/test_parser_internalcfg.cpp Updates path to use PICKER_EXAMPLE_DIR macro instead of relative path
test/CMakeLists.txt Adds new unit tests to build and test configuration; adds PICKER_EXAMPLE_DIR and PICKER_TEST_DATA_DIR
test/cmake/*.cmake New CMake configuration files for each unit test
test/data/VTop___024root.h New test data file for Verilator parser tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +13
static void write_text(const std::filesystem::path &p, const std::string &t)
{
std::ofstream o(p, std::ios::trunc);
o << t;
}
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The write_text helper does not check if the file stream opened successfully before writing. If the file cannot be created or opened for writing, the write operation will silently fail. Consider adding error checking.

Copilot uses AI. Check for mistakes.
@Makiras Makiras merged commit e5e764e into master Jan 29, 2026
12 checks passed
@Makiras Makiras deleted the feat_trigger_cond_expr branch January 30, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants