-
Notifications
You must be signed in to change notification settings - Fork 7
Generate sources list #198
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
Open
adrianf0
wants to merge
7
commits into
master
Choose a base branch
from
generate_sources_list
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2bb49b0
Fix copy_rtl_files
mksoc b398eb8
refactor(utils): replace copy_rtl_files with generate_sources_list
adrianf0 1329803
chore: remove vhier and related CMake integration
adrianf0 ceb38e2
fix(generate_sources_list): split output into rtl and include sources…
adrianf0 2bcf95c
refactor(generate_sources_list): replace Python script with direct sl…
adrianf0 a3247ed
docs(generate_sources_list): clarify OUTDIR keyword description in co…
adrianf0 4fd034f
feat(generate_sources_list): add SLANG_ARGS option for extra slang ar…
adrianf0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
98 changes: 98 additions & 0 deletions
98
cmake/utils/generate_sources_list/generate_sources_list.cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #[[[ | ||
| # Generates a filtered and organized list of RTL (Register Transfer Level) source files for a specified IP library target. | ||
| # | ||
| # This function collects all relevant RTL source files (excluding simulation, testbench, and FPGA-specific files) associated | ||
| # with the given ~IP_LIB~ target. It produces a file containing: | ||
| # * All source files required for synthesis, preserving their directory hierarchy. | ||
| # * All include directories and files needed for compilation. | ||
| # * Only the files instantiated in the design hierarchy, as determined by the `slang` tool. | ||
| # | ||
| # The hierarchy is parsed using `slang` (https://github.com/MikePopoloski/slang), ensuring that only the necessary | ||
| # files for the specified top module (if provided) and its dependencies are included. | ||
| # | ||
| # :param IP_LIB: Name of the IP library target to analyze. | ||
| # :type IP_LIB: string | ||
| # | ||
| # **Keyword Arguments** | ||
| # :keyword OUTDIR: (Optional) Output directory for the generated file lists. Defaults to ${CMAKE_BINARY_DIR}/ip_sources | ||
| # :type OUTDIR: string | ||
| # :keyword TOP_MODULE: (Optional) Name of the top module to use as the root of the hierarchy. Only modules below this point are included. An error is reported if the specified module does not exist. | ||
| # :type TOP_MODULE: string | ||
| # :keyword SLANG_ARGS: (Optional) Extra arguments to pass directly to slang. | ||
| # :type SLANG_ARGS: list | ||
| #]] | ||
| function(generate_sources_list IP_LIB) | ||
| cmake_parse_arguments(ARG "" "OUTDIR;TOP_MODULE;SLANG_ARGS" "" ${ARGN}) | ||
| if(ARG_UNPARSED_ARGUMENTS) | ||
| message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") | ||
| endif() | ||
|
|
||
| # Find slang executable | ||
| find_program(SLANG_EXECUTABLE slang) | ||
| if(NOT SLANG_EXECUTABLE) | ||
| message(FATAL_ERROR "slang executable not found! Please install slang or set SLANG_EXECUTABLE.") | ||
| endif() | ||
|
|
||
| # Initialize variables | ||
| set(INCDIR_ARG) | ||
| set(TOP_MODULE_ARG) | ||
| set(USER_SLANG_ARGS) | ||
|
|
||
| include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../hwip.cmake") | ||
| alias_dereference(IP_LIB ${IP_LIB}) | ||
|
|
||
| if(NOT ARG_OUTDIR) | ||
| set(OUTDIR ${CMAKE_BINARY_DIR}/ip_sources) | ||
| else() | ||
| set(OUTDIR ${ARG_OUTDIR}) | ||
| endif() | ||
|
|
||
| # If a top module is provided, only modules in its hierarchy are included. | ||
| if(ARG_TOP_MODULE) | ||
| list(APPEND TOP_MODULE_ARG --top ${ARG_TOP_MODULE}) | ||
| endif() | ||
|
|
||
| # Get the list of RTL sources | ||
| get_ip_sources(RTL_SOURCES ${IP_LIB} SYSTEMVERILOG VERILOG) | ||
| get_ip_include_directories(RTL_INCDIRS ${IP_LIB} SYSTEMVERILOG) | ||
| foreach(_i ${RTL_INCDIRS}) | ||
| list(APPEND INCDIR_ARG -I${_i}) | ||
| endforeach() | ||
|
|
||
| if(ARG_SLANG_ARGS) | ||
| list(APPEND USER_SLANG_ARGS ${ARG_SLANG_ARGS}) | ||
| endif() | ||
|
|
||
| set(RTL_FILE ${OUTDIR}/rtl_sources.f) | ||
| set(INCLUDE_FILE ${OUTDIR}/include_sources.f) | ||
| file(MAKE_DIRECTORY ${OUTDIR}) | ||
|
|
||
| set(SLANG_CMD | ||
| ${SLANG_EXECUTABLE} | ||
| --depfile-trim --Mmodule ${RTL_FILE} --Minclude ${INCLUDE_FILE} | ||
| ${TOP_MODULE_ARG} | ||
| ${INCDIR_ARG} | ||
| ${USER_SLANG_ARGS} | ||
| ${RTL_SOURCES} | ||
| ) | ||
|
|
||
| get_ip_links(DEPENDENT_TARGETS ${IP_LIB}) | ||
|
|
||
| add_custom_command( | ||
| OUTPUT ${RTL_FILE} ${INCLUDE_FILE} | ||
| COMMAND ${SLANG_CMD} | ||
| DEPENDS ${DEPENDENT_TARGETS} ${RTL_SOURCES} | ||
| COMMENT "Generating list of the RTL source files in ${OUTDIR}" | ||
| VERBATIM | ||
| ) | ||
|
|
||
| add_custom_target( | ||
| ${IP_LIB}_source_list | ||
| DEPENDS ${RTL_FILE} ${INCLUDE_FILE} | ||
| COMMENT "Target for generating filtered RTL source list for ${IP_LIB}" | ||
| VERBATIM | ||
| ) | ||
|
|
||
| message(STATUS "To generate RTL source list for ${IP_LIB}, build the target: ${IP_LIB}_source_list") | ||
|
|
||
| endfunction() |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benoitdenkinger will add a simple test to using slang instead on vhier