Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions SoCMakeConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/uniquify_files_by_basename.cmake"
# ====================================
# ======== Additional utilities ======
# ====================================
include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/copy_rtl_files/copy_rtl_files.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/copy_rtl_files/read_rtl_sources.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/copy_rtl_files/vhier.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/generate_sources_list/generate_sources_list.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/generate_sources_list/read_rtl_sources.cmake")

# ====================================
# ======== Simulation ================
Expand Down
91 changes: 0 additions & 91 deletions cmake/utils/copy_rtl_files/copy_rtl_files.cmake

This file was deleted.

106 changes: 0 additions & 106 deletions cmake/utils/copy_rtl_files/copy_rtl_files.py

This file was deleted.

54 changes: 0 additions & 54 deletions cmake/utils/copy_rtl_files/vhier.cmake

This file was deleted.

98 changes: 98 additions & 0 deletions cmake/utils/generate_sources_list/generate_sources_list.cmake
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()
1 change: 0 additions & 1 deletion tests/tests/CMakeLists.txt
Copy link
Copy Markdown
Contributor

@benoitdenkinger benoitdenkinger Mar 23, 2026

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

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ add_custom_target(check_cdash
)

add_subdirectory(iverilog)
add_subdirectory(vhier)
add_subdirectory(peakrdl)

include("getcmaketest.cmake")
Expand Down
Loading
Loading