Skip to content

Switching from Synlig to Yosys-Slang #3181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jul 14, 2025
Merged

Conversation

loglav03
Copy link
Contributor

@loglav03 loglav03 commented Jul 3, 2025

Description

Replaced Synlig/Surelog with the Yosys-Slang plugin for Yosys for reading SystemVerilog.

Yosys-Slang is installed by default in the build system and depends on Yosys. To use Yosys-Slang as the parser instead of the default Yosys parser, add the '-parser slang' option at the end of your 'run_vtr_flow.py <circuit> <arch>' or add it to the script parameters in the config file for regression test suites.

Yosys-Slang can be used to parse both verilog and SystemVerilog but may require specific syntax when parsing with verilog.

If you disable the cmake param "-DWITH_PARMYS" you should also disable the "-DSLANG_SYSTEMVERILOG" param as well to avoid cmake errors.

Related Issue

  1. System Verilog support is broken due to compilation error in F4PGA plugin #2821
  2. Embed slang-yosys plugin as a SystemVerilog frontend for yosys #3108

Motivation and Context

Synlig has a lot of overhead when building with the vtr build system leading to issues when building in CI and sometimes locally. Synlig is also poorly maintained. Yosys-Slang has significantly less overhead, can easily be implemented as a plugin for yosys, and is regularly maintained.

How Has This Been Tested?

Has been tested with the vtr_reg_system_verilog tests [PASSED]

Types of changes

  • [ x] Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ x] My change requires a change to the documentation
  • [ x] I have updated the documentation accordingly
  • [ x] I have added tests to cover my changes
  • [ x] All new and existing tests passed

loglav03 and others added 5 commits June 26, 2025 17:38
…stall with vtr when enabled with the cmake parameter -DSLANG_SYSTEMVERILOG=ON
…ultiple .sv files instead of single flattened .sv files (with the exception of the f4pga_pulse_width_led test since it uses .v files instead of .sv)
@github-actions github-actions bot added lang-cpp C/C++ code build Build system lang-python Python code lang-make CMake/Make code external_libs labels Jul 3, 2025
@github-actions github-actions bot added the infra Project Infrastructure label Jul 3, 2025
@github-actions github-actions bot added the docs Documentation label Jul 7, 2025
@loglav03
Copy link
Contributor Author

loglav03 commented Jul 8, 2025

@petergrossmann21 - I ran tests with yosys-slang enabled on the benchmarks you listed in this PR #2885. Some of these benchmarks made it through the entire flow and passed while others failed at read_slang in Yosys or failed at the VPR stage. There are also many other benchmarks not in the list that also failed with yosys-slang. Whenever you're available Peter I'll need help with HDL file cleanup for this.

Passing VPR Benchmarks:

blob_merge
diffeq1
diffeq2
single_ff
single_wire

Failing VPR Benchmarks:

and_latch
arm_core
boundtop
ch_intrinisics
multiclock_output_and_latch
multiclock_reader_writer
multiclock_separate_and_latch
stereovision3

I have not tried koios yet since the benchmarks take a long time to run, but I'm sure I will see similar results.

@loglav03 loglav03 marked this pull request as ready for review July 10, 2025 20:31
Copy link
Contributor

@AlexandreSinger AlexandreSinger left a comment

Choose a reason for hiding this comment

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

HI @loglav03 thank you so much for this PR! The CI test you added is exactly what I had in mind. Great job!

Some comments below.


# Ensure dependencies like Yosys are built first
DEPENDS yosys # Ensure submodule sync runs before synlig build
BUILD_COMMAND ${CMAKE_COMMAND} --build ${SLANG_BUILD_DIR} -- -j${PROCESSOR_COUNT}
Copy link
Contributor

Choose a reason for hiding this comment

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

"-j${PROCESSOR_COUNT}" should not be set here. The number of threads is enhereted by the make that creates it. I think this should not be here. This can have some odd affects. This is what is causing this warning:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually uses -j1 if I remove the "-j${PROCESSOR_COUNT}". I get this when I remove it:
gmake[4]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.

SOURCE_DIR ${SLANG_SRC_DIR}
BINARY_DIR ${SLANG_BUILD_DIR}

#Disabling UndrivenPass in slang_frontend.cc
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add some more comments here as to why we need to patch slang. Is this something that we can bring back to the slang master? Or is there something integral to VTR that causes problems?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I currently have it patching slang to disable the UndrivenPass because it was failing benchmarks due to unsupported synchronous rules in vtr_primitives.v and wouldn't let me run any benchmark with read_slang without disabling that pass.

I believe Peter is working on this in his work to clean up benchmarks to be compatible with read_slang. So if that ends up being fixed, I'll probably be able to remove the patch step for slang. I think we can leave this in for now just so the CI is able to pass the SystemVerilog reg test.

@loglav03 loglav03 changed the title [WIP] Switching from Synlig to Yosys-Slang Switching from Synlig to Yosys-Slang Jul 11, 2025
Copy link
Contributor

@AlexandreSinger AlexandreSinger left a comment

Choose a reason for hiding this comment

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

Thank you for resolving my prior comments! I appreciate it. This PR is looking very close to being able to be merged. I just have two final comments:

First, regarding the "-j" issue. When you remove it, it was asking you to prefix your call to the make subprocess with "+". So that would look like BUILD_COMMAND +${CMAKE_COMMAND} .... This should enable the job server of our CMake to communicate with the sub-cmake that you are calling. I wonder if this is the cause of the multiple builds we are seeing for the Yosys build? May be worth looking into. But for this PR, can you please remove the -j... option and prepend the build command with +. I want to avoid confusing warnings from showing up to users of VTR.

Second, thank you for adding back the koios SV regression test. It is actually very common to forget this. I actually made a CI test to check for this type of thing automatically. I only have it run on currently run test suites. Can you please add vtr_reg_system_verilog to this config file:

{
"name": "vtr_reg_valgrind_small",
"ignored_tasks": []
},

I do not think you need to mark any tests as ignored, so you can just copy the entry for vtr_reg_valgrind_small

@loglav03
Copy link
Contributor Author

@AlexandreSinger All comments should be resolved now! Simply adding a + to the build_command for slang didn't work so I had to find a workaround for it. It should be inheriting threads properly now without emitting a warning.

Copy link
Contributor

@AlexandreSinger AlexandreSinger left a comment

Choose a reason for hiding this comment

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

LGTM

@AlexandreSinger AlexandreSinger merged commit 3ad299e into master Jul 14, 2025
30 checks passed
@AlexandreSinger AlexandreSinger deleted the synlig_to_yosys_slang branch July 14, 2025 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build system docs Documentation external_libs infra Project Infrastructure lang-cpp C/C++ code lang-make CMake/Make code lang-python Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy