From 366ab23b391e3bd207b8c0a5fa5cf8c9d91b302b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Tue, 15 Apr 2025 22:37:30 +0200 Subject: [PATCH 01/26] Initial IPXact IP importer implementation --- cmake/ipxact/importer/get_vlnv.xslt | 34 ++++++++++++ cmake/ipxact/importer/ip_lib.xslt | 37 +++++++++++++ .../ip_lib_with_filetype_modifier.xslt | 54 +++++++++++++++++++ .../ipxact/importer/ipxact_ip_importer.cmake | 23 ++++++++ 4 files changed, 148 insertions(+) create mode 100644 cmake/ipxact/importer/get_vlnv.xslt create mode 100644 cmake/ipxact/importer/ip_lib.xslt create mode 100644 cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt create mode 100644 cmake/ipxact/importer/ipxact_ip_importer.cmake diff --git a/cmake/ipxact/importer/get_vlnv.xslt b/cmake/ipxact/importer/get_vlnv.xslt new file mode 100644 index 00000000..42dd98d9 --- /dev/null +++ b/cmake/ipxact/importer/get_vlnv.xslt @@ -0,0 +1,34 @@ + + + + + + + + ; + + + + ; + + + + ; + + + + + + + + + + + + + diff --git a/cmake/ipxact/importer/ip_lib.xslt b/cmake/ipxact/importer/ip_lib.xslt new file mode 100644 index 00000000..1e5b31b5 --- /dev/null +++ b/cmake/ipxact/importer/ip_lib.xslt @@ -0,0 +1,37 @@ + + + + + + + + + add_ip( + + ) + + + + + + ip_sources(${IP} + + + + + + + ${_SOURCE_DIR}/ + + + + ) + + + + + + diff --git a/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt b/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt new file mode 100644 index 00000000..225fe617 --- /dev/null +++ b/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt @@ -0,0 +1,54 @@ + + + + + + + + + + + + add_ip( + + ) + + + + + + ip_sources(${IP} + + + + + + + + + + + + + + + + + + + ${ + + _SOURCE_DIR}/ + + + + + ) + + + + + diff --git a/cmake/ipxact/importer/ipxact_ip_importer.cmake b/cmake/ipxact/importer/ipxact_ip_importer.cmake new file mode 100644 index 00000000..d8fda546 --- /dev/null +++ b/cmake/ipxact/importer/ipxact_ip_importer.cmake @@ -0,0 +1,23 @@ +function(add_ip_from_ipxact COMP_XML) + + execute_process(COMMAND xmlstarlet tr "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/get_vlnv.xslt" ${COMP_XML} + OUTPUT_VARIABLE vlnv_list) + list(GET vlnv_list 0 ip_vendor) + list(GET vlnv_list 1 ip_library) + list(GET vlnv_list 2 ip_name) + list(GET vlnv_list 3 ip_version) + + set(outdir ${CMAKE_BINARY_DIR}/${ip_vendor}__${ip_library}__${ip_name}) + set(output_cmake_file ${outdir}/${ip_name}.cmake) + make_directory(${outdir}) + + execute_process(COMMAND xmlstarlet tr "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ip_lib_with_filetype_modifier.xslt" ${COMP_XML} + OUTPUT_FILE ${output_cmake_file} + ) + + cmake_path(GET COMP_XML PARENT_PATH ${ip_name}_SOURCE_DIR) + + include("${output_cmake_file}") + + set(IP ${IP} PARENT_SCOPE) +endfunction() From e25ce1fb8bbb8881a9d76a05e3b7f91b58204071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Mon, 28 Apr 2025 23:58:15 +0200 Subject: [PATCH 02/26] extract ip_links from IPXact reference types --- cmake/ipxact/importer/get_ip_links.xslt | 60 +++++++++++++++++++ .../ipxact/importer/ipxact_ip_importer.cmake | 8 ++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 cmake/ipxact/importer/get_ip_links.xslt diff --git a/cmake/ipxact/importer/get_ip_links.xslt b/cmake/ipxact/importer/get_ip_links.xslt new file mode 100644 index 00000000..4bc15128 --- /dev/null +++ b/cmake/ipxact/importer/get_ip_links.xslt @@ -0,0 +1,60 @@ + + + + + + + + + + + ip_link(${IP} + + + + + + + + + + + + + + + + + ) + + + + diff --git a/cmake/ipxact/importer/ipxact_ip_importer.cmake b/cmake/ipxact/importer/ipxact_ip_importer.cmake index d8fda546..7ad9d8e8 100644 --- a/cmake/ipxact/importer/ipxact_ip_importer.cmake +++ b/cmake/ipxact/importer/ipxact_ip_importer.cmake @@ -12,9 +12,15 @@ function(add_ip_from_ipxact COMP_XML) make_directory(${outdir}) execute_process(COMMAND xmlstarlet tr "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ip_lib_with_filetype_modifier.xslt" ${COMP_XML} - OUTPUT_FILE ${output_cmake_file} + OUTPUT_VARIABLE file_lists ) + execute_process(COMMAND xmlstarlet tr "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/get_ip_links.xslt" ${COMP_XML} + OUTPUT_VARIABLE ip_links + ) + + write_file(${output_cmake_file} ${file_lists} ${ip_links}) + cmake_path(GET COMP_XML PARENT_PATH ${ip_name}_SOURCE_DIR) include("${output_cmake_file}") From 53af809bacb5ea52fc482f541e4bba7073356ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Tue, 29 Apr 2025 23:04:20 +0200 Subject: [PATCH 03/26] fix ipxact_importer stylesheets --- cmake/ipxact/importer/get_vlnv.xslt | 9 +++++---- .../importer/ip_lib_with_filetype_modifier.xslt | 10 ++++------ cmake/ipxact/importer/ipxact_ip_importer.cmake | 14 +++++++++----- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/cmake/ipxact/importer/get_vlnv.xslt b/cmake/ipxact/importer/get_vlnv.xslt index 42dd98d9..9bb23d23 100644 --- a/cmake/ipxact/importer/get_vlnv.xslt +++ b/cmake/ipxact/importer/get_vlnv.xslt @@ -8,21 +8,22 @@ - + ; - + ; - + ; - + + diff --git a/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt b/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt index 225fe617..7940a838 100644 --- a/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt +++ b/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt @@ -13,12 +13,12 @@ add_ip( - - ) + + NO_ALIAS) - + ip_sources(${IP} @@ -39,9 +39,7 @@ - ${ - - _SOURCE_DIR}/ + ${CMAKE_CURRENT_LIST_DIR}/ diff --git a/cmake/ipxact/importer/ipxact_ip_importer.cmake b/cmake/ipxact/importer/ipxact_ip_importer.cmake index 7ad9d8e8..94dc32b8 100644 --- a/cmake/ipxact/importer/ipxact_ip_importer.cmake +++ b/cmake/ipxact/importer/ipxact_ip_importer.cmake @@ -1,4 +1,11 @@ function(add_ip_from_ipxact COMP_XML) + cmake_parse_arguments(ARG "" "" "" ${ARGN}) + if(ARG_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") + endif() + + cmake_path(GET COMP_XML PARENT_PATH ip_source_dir) + cmake_path(GET COMP_XML FILENAME file_name) execute_process(COMMAND xmlstarlet tr "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/get_vlnv.xslt" ${COMP_XML} OUTPUT_VARIABLE vlnv_list) @@ -7,9 +14,7 @@ function(add_ip_from_ipxact COMP_XML) list(GET vlnv_list 2 ip_name) list(GET vlnv_list 3 ip_version) - set(outdir ${CMAKE_BINARY_DIR}/${ip_vendor}__${ip_library}__${ip_name}) - set(output_cmake_file ${outdir}/${ip_name}.cmake) - make_directory(${outdir}) + set(output_cmake_file ${ip_source_dir}/${ip_vendor}_${ip_library}_${ip_name}_${ip_version}.cmake) execute_process(COMMAND xmlstarlet tr "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ip_lib_with_filetype_modifier.xslt" ${COMP_XML} OUTPUT_VARIABLE file_lists @@ -19,10 +24,9 @@ function(add_ip_from_ipxact COMP_XML) OUTPUT_VARIABLE ip_links ) + set(file_lists "${file_lists}\nip_sources(\${IP} IPXACT\n \${CMAKE_CURRENT_LIST_DIR}/${file_name})\n\n") write_file(${output_cmake_file} ${file_lists} ${ip_links}) - cmake_path(GET COMP_XML PARENT_PATH ${ip_name}_SOURCE_DIR) - include("${output_cmake_file}") set(IP ${IP} PARENT_SCOPE) From 12f649ed0372bc5296f449e5046beaf73ddc8a31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Tue, 29 Apr 2025 23:05:02 +0200 Subject: [PATCH 04/26] Introduce NO_ALIAS argument to add_ip, if passed, it will not create a alias target without version --- cmake/hwip.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index 2fe88c6d..c44d588a 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -53,7 +53,7 @@ include("${CMAKE_CURRENT_LIST_DIR}//utils/file_paths.cmake") # :type DESCRIPTION: string #]] function(add_ip IP_NAME) - cmake_parse_arguments(ARG "" "VENDOR;LIBRARY;VERSION;DESCRIPTION" "" ${ARGN}) + cmake_parse_arguments(ARG "NO_ALIAS" "VENDOR;LIBRARY;VERSION;DESCRIPTION" "" ${ARGN}) # Vendor and library arguments are expected at the minimum if(ARG_UNPARSED_ARGUMENTS) @@ -81,7 +81,7 @@ function(add_ip IP_NAME) endif() # TODO Maybe delete short name without version - if(ARG_VERSION) + if(ARG_VERSION AND NOT ARG_NO_ALIAS) create_ip_vlnv(IP_LIB_SHORT ${IP_NAME} VENDOR "${ARG_VENDOR}" LIBRARY "${ARG_LIBRARY}" VERSION "") string(REPLACE "__" "::" ALIAS_NAME_SHORT "${IP_LIB_SHORT}") if(NOT "${IP_LIB}" STREQUAL "${ALIAS_NAME_SHORT}") From ad08e8fa5f4055ac9aef12c8bac76dcaca5a54e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Tue, 29 Apr 2025 23:06:26 +0200 Subject: [PATCH 05/26] Add SOCMAKE_ALLOW_UNDEFINED_TARGETS global variable, if set it allows linking to IP libraries that were not yet defined --- cmake/hwip.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index c44d588a..8fdd6077 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -625,7 +625,7 @@ function(ip_link IP_LIB) __ip_link_check_version(lib ${lib}) # Issue an error if the library does not exist - if(NOT TARGET ${lib}) + if(NOT TARGET ${lib} AND NOT SOCMAKE_ALLOW_UNDEFINED_TARGETS) message(FATAL_ERROR "Library ${lib} linked to ${_reallib} is not defined") endif() # In case user tries to link library to itself, raise an error From 272ee2511134596faf64e3cb1ca18a46cf98c018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Wed, 30 Apr 2025 08:46:20 +0200 Subject: [PATCH 06/26] Update SoCMakeConfig.cmake --- SoCMakeConfig.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SoCMakeConfig.cmake b/SoCMakeConfig.cmake index 9efc58f3..e4b741fe 100644 --- a/SoCMakeConfig.cmake +++ b/SoCMakeConfig.cmake @@ -118,3 +118,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/cmake/riscv/sail/sail_install.cmake") # ==================================== include("${CMAKE_CURRENT_LIST_DIR}/cmake/build_scripts/systemc/systemc_build.cmake") include("${CMAKE_CURRENT_LIST_DIR}/cmake/build_scripts/uvm-systemc/uvm-systemc_build.cmake") + +# ==================================== +# ====== IPXact ====================== +# ==================================== +include("${CMAKE_CURRENT_LIST_DIR}/cmake/ipxact/importer/ipxact_ip_importer.cmake") From 25d5a14f29a9074c10ded56f74774f6c9318e531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Wed, 30 Apr 2025 10:54:34 +0200 Subject: [PATCH 07/26] If xmlstarlet not available use xsltproc --- cmake/ipxact/importer/ipxact_ip_importer.cmake | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cmake/ipxact/importer/ipxact_ip_importer.cmake b/cmake/ipxact/importer/ipxact_ip_importer.cmake index 94dc32b8..c3fc3ffb 100644 --- a/cmake/ipxact/importer/ipxact_ip_importer.cmake +++ b/cmake/ipxact/importer/ipxact_ip_importer.cmake @@ -3,11 +3,18 @@ function(add_ip_from_ipxact COMP_XML) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() + + find_program(xml_tool xmlstarlet) + set(xml_command ${xml_tool} tr) + if(NOT xml_tool) + find_program(xml_tool xsltproc REQUIRED) + set(xml_command ${xml_tool}) + endif() cmake_path(GET COMP_XML PARENT_PATH ip_source_dir) cmake_path(GET COMP_XML FILENAME file_name) - execute_process(COMMAND xmlstarlet tr "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/get_vlnv.xslt" ${COMP_XML} + execute_process(COMMAND ${xml_command} "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/get_vlnv.xslt" ${COMP_XML} OUTPUT_VARIABLE vlnv_list) list(GET vlnv_list 0 ip_vendor) list(GET vlnv_list 1 ip_library) @@ -16,11 +23,11 @@ function(add_ip_from_ipxact COMP_XML) set(output_cmake_file ${ip_source_dir}/${ip_vendor}_${ip_library}_${ip_name}_${ip_version}.cmake) - execute_process(COMMAND xmlstarlet tr "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ip_lib_with_filetype_modifier.xslt" ${COMP_XML} + execute_process(COMMAND ${xml_command} "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ip_lib_with_filetype_modifier.xslt" ${COMP_XML} OUTPUT_VARIABLE file_lists ) - execute_process(COMMAND xmlstarlet tr "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/get_ip_links.xslt" ${COMP_XML} + execute_process(COMMAND ${xml_command} "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/get_ip_links.xslt" ${COMP_XML} OUTPUT_VARIABLE ip_links ) From 108c15bb57eccfab43b56175bb022132cf4aa58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Wed, 30 Apr 2025 11:03:42 +0200 Subject: [PATCH 08/26] fix xsltproc fallback --- cmake/ipxact/importer/ipxact_ip_importer.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/ipxact/importer/ipxact_ip_importer.cmake b/cmake/ipxact/importer/ipxact_ip_importer.cmake index c3fc3ffb..1e0407e4 100644 --- a/cmake/ipxact/importer/ipxact_ip_importer.cmake +++ b/cmake/ipxact/importer/ipxact_ip_importer.cmake @@ -4,11 +4,11 @@ function(add_ip_from_ipxact COMP_XML) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() - find_program(xml_tool xmlstarlet) - set(xml_command ${xml_tool} tr) - if(NOT xml_tool) - find_program(xml_tool xsltproc REQUIRED) - set(xml_command ${xml_tool}) + find_program(xmlstarlet_EXECUTABLE xmlstarlet) + set(xml_command ${xmlstarlet_EXECUTABLE} tr) + if(NOT xmlstarlet_EXECUTABLE) + find_program(xsltproc_EXECUTABLE xsltproc REQUIRED) + set(xml_command ${xsltproc_EXECUTABLE}) endif() cmake_path(GET COMP_XML PARENT_PATH ip_source_dir) From 0ae73caca755b534f6cbdabf9c6e705738e62bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Mon, 2 Jun 2025 21:43:50 +0200 Subject: [PATCH 09/26] Use file sets for ipxact importer --- cmake/ipxact/importer/ip_lib.xslt | 37 ------ .../ip_lib_with_filetype_modifier.xslt | 112 ++++++++++++------ .../ipxact/importer/ipxact_ip_importer.cmake | 5 +- 3 files changed, 80 insertions(+), 74 deletions(-) delete mode 100644 cmake/ipxact/importer/ip_lib.xslt diff --git a/cmake/ipxact/importer/ip_lib.xslt b/cmake/ipxact/importer/ip_lib.xslt deleted file mode 100644 index 1e5b31b5..00000000 --- a/cmake/ipxact/importer/ip_lib.xslt +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - add_ip( - - ) - - - - - - ip_sources(${IP} - - - - - - - ${_SOURCE_DIR}/ - - - - ) - - - - - - diff --git a/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt b/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt index 7940a838..72cd8678 100644 --- a/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt +++ b/cmake/ipxact/importer/ip_lib_with_filetype_modifier.xslt @@ -6,47 +6,89 @@ - - + + - - - - add_ip( - - NO_ALIAS) - - - - - - ip_sources(${IP} - - - + + + + + + + + + + + + ip_sources(${IP} + - - - - - - + + + + + + - - - - - - - - ${CMAKE_CURRENT_LIST_DIR}/ + + + + + FILE_SET + + + HEADERS + + + + ${CMAKE_CURRENT_LIST_DIR}/ - - - ) - + + ) + + + + + add_ip( + + NO_ALIAS) + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cmake/ipxact/importer/ipxact_ip_importer.cmake b/cmake/ipxact/importer/ipxact_ip_importer.cmake index 1e0407e4..58484e8c 100644 --- a/cmake/ipxact/importer/ipxact_ip_importer.cmake +++ b/cmake/ipxact/importer/ipxact_ip_importer.cmake @@ -5,8 +5,9 @@ function(add_ip_from_ipxact COMP_XML) endif() find_program(xmlstarlet_EXECUTABLE xmlstarlet) - set(xml_command ${xmlstarlet_EXECUTABLE} tr) - if(NOT xmlstarlet_EXECUTABLE) + if(xmlstarlet_EXECUTABLE) + set(xml_command ${xmlstarlet_EXECUTABLE} tr) + else() find_program(xsltproc_EXECUTABLE xsltproc REQUIRED) set(xml_command ${xsltproc_EXECUTABLE}) endif() From 5e4770e2dd5dca7382c08ca70a6647c4cb83b4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Mon, 2 Jun 2025 21:57:25 +0200 Subject: [PATCH 10/26] rebase for file sets --- cmake/hwip.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index 8fdd6077..c59d60d6 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -871,6 +871,7 @@ function(get_socmake_languages OUTVAR) VERILOG VERILOG_SIM VERILOG_FPGA VHDL VHDL_SIM VHDL_FPGA SYSTEMRDL SYSTEMRDL_SOCGEN + IPXACT VERILATOR_CFG ${SOCMAKE_ADDITIONAL_LANGUAGES} ${additional_languages}) From 9723ec6e2d36d8699fabf7a0db4ffbe162f5f7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Mon, 2 Jun 2025 23:09:52 +0200 Subject: [PATCH 11/26] Add HEADER parent directory to ip include directories --- cmake/hwip.cmake | 8 ++++ .../socmake_tests_file_sets_1.0.cmake | 41 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/tests/ipxact/importer/socmake_tests_file_sets_1.0.cmake diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index c59d60d6..f0d679a9 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -236,6 +236,10 @@ endfunction() # :type IP_LIB: string # :param TYPE: The type of source file(s). # :type TYPE: string +# :param FILE_SET: Specify to which file set to associate the listed files +# :type FILE_SET: string +# :param HEADERS: List of header files. Header files are stored in separate property ${LANGUAGE}_HEADERS, the include directory will also be set. +# :type HEADERS: list # # **Keyword Arguments** # @@ -302,6 +306,10 @@ function(ip_sources IP_LIB LANGUAGE) set_property(TARGET ${_reallib} PROPERTY ${sources_property} ${_sources}) # set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${sources_property}) # TODO don't add if already there if(ARG_HEADERS) + foreach(header ${_headers}) + cmake_path(GET header PARENT_PATH header_incdir) + ip_include_directories(${IP_LIB} ${LANGUAGE} ${header_incdir}) + endforeach() set_property(TARGET ${_reallib} PROPERTY ${headers_property} ${_headers}) # set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${headers_property}) # TODO don't add if already there endif() diff --git a/tests/tests/ipxact/importer/socmake_tests_file_sets_1.0.cmake b/tests/tests/ipxact/importer/socmake_tests_file_sets_1.0.cmake new file mode 100644 index 00000000..3657558f --- /dev/null +++ b/tests/tests/ipxact/importer/socmake_tests_file_sets_1.0.cmake @@ -0,0 +1,41 @@ +add_ip(socmake::tests::file_sets::1.0 NO_ALIAS) + +ip_sources(${IP} VERILOG FILE_SET rtl_files + ${CMAKE_CURRENT_LIST_DIR}/i2c_top.v + ${CMAKE_CURRENT_LIST_DIR}/i2c_rx.v + ${CMAKE_CURRENT_LIST_DIR}/i2c_tx.v +) + +ip_sources(${IP} VHDL FILE_SET rtl_files + ${CMAKE_CURRENT_LIST_DIR}/fifo.vhd +) + +ip_sources(${IP} VERILOG FILE_SET rtl_files HEADERS + ${CMAKE_CURRENT_LIST_DIR}/i2c_defs.vh + ${CMAKE_CURRENT_LIST_DIR}/apb_defs.vh +) + +ip_sources(${IP} SYSTEMVERILOG FILE_SET simulation + ${CMAKE_CURRENT_LIST_DIR}/i2c_tb.sv + ${CMAKE_CURRENT_LIST_DIR}/clk_gen.sv +) + +ip_sources(${IP} SYSTEMVERILOG FILE_SET simulation HEADERS + ${CMAKE_CURRENT_LIST_DIR}/i2c_tb_defs.svh +) + +ip_sources(${IP} VERILOG FILE_SET synthesis + ${CMAKE_CURRENT_LIST_DIR}/i2c_cells.v +) + +ip_sources(${IP} SYSTEMVERILOG FILE_SET synthesis + ${CMAKE_CURRENT_LIST_DIR}/clk_gate.sv +) + + +ip_sources(${IP} IPXACT + ${CMAKE_CURRENT_LIST_DIR}/file_sets.xml) + +ip_link(${IP} +) + From 17a9af36ee7dd792d6970029d24abb828ddf9e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Mon, 2 Jun 2025 23:10:11 +0200 Subject: [PATCH 12/26] IPXact file set test --- tests/tests/CMakeLists.txt | 1 + tests/tests/ipxact/importer/file_sets.xml | 71 +++++++++++++++++++ .../tests/ipxact/importer/ipxact_import.cmake | 46 ++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 tests/tests/ipxact/importer/file_sets.xml create mode 100644 tests/tests/ipxact/importer/ipxact_import.cmake diff --git a/tests/tests/CMakeLists.txt b/tests/tests/CMakeLists.txt index 2dd24372..789e1adb 100644 --- a/tests/tests/CMakeLists.txt +++ b/tests/tests/CMakeLists.txt @@ -27,3 +27,4 @@ ct_add_dir(alias_dereference USE_REL_PATH_NAMES LABEL) ct_add_dir(check_languages USE_REL_PATH_NAMES LABEL) ct_add_dir(ip_sources USE_REL_PATH_NAMES LABEL) ct_add_dir(ip_link USE_REL_PATH_NAMES LABEL) +ct_add_dir(ipxact USE_REL_PATH_NAMES LABEL) diff --git a/tests/tests/ipxact/importer/file_sets.xml b/tests/tests/ipxact/importer/file_sets.xml new file mode 100644 index 00000000..e075e484 --- /dev/null +++ b/tests/tests/ipxact/importer/file_sets.xml @@ -0,0 +1,71 @@ + + + socmake + tests + file_sets + 1.0 + + + rtl_files + + i2c_top.v + verilogSource + + + i2c_rx.v + verilogSource + + + i2c_tx.v + verilogSource + + + fifo.vhd + vhdlSource + + + i2c_defs.vh + verilogSource + true + + + apb_defs.vh + verilogSource + true + + + + + simulation + + i2c_tb.sv + systemVerilogSource + + + clk_gen.sv + systemVerilogSource + + + i2c_tb_defs.svh + systemVerilogSource + true + + + + + synthesis + + i2c_cells.v + verilogSource + + + clk_gate.sv + systemVerilogSource + + + + + + diff --git a/tests/tests/ipxact/importer/ipxact_import.cmake b/tests/tests/ipxact/importer/ipxact_import.cmake new file mode 100644 index 00000000..86d04d5d --- /dev/null +++ b/tests/tests/ipxact/importer/ipxact_import.cmake @@ -0,0 +1,46 @@ +include("${CMAKE_CURRENT_LIST_DIR}/../../../../CMakeLists.txt") + +set(TEST_NAME ipxact_import) +set(CDIR ${CMAKE_CURRENT_LIST_DIR}) + +ct_add_test(NAME ${TEST_NAME}) +function(${${TEST_NAME}}) + add_ip_from_ipxact(${CDIR}/file_sets.xml) + + ct_assert_target_exists(socmake::tests::file_sets::1.0) + ct_assert_target_exists(socmake__tests__file_sets__1.0) + + get_ip_sources(sources ${IP} VERILOG) + ct_assert_equal(sources "${CDIR}/i2c_top.v;${CDIR}/i2c_rx.v;${CDIR}/i2c_tx.v;${CDIR}/i2c_cells.v") + + get_ip_sources(sources ${IP} VHDL) + ct_assert_equal(sources "${CDIR}/fifo.vhd") + + get_ip_sources(sources ${IP} SYSTEMVERILOG) + ct_assert_equal(sources "${CDIR}/i2c_tb.sv;${CDIR}/clk_gen.sv;${CDIR}/clk_gate.sv") + + get_ip_sources(sources ${IP} VERILOG FILE_SETS rtl_files) + ct_assert_equal(sources "${CDIR}/i2c_top.v;${CDIR}/i2c_rx.v;${CDIR}/i2c_tx.v") + + get_ip_sources(sources ${IP} VERILOG FILE_SETS synthesis) + ct_assert_equal(sources "${CDIR}/i2c_cells.v") + + get_ip_sources(sources ${IP} SYSTEMVERILOG FILE_SETS simulation) + ct_assert_equal(sources "${CDIR}/i2c_tb.sv;${CDIR}/clk_gen.sv") + + get_ip_sources(sources ${IP} SYSTEMVERILOG HEADERS FILE_SETS simulation) + ct_assert_equal(sources "${CDIR}/i2c_tb_defs.svh") + + get_ip_sources(sources ${IP} VERILOG HEADERS FILE_SETS rtl_files) + ct_assert_equal(sources "${CDIR}/i2c_defs.vh;${CDIR}/apb_defs.vh") + + get_ip_sources(sources ${IP} VERILOG SYSTEMVERILOG HEADERS FILE_SETS rtl_files simulation) + ct_assert_equal(sources "${CDIR}/i2c_defs.vh;${CDIR}/apb_defs.vh;${CDIR}/i2c_tb_defs.svh") + + get_ip_include_directories(incdirs ${IP} VERILOG) + ct_assert_equal(incdirs "${CDIR}") + + get_ip_include_directories(incdirs ${IP} SYSTEMVERILOG) + ct_assert_equal(incdirs "${CDIR}") + +endfunction() From fd904b82bbccf26fabbee413d51deaf382932bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Mon, 2 Jun 2025 23:12:29 +0200 Subject: [PATCH 13/26] remove the ipxact cmake file from the test directory to avoid detection by CMakeTest --- tests/tests/ipxact/importer/ipxact_import.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/tests/ipxact/importer/ipxact_import.cmake b/tests/tests/ipxact/importer/ipxact_import.cmake index 86d04d5d..23a5cd82 100644 --- a/tests/tests/ipxact/importer/ipxact_import.cmake +++ b/tests/tests/ipxact/importer/ipxact_import.cmake @@ -43,4 +43,5 @@ function(${${TEST_NAME}}) get_ip_include_directories(incdirs ${IP} SYSTEMVERILOG) ct_assert_equal(incdirs "${CDIR}") + file(REMOVE "${CDIR}/socmake_tests_file_sets_1.0.cmake") endfunction() From e6d152992c1ebe4b059bdb0e2e4f185bd11d4fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Mon, 2 Jun 2025 23:14:42 +0200 Subject: [PATCH 14/26] Install xslptroc in CI --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 178f1061..1c745618 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: | - sudo apt-get install cmake sudo iverilog make g++ perl cpanminus + sudo apt-get install cmake sudo iverilog make g++ perl cpanminus xsltproc # Install Verilog::Perl from GitHub git clone https://github.com/Veripool/Verilog-Perl.git From b54cd4a02533ae819295e94216410a163686dc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Tue, 24 Jun 2025 00:51:29 +0200 Subject: [PATCH 15/26] Fix the failing test --- .../socmake_tests_file_sets_1.0.cmake | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 tests/tests/ipxact/importer/socmake_tests_file_sets_1.0.cmake diff --git a/tests/tests/ipxact/importer/socmake_tests_file_sets_1.0.cmake b/tests/tests/ipxact/importer/socmake_tests_file_sets_1.0.cmake deleted file mode 100644 index 3657558f..00000000 --- a/tests/tests/ipxact/importer/socmake_tests_file_sets_1.0.cmake +++ /dev/null @@ -1,41 +0,0 @@ -add_ip(socmake::tests::file_sets::1.0 NO_ALIAS) - -ip_sources(${IP} VERILOG FILE_SET rtl_files - ${CMAKE_CURRENT_LIST_DIR}/i2c_top.v - ${CMAKE_CURRENT_LIST_DIR}/i2c_rx.v - ${CMAKE_CURRENT_LIST_DIR}/i2c_tx.v -) - -ip_sources(${IP} VHDL FILE_SET rtl_files - ${CMAKE_CURRENT_LIST_DIR}/fifo.vhd -) - -ip_sources(${IP} VERILOG FILE_SET rtl_files HEADERS - ${CMAKE_CURRENT_LIST_DIR}/i2c_defs.vh - ${CMAKE_CURRENT_LIST_DIR}/apb_defs.vh -) - -ip_sources(${IP} SYSTEMVERILOG FILE_SET simulation - ${CMAKE_CURRENT_LIST_DIR}/i2c_tb.sv - ${CMAKE_CURRENT_LIST_DIR}/clk_gen.sv -) - -ip_sources(${IP} SYSTEMVERILOG FILE_SET simulation HEADERS - ${CMAKE_CURRENT_LIST_DIR}/i2c_tb_defs.svh -) - -ip_sources(${IP} VERILOG FILE_SET synthesis - ${CMAKE_CURRENT_LIST_DIR}/i2c_cells.v -) - -ip_sources(${IP} SYSTEMVERILOG FILE_SET synthesis - ${CMAKE_CURRENT_LIST_DIR}/clk_gate.sv -) - - -ip_sources(${IP} IPXACT - ${CMAKE_CURRENT_LIST_DIR}/file_sets.xml) - -ip_link(${IP} -) - From 3db6d9b99969b63030ade138a39fa8fda9675725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Wed, 26 Mar 2025 23:43:39 +0100 Subject: [PATCH 16/26] Initial support for installing IP blocks #121 --- SoCMakeConfig.cmake | 1 + cmake/hwip.cmake | 13 ++- cmake/utils/file_paths.cmake | 10 ++- cmake/utils/get_all_targets.cmake | 5 +- cmake/utils/install/install.cmake | 79 +++++++++++++++++++ cmake/utils/install/ipConfig.cmake.in | 15 ++++ .../install/simple_verilog/CMakeLists.txt | 19 +++++ examples/install/simple_verilog/adder/adder.v | 9 +++ .../install/simple_verilog/tb/CMakeLists.txt | 19 +++++ examples/install/simple_verilog/tb/tb.v | 23 ++++++ 10 files changed, 184 insertions(+), 9 deletions(-) create mode 100644 cmake/utils/install/install.cmake create mode 100644 cmake/utils/install/ipConfig.cmake.in create mode 100644 examples/install/simple_verilog/CMakeLists.txt create mode 100644 examples/install/simple_verilog/adder/adder.v create mode 100644 examples/install/simple_verilog/tb/CMakeLists.txt create mode 100644 examples/install/simple_verilog/tb/tb.v diff --git a/SoCMakeConfig.cmake b/SoCMakeConfig.cmake index e4b741fe..0777acc8 100644 --- a/SoCMakeConfig.cmake +++ b/SoCMakeConfig.cmake @@ -16,6 +16,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/option.cmake") include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/find_python.cmake") include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/print_list.cmake") include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/uniquify_files_by_basename.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/cmake/utils/install/install.cmake") # ==================================== # ======== Additional utilities ====== diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index f0d679a9..c67d517a 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -92,6 +92,7 @@ function(add_ip IP_NAME) if(ARG_DESCRIPTION) set_property(TARGET ${IP_LIB} PROPERTY DESCRIPTION ${ARG_DESCRIPTION}) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES DESCRIPTION) endif() # Unset the parent variables that might have been set by previous add_ip() call @@ -102,15 +103,19 @@ function(add_ip IP_NAME) if(ARG_VENDOR) set(IP_VENDOR ${ARG_VENDOR} PARENT_SCOPE) set_target_properties(${IP_LIB} PROPERTIES VENDOR ${ARG_VENDOR}) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES VENDOR) endif() if(ARG_LIBRARY) set(IP_LIBRARY ${ARG_LIBRARY} PARENT_SCOPE) set_target_properties(${IP_LIB} PROPERTIES LIBRARY ${ARG_LIBRARY}) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES LIBRARY) endif() set_target_properties(${IP_LIB} PROPERTIES IP_NAME ${IP_NAME}) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES IP_NAME) if(ARG_VERSION) set(IP_VERSION ${ARG_VERSION} PARENT_SCOPE) set_target_properties(${IP_LIB} PROPERTIES VERSION ${ARG_VERSION}) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES VERSION) endif() set(IP_NAME ${IP_NAME} PARENT_SCOPE) @@ -304,14 +309,14 @@ function(ip_sources IP_LIB LANGUAGE) endif() # Set the target property with the new list of source and header files set_property(TARGET ${_reallib} PROPERTY ${sources_property} ${_sources}) - # set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${sources_property}) # TODO don't add if already there + set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${sources_property}) # TODO don't add if already there if(ARG_HEADERS) foreach(header ${_headers}) cmake_path(GET header PARENT_PATH header_incdir) ip_include_directories(${IP_LIB} ${LANGUAGE} ${header_incdir}) endforeach() set_property(TARGET ${_reallib} PROPERTY ${headers_property} ${_headers}) - # set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${headers_property}) # TODO don't add if already there + set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${headers_property}) # TODO don't add if already there endif() endfunction() @@ -428,6 +433,7 @@ function(ip_include_directories IP_LIB LANGUAGE) convert_paths_to_absolute(dir_list ${ARGN}) # Append the new include directories to the exsiting ones set_property(TARGET ${_reallib} APPEND PROPERTY ${incdir_property} ${dir_list}) + set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${incdir_property}) # TODO don't add if already there endfunction() #[[[ @@ -509,7 +515,7 @@ function(check_languages LANGUAGE) # The user can add addition languages using the SOCMAKE_ADDITIONAL_LANGUAGES variable and global property get_socmake_languages(SOCMAKE_SUPPORTED_LANGUAGES) - if(NOT ${LANGUAGE} IN_LIST SOCMAKE_SUPPORTED_LANGUAGES) + if(NOT "${LANGUAGE}" IN_LIST SOCMAKE_SUPPORTED_LANGUAGES) if(SOCMAKE_UNSUPPORTED_LANGUAGE_FATAL) set(_verbosity FATAL_ERROR) else() @@ -737,6 +743,7 @@ function(ip_compile_definitions IP_LIB LANGUAGE) # Append the new compile definitions to the exsiting ones set_property(TARGET ${_reallib} APPEND PROPERTY ${comp_def_property} ${__comp_defs}) + set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${comp_def_property}) # TODO don't add if already there endfunction() diff --git a/cmake/utils/file_paths.cmake b/cmake/utils/file_paths.cmake index bf64087f..05f4a7e6 100644 --- a/cmake/utils/file_paths.cmake +++ b/cmake/utils/file_paths.cmake @@ -11,10 +11,12 @@ function(convert_paths_to_absolute OUTPUT_LIST) unset(output_list) foreach(path ${ARGN}) - cmake_path(ABSOLUTE_PATH path - BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} NORMALIZE - OUTPUT_VARIABLE path - ) + if(NOT "${path}" MATCHES "\\$\{_IMPORT_PREFIX\}") + cmake_path(ABSOLUTE_PATH path + BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} NORMALIZE + OUTPUT_VARIABLE path + ) + endif() list(APPEND output_list ${path} ) endforeach() diff --git a/cmake/utils/get_all_targets.cmake b/cmake/utils/get_all_targets.cmake index bc3fd3a3..74af4dda 100644 --- a/cmake/utils/get_all_targets.cmake +++ b/cmake/utils/get_all_targets.cmake @@ -12,6 +12,7 @@ macro(__get_all_targets_recursive targets dir) __get_all_targets_recursive(${targets} ${subdir}) endforeach() - get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) - list(APPEND ${targets} ${current_targets}) + get_property(current_targets DIRECTORY "${dir}" PROPERTY BUILDSYSTEM_TARGETS) + get_property(imported_targets DIRECTORY "${dir}" PROPERTY IMPORTED_TARGETS) + list(APPEND ${targets} ${current_targets} ${imported_targets}) endmacro() diff --git a/cmake/utils/install/install.cmake b/cmake/utils/install/install.cmake new file mode 100644 index 00000000..ae8366eb --- /dev/null +++ b/cmake/utils/install/install.cmake @@ -0,0 +1,79 @@ +include_guard(GLOBAL) + +function(ip_install IP_LIB) + cmake_parse_arguments(ARG "" "" "" ${ARGN}) + if(ARG_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") + endif() + + + get_property(export_sources TARGET ${IP_LIB} PROPERTY EXPORT_PROPERTIES) + message("export_source: ${export_sources}") + # list(FILTER export_sources INCLUDE REGEX "(_SOURCES|_HEADERS|_INCLUDE_DIRECTORIES)$") + + set(sources_list ${export_sources}) + list(FILTER sources_list INCLUDE REGEX "_SOURCES$") + + set(headers_list ${export_sources}) + list(FILTER headers_list INCLUDE REGEX "_HEADERS$") + + set(inc_dirs_list ${export_sources}) + list(FILTER inc_dirs_list INCLUDE REGEX "_INCLUDE_DIRECTORIES$") + + foreach(fileset ${sources_list}) + string(REGEX REPLACE "_SOURCES$" "" fileset ${fileset}) + # message("fileset is: ${fileset}") + get_ip_sources(${fileset} ${IP_LIB} ${fileset}) + + unset(${fileset}_copy) + foreach(source ${${fileset}}) + cmake_path(GET source FILENAME filename) + list(APPEND ${fileset}_copy "\${_IMPORT_PREFIX}/${fileset}/${filename}") + endforeach() + + ip_sources(${IP_LIB} ${fileset} REPLACE + ${${fileset}_copy} + ) + + + install(FILES ${${fileset}} + DESTINATION ${fileset} + ) + get_ip_sources(sources ${IP_LIB} ${fileset}) + endforeach() + + get_property(IP_NAME TARGET ${IP_LIB} PROPERTY IP_NAME) + get_property(IP_VERSION TARGET ${IP_LIB} PROPERTY VERSION) + if(NOT IP_VERSION) + set(VERSION 0.0.1) + else() + set(VERSION ${IP_VERSION}) + endif() + + include(CMakePackageConfigHelpers) + write_basic_package_version_file( + "${PROJECT_BINARY_DIR}/${IP_NAME}ConfigVersion.cmake" + VERSION ${VERSION} + COMPATIBILITY AnyNewerVersion + ) + + install(TARGETS ${IP_LIB} + EXPORT ${IP_NAME}Targets + ) + + include(CMakePackageConfigHelpers) + configure_package_config_file( + "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ipConfig.cmake.in" + "${PROJECT_BINARY_DIR}/${IP_NAME}Config.cmake" + INSTALL_DESTINATION lib/cmake/${IP_NAME} + ) + + install(EXPORT ${IP_NAME}Targets + DESTINATION lib/cmake/${IP_NAME}) + + install(FILES "${PROJECT_BINARY_DIR}/${IP_NAME}ConfigVersion.cmake" + "${PROJECT_BINARY_DIR}/${IP_NAME}Config.cmake" + DESTINATION lib/cmake/${IP_NAME} + ) + +endfunction() diff --git a/cmake/utils/install/ipConfig.cmake.in b/cmake/utils/install/ipConfig.cmake.in new file mode 100644 index 00000000..2115014a --- /dev/null +++ b/cmake/utils/install/ipConfig.cmake.in @@ -0,0 +1,15 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/adderTargets.cmake") +check_required_components("@PROJECT_NAME@") + +string(REPLACE "__" "::" IP_ALIAS "@IP_LIB@") +if(NOT "${IP_ALIAS}" STREQUAL "@IP_LIB@") + add_library(${IP_ALIAS} ALIAS @IP_LIB@) +endif() + +if(@IP_VERSION@) + string(REPLACE "__@IP_VERSION@" "" IP_NO_VERSION_ALIAS "@IP_LIB@") + add_library(${IP_NO_VERSION_ALIAS} ALIAS @IP_LIB@) +endif() + diff --git a/examples/install/simple_verilog/CMakeLists.txt b/examples/install/simple_verilog/CMakeLists.txt new file mode 100644 index 00000000..b510b9b4 --- /dev/null +++ b/examples/install/simple_verilog/CMakeLists.txt @@ -0,0 +1,19 @@ +include("../../../SoCMakeConfig.cmake") + +cmake_minimum_required(VERSION 3.25) + +project(adder NONE) + +add_ip(adder + DESCRIPTION "Just a simple adder") + +ip_sources(${IP} VERILOG + ./adder/adder.v + # HEADERS + # ./adder/adder.v + ) + +# ip_include_directories(${IP} VERILOG +# ./adder) + +ip_install(${IP}) diff --git a/examples/install/simple_verilog/adder/adder.v b/examples/install/simple_verilog/adder/adder.v new file mode 100644 index 00000000..6db7abd2 --- /dev/null +++ b/examples/install/simple_verilog/adder/adder.v @@ -0,0 +1,9 @@ +module adder( + input [4:0] NUM1, + input [4:0] NUM2, + output [4:0] SUM + ); + + assign SUM = NUM1 + NUM2; +endmodule + diff --git a/examples/install/simple_verilog/tb/CMakeLists.txt b/examples/install/simple_verilog/tb/CMakeLists.txt new file mode 100644 index 00000000..d703505a --- /dev/null +++ b/examples/install/simple_verilog/tb/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.25) +project(simple_verilog_example NONE) + +include("../../../../SoCMakeConfig.cmake") + +add_ip(tb + DESCRIPTION "Simple verilog testbench") + +ip_sources(${IP} VERILOG + tb.v) + +find_package(adder CONFIG REQUIRED + HINTS ../install + ) +ip_link(${IP} adder) + +modelsim(${IP}) + +help() diff --git a/examples/install/simple_verilog/tb/tb.v b/examples/install/simple_verilog/tb/tb.v new file mode 100644 index 00000000..ca6eea56 --- /dev/null +++ b/examples/install/simple_verilog/tb/tb.v @@ -0,0 +1,23 @@ +module tb; + reg [4:0] a, b; + wire [4:0] o; + + adder adder_i ( + .NUM1(a), + .NUM2(b), + .SUM(o) + ); + + initial begin + a = 5; + b = 10; + #1; + + $display("Hello world, from SoCMake build system\n"); + $display("%d + %d = %d", a, b, o); + $finish(); + end + + + endmodule + From 4ddfb340fc77064e544bf05e790cc89e568f30e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Thu, 26 Jun 2025 00:12:21 +0200 Subject: [PATCH 17/26] Install output directory is vendor/library/name/version --- cmake/utils/install/install.cmake | 39 +++++++++++++------ cmake/utils/install/ipConfig.cmake.in | 3 +- .../install/simple_verilog/CMakeLists.txt | 18 ++++++++- .../install/simple_verilog/tb/CMakeLists.txt | 9 +++-- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/cmake/utils/install/install.cmake b/cmake/utils/install/install.cmake index ae8366eb..44993f30 100644 --- a/cmake/utils/install/install.cmake +++ b/cmake/utils/install/install.cmake @@ -1,5 +1,12 @@ include_guard(GLOBAL) +function(make_outdir_path OUTVAR IP_LIB) + alias_dereference(_reallib ${IP_LIB}) + string(REPLACE "__" "/" outpath "${_reallib}") + + set(${OUTVAR} ${outpath} PARENT_SCOPE) +endfunction() + function(ip_install IP_LIB) cmake_parse_arguments(ARG "" "" "" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) @@ -7,10 +14,13 @@ function(ip_install IP_LIB) endif() + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES FILE_SETS) get_property(export_sources TARGET ${IP_LIB} PROPERTY EXPORT_PROPERTIES) - message("export_source: ${export_sources}") + get_property(filesets TARGET ${IP_LIB} PROPERTY FILE_SETS) # list(FILTER export_sources INCLUDE REGEX "(_SOURCES|_HEADERS|_INCLUDE_DIRECTORIES)$") + make_outdir_path(OUTDIR ${IP_LIB}) + set(sources_list ${export_sources}) list(FILTER sources_list INCLUDE REGEX "_SOURCES$") @@ -20,34 +30,38 @@ function(ip_install IP_LIB) set(inc_dirs_list ${export_sources}) list(FILTER inc_dirs_list INCLUDE REGEX "_INCLUDE_DIRECTORIES$") - foreach(fileset ${sources_list}) - string(REGEX REPLACE "_SOURCES$" "" fileset ${fileset}) + foreach(fileset ${filesets}) + string(REPLACE "::" ";" fileset_list "${fileset}") + list(GET fileset_list 0 fileset_language) + list(GET fileset_list 1 fileset_name) + + # string(REGEX REPLACE "_SOURCES$" "" fileset ${fileset}) # message("fileset is: ${fileset}") - get_ip_sources(${fileset} ${IP_LIB} ${fileset}) + get_ip_sources(${fileset} ${IP_LIB} ${fileset_language} FILE_SETS ${fileset_name}) unset(${fileset}_copy) foreach(source ${${fileset}}) cmake_path(GET source FILENAME filename) - list(APPEND ${fileset}_copy "\${_IMPORT_PREFIX}/${fileset}/${filename}") + list(APPEND ${fileset}_copy "\${_IMPORT_PREFIX}/${OUTDIR}/${fileset_language}/${fileset_name}/${filename}") endforeach() - ip_sources(${IP_LIB} ${fileset} REPLACE + ip_sources(${IP_LIB} ${fileset_language} FILE_SET ${fileset_name} REPLACE ${${fileset}_copy} ) - install(FILES ${${fileset}} - DESTINATION ${fileset} + DESTINATION "${OUTDIR}/${fileset_language}/${fileset_name}" ) - get_ip_sources(sources ${IP_LIB} ${fileset}) endforeach() get_property(IP_NAME TARGET ${IP_LIB} PROPERTY IP_NAME) get_property(IP_VERSION TARGET ${IP_LIB} PROPERTY VERSION) + set(VERSION_USED FALSE) if(NOT IP_VERSION) set(VERSION 0.0.1) else() set(VERSION ${IP_VERSION}) + set(VERSION_USED TRUE) endif() include(CMakePackageConfigHelpers) @@ -65,15 +79,16 @@ function(ip_install IP_LIB) configure_package_config_file( "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ipConfig.cmake.in" "${PROJECT_BINARY_DIR}/${IP_NAME}Config.cmake" - INSTALL_DESTINATION lib/cmake/${IP_NAME} + INSTALL_DESTINATION "${OUTDIR}/lib/cmake/${IP_NAME}" ) install(EXPORT ${IP_NAME}Targets - DESTINATION lib/cmake/${IP_NAME}) + DESTINATION "${OUTDIR}/lib/cmake/${IP_NAME}" + ) install(FILES "${PROJECT_BINARY_DIR}/${IP_NAME}ConfigVersion.cmake" "${PROJECT_BINARY_DIR}/${IP_NAME}Config.cmake" - DESTINATION lib/cmake/${IP_NAME} + DESTINATION "${OUTDIR}/lib/cmake/${IP_NAME}" ) endfunction() diff --git a/cmake/utils/install/ipConfig.cmake.in b/cmake/utils/install/ipConfig.cmake.in index 2115014a..2b6a1c55 100644 --- a/cmake/utils/install/ipConfig.cmake.in +++ b/cmake/utils/install/ipConfig.cmake.in @@ -8,8 +8,9 @@ if(NOT "${IP_ALIAS}" STREQUAL "@IP_LIB@") add_library(${IP_ALIAS} ALIAS @IP_LIB@) endif() -if(@IP_VERSION@) +if(@VERSION_USED@) string(REPLACE "__@IP_VERSION@" "" IP_NO_VERSION_ALIAS "@IP_LIB@") + string(REPLACE "__" "::" IP_NO_VERSION_ALIAS "${IP_NO_VERSION_ALIAS}") add_library(${IP_NO_VERSION_ALIAS} ALIAS @IP_LIB@) endif() diff --git a/examples/install/simple_verilog/CMakeLists.txt b/examples/install/simple_verilog/CMakeLists.txt index b510b9b4..d43d0cd9 100644 --- a/examples/install/simple_verilog/CMakeLists.txt +++ b/examples/install/simple_verilog/CMakeLists.txt @@ -4,7 +4,23 @@ cmake_minimum_required(VERSION 3.25) project(adder NONE) -add_ip(adder +foreach(i RANGE 1 10) + add_ip(vendor::ip::adder::0.0.${i} NO_ALIAS + DESCRIPTION "Just a simple adder") + + ip_sources(${IP} VERILOG + ./adder/adder.v + # HEADERS + # ./adder/adder.v + ) + +# ip_include_directories(${IP} VERILOG +# ./adder) + + ip_install(${IP}) +endforeach() + +add_ip(vendor::ip::mult::0.0.1 NO_ALIAS DESCRIPTION "Just a simple adder") ip_sources(${IP} VERILOG diff --git a/examples/install/simple_verilog/tb/CMakeLists.txt b/examples/install/simple_verilog/tb/CMakeLists.txt index d703505a..46de4fe0 100644 --- a/examples/install/simple_verilog/tb/CMakeLists.txt +++ b/examples/install/simple_verilog/tb/CMakeLists.txt @@ -9,11 +9,12 @@ add_ip(tb ip_sources(${IP} VERILOG tb.v) -find_package(adder CONFIG REQUIRED - HINTS ../install +find_package(adder 0.0.10 CONFIG REQUIRED + HINTS ${PROJECT_SOURCE_DIR}/../build/here/*/*/*/* ) -ip_link(${IP} adder) +ip_link(${IP} vendor::ip::adder) -modelsim(${IP}) + +iverilog(${IP}) help() From 5b46f697cc4d6238f0dfdc4d4cd1bb93feaf928b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Thu, 26 Jun 2025 23:25:28 +0200 Subject: [PATCH 18/26] Fix the get_ip_ function Language and FILE_SETS combination --- cmake/hwip.cmake | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index c67d517a..d9b7584d 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -92,7 +92,6 @@ function(add_ip IP_NAME) if(ARG_DESCRIPTION) set_property(TARGET ${IP_LIB} PROPERTY DESCRIPTION ${ARG_DESCRIPTION}) - set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES DESCRIPTION) endif() # Unset the parent variables that might have been set by previous add_ip() call @@ -103,19 +102,15 @@ function(add_ip IP_NAME) if(ARG_VENDOR) set(IP_VENDOR ${ARG_VENDOR} PARENT_SCOPE) set_target_properties(${IP_LIB} PROPERTIES VENDOR ${ARG_VENDOR}) - set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES VENDOR) endif() if(ARG_LIBRARY) set(IP_LIBRARY ${ARG_LIBRARY} PARENT_SCOPE) set_target_properties(${IP_LIB} PROPERTIES LIBRARY ${ARG_LIBRARY}) - set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES LIBRARY) endif() set_target_properties(${IP_LIB} PROPERTIES IP_NAME ${IP_NAME}) - set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES IP_NAME) if(ARG_VERSION) set(IP_VERSION ${ARG_VERSION} PARENT_SCOPE) set_target_properties(${IP_LIB} PROPERTIES VERSION ${ARG_VERSION}) - set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES VERSION) endif() set(IP_NAME ${IP_NAME} PARENT_SCOPE) @@ -309,14 +304,12 @@ function(ip_sources IP_LIB LANGUAGE) endif() # Set the target property with the new list of source and header files set_property(TARGET ${_reallib} PROPERTY ${sources_property} ${_sources}) - set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${sources_property}) # TODO don't add if already there if(ARG_HEADERS) foreach(header ${_headers}) cmake_path(GET header PARENT_PATH header_incdir) ip_include_directories(${IP_LIB} ${LANGUAGE} ${header_incdir}) endforeach() set_property(TARGET ${_reallib} PROPERTY ${headers_property} ${_headers}) - set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${headers_property}) # TODO don't add if already there endif() endfunction() @@ -364,12 +357,14 @@ function(get_ip_sources OUTVAR IP_LIB LANGUAGE) if(NOT ARG_FILE_SETS) set(filesets ${ip_filesets}) else() + list(REMOVE_ITEM ARGN ${ARG_FILE_SETS}) + list(REMOVE_ITEM ARGN "FILE_SETS") unset(filesets) - foreach(fileset ${ARG_FILE_SETS}) - list(APPEND filesets "${LANGUAGE}::${fileset}") - list(REMOVE_ITEM ARGN "${fileset}") + foreach(lang ${LANGUAGE} ${ARGN}) + foreach(fileset_name ${ARG_FILE_SETS}) + list(APPEND filesets ${lang}::${fileset_name}) + endforeach() endforeach() - list(REMOVE_ITEM ARGN "FILE_SETS") endif() unset(SOURCES) @@ -433,7 +428,6 @@ function(ip_include_directories IP_LIB LANGUAGE) convert_paths_to_absolute(dir_list ${ARGN}) # Append the new include directories to the exsiting ones set_property(TARGET ${_reallib} APPEND PROPERTY ${incdir_property} ${dir_list}) - set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${incdir_property}) # TODO don't add if already there endfunction() #[[[ @@ -463,17 +457,19 @@ function(get_ip_include_directories OUTVAR IP_LIB LANGUAGE) alias_dereference(_reallib ${IP_LIB}) # In case FILE_SETS function argument is not specified, return all defined file sets - # Otherwise return only directories in listed file sets + # Otherwise return only files in listed file sets get_ip_property(ip_filesets ${_reallib} FILE_SETS ${_no_deps}) if(NOT ARG_FILE_SETS) set(filesets ${ip_filesets}) else() + list(REMOVE_ITEM ARGN ${ARG_FILE_SETS}) + list(REMOVE_ITEM ARGN "FILE_SETS") unset(filesets) - foreach(fileset ${ARG_FILE_SETS}) - list(APPEND filesets "${LANGUAGE}::${fileset}") - list(REMOVE_ITEM ARGN "${fileset}") + foreach(lang ${LANGUAGE} ${ARGN}) + foreach(fileset_name ${ARG_FILE_SETS}) + list(APPEND filesets ${lang}::${fileset_name}) + endforeach() endforeach() - list(REMOVE_ITEM ARGN "FILE_SETS") endif() # ARGN contains extra languages passed, it might also include NO_DEPS so remove it from the list @@ -743,7 +739,6 @@ function(ip_compile_definitions IP_LIB LANGUAGE) # Append the new compile definitions to the exsiting ones set_property(TARGET ${_reallib} APPEND PROPERTY ${comp_def_property} ${__comp_defs}) - set_property(TARGET ${_reallib} APPEND PROPERTY EXPORT_PROPERTIES ${comp_def_property}) # TODO don't add if already there endfunction() @@ -775,17 +770,19 @@ function(get_ip_compile_definitions OUTVAR IP_LIB LANGUAGE) alias_dereference(_reallib ${IP_LIB}) # In case FILE_SETS function argument is not specified, return all defined file sets - # Otherwise return only directories in listed file sets + # Otherwise return only files in listed file sets get_ip_property(ip_filesets ${_reallib} FILE_SETS ${_no_deps}) if(NOT ARG_FILE_SETS) set(filesets ${ip_filesets}) else() + list(REMOVE_ITEM ARGN ${ARG_FILE_SETS}) + list(REMOVE_ITEM ARGN "FILE_SETS") unset(filesets) - foreach(fileset ${ARG_FILE_SETS}) - list(APPEND filesets "${LANGUAGE}::${fileset}") - list(REMOVE_ITEM ARGN "${fileset}") + foreach(lang ${LANGUAGE} ${ARGN}) + foreach(fileset_name ${ARG_FILE_SETS}) + list(APPEND filesets ${lang}::${fileset_name}) + endforeach() endforeach() - list(REMOVE_ITEM ARGN "FILE_SETS") endif() # ARGN contains extra languages passed, it might also include NO_DEPS so remove it from the list From 98ab12c256df10a6bb6b31aeb2c7bcd7890c79aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Thu, 26 Jun 2025 23:25:39 +0200 Subject: [PATCH 19/26] Mark exported properties in install.cmake --- cmake/utils/install/install.cmake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmake/utils/install/install.cmake b/cmake/utils/install/install.cmake index 44993f30..76cd0394 100644 --- a/cmake/utils/install/install.cmake +++ b/cmake/utils/install/install.cmake @@ -8,11 +8,17 @@ function(make_outdir_path OUTVAR IP_LIB) endfunction() function(ip_install IP_LIB) - cmake_parse_arguments(ARG "" "" "" ${ARGN}) + cmake_parse_arguments(ARG "" "" "FILE_SETS;EXCLUDE_FILE_SETS" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() + # Set properties to export + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES DESCRIPTION) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES VENDOR) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES LIBRARY) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES IP_NAME) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES VERSION) set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES FILE_SETS) get_property(export_sources TARGET ${IP_LIB} PROPERTY EXPORT_PROPERTIES) @@ -35,6 +41,11 @@ function(ip_install IP_LIB) list(GET fileset_list 0 fileset_language) list(GET fileset_list 1 fileset_name) + set(fileset_property ${fileset_language}_${fileset_name}) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES ${fileset_property}_SOURCES) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES ${fileset_property}_HEADERS) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES ${fileset_property}_INCLUDE_DIRECTORIES) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES ${fileset_property}_COMPILE_DEFINITIONS) # string(REGEX REPLACE "_SOURCES$" "" fileset ${fileset}) # message("fileset is: ${fileset}") get_ip_sources(${fileset} ${IP_LIB} ${fileset_language} FILE_SETS ${fileset_name}) From d0147fb785c7e35bd93d817f8e504fa77011af3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Thu, 26 Jun 2025 23:36:31 +0200 Subject: [PATCH 20/26] Rename FILE_SETS property to LANG_FILE_SETS or correctness --- cmake/hwip.cmake | 22 +++++++++++----------- cmake/utils/install/install.cmake | 10 +++++++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/cmake/hwip.cmake b/cmake/hwip.cmake index d9b7584d..3001efcc 100644 --- a/cmake/hwip.cmake +++ b/cmake/hwip.cmake @@ -269,10 +269,10 @@ function(ip_sources IP_LIB LANGUAGE) set(headers_property ${LANGUAGE}_${ARG_FILE_SET}_HEADERS) set(get_sources_fileset_arg FILE_SETS ${ARG_FILE_SET}) - get_property(filesets TARGET ${_reallib} PROPERTY FILE_SETS) + get_property(filesets TARGET ${_reallib} PROPERTY LANG_FILE_SETS) set(file_set "${LANGUAGE}::${ARG_FILE_SET}") if(NOT file_set IN_LIST filesets) - set_property(TARGET ${_reallib} APPEND PROPERTY FILE_SETS ${file_set}) + set_property(TARGET ${_reallib} APPEND PROPERTY LANG_FILE_SETS ${file_set}) endif() list(REMOVE_ITEM ARGN "${ARG_FILE_SET}") @@ -353,7 +353,7 @@ function(get_ip_sources OUTVAR IP_LIB LANGUAGE) # In case FILE_SETS function argument is not specified, return all defined file sets # Otherwise return only files in listed file sets - get_ip_property(ip_filesets ${_reallib} FILE_SETS ${_no_deps}) + get_ip_property(ip_filesets ${_reallib} LANG_FILE_SETS ${_no_deps}) if(NOT ARG_FILE_SETS) set(filesets ${ip_filesets}) else() @@ -415,11 +415,11 @@ function(ip_include_directories IP_LIB LANGUAGE) endif() set(incdir_property ${LANGUAGE}_${ARG_FILE_SET}_INCLUDE_DIRECTORIES) - # Add the file set to the FILE_SETS property - get_property(filesets TARGET ${_reallib} PROPERTY FILE_SETS) + # Add the file set to the LANG_FILE_SETS property + get_property(filesets TARGET ${_reallib} PROPERTY LANG_FILE_SETS) set(file_set "${LANGUAGE}::${ARG_FILE_SET}") if(NOT file_set IN_LIST filesets) - set_property(TARGET ${_reallib} APPEND PROPERTY FILE_SETS ${file_set}) + set_property(TARGET ${_reallib} APPEND PROPERTY LANG_FILE_SETS ${file_set}) endif() # Remove the FILE_SET argument and its value from ARGN to not interfere with directory list list(REMOVE_ITEM ARGN "${ARG_FILE_SET}") @@ -458,7 +458,7 @@ function(get_ip_include_directories OUTVAR IP_LIB LANGUAGE) # In case FILE_SETS function argument is not specified, return all defined file sets # Otherwise return only files in listed file sets - get_ip_property(ip_filesets ${_reallib} FILE_SETS ${_no_deps}) + get_ip_property(ip_filesets ${_reallib} LANG_FILE_SETS ${_no_deps}) if(NOT ARG_FILE_SETS) set(filesets ${ip_filesets}) else() @@ -722,11 +722,11 @@ function(ip_compile_definitions IP_LIB LANGUAGE) endif() set(comp_def_property ${LANGUAGE}_${ARG_FILE_SET}_COMPILE_DEFINITIONS) - # Add the file set to the FILE_SETS property - get_property(filesets TARGET ${_reallib} PROPERTY FILE_SETS) + # Add the file set to the LANG_FILE_SETS property + get_property(filesets TARGET ${_reallib} PROPERTY LANG_FILE_SETS) set(file_set "${LANGUAGE}::${ARG_FILE_SET}") if(NOT file_set IN_LIST filesets) - set_property(TARGET ${_reallib} APPEND PROPERTY FILE_SETS ${file_set}) + set_property(TARGET ${_reallib} APPEND PROPERTY LANG_FILE_SETS ${file_set}) endif() # Remove the FILE_SET argument and its value from ARGN to not interfere with directory list list(REMOVE_ITEM ARGN "${ARG_FILE_SET}") @@ -771,7 +771,7 @@ function(get_ip_compile_definitions OUTVAR IP_LIB LANGUAGE) # In case FILE_SETS function argument is not specified, return all defined file sets # Otherwise return only files in listed file sets - get_ip_property(ip_filesets ${_reallib} FILE_SETS ${_no_deps}) + get_ip_property(ip_filesets ${_reallib} LANG_FILE_SETS ${_no_deps}) if(NOT ARG_FILE_SETS) set(filesets ${ip_filesets}) else() diff --git a/cmake/utils/install/install.cmake b/cmake/utils/install/install.cmake index 76cd0394..d1478774 100644 --- a/cmake/utils/install/install.cmake +++ b/cmake/utils/install/install.cmake @@ -8,7 +8,7 @@ function(make_outdir_path OUTVAR IP_LIB) endfunction() function(ip_install IP_LIB) - cmake_parse_arguments(ARG "" "" "FILE_SETS;EXCLUDE_FILE_SETS" ${ARGN}) + cmake_parse_arguments(ARG "" "" "LANGUAGES;FILE_SETS;EXCLUDE_FILE_SETS" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() @@ -20,9 +20,13 @@ function(ip_install IP_LIB) set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES IP_NAME) set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES VERSION) - set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES FILE_SETS) + set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES LANG_FILE_SETS) get_property(export_sources TARGET ${IP_LIB} PROPERTY EXPORT_PROPERTIES) - get_property(filesets TARGET ${IP_LIB} PROPERTY FILE_SETS) + + # Get file sets that were set on the IP block + # This is a combination of {LANGUAGE}::{FILE_SET} + get_property(filesets TARGET ${IP_LIB} PROPERTY LANG_FILE_SETS) + # list(FILTER export_sources INCLUDE REGEX "(_SOURCES|_HEADERS|_INCLUDE_DIRECTORIES)$") make_outdir_path(OUTDIR ${IP_LIB}) From dbdef63b36834e7d5282bc856a9821487a5ce755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Thu, 26 Jun 2025 23:52:05 +0200 Subject: [PATCH 21/26] Allow selecting languages and filesets to be installed with ip install --- cmake/utils/install/install.cmake | 36 ++++++++++++++++++- .../install/peakrdl_regblock/CMakeLists.txt | 19 ++++++++++ examples/install/peakrdl_regblock/simple.rdl | 5 +++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 examples/install/peakrdl_regblock/CMakeLists.txt create mode 100644 examples/install/peakrdl_regblock/simple.rdl diff --git a/cmake/utils/install/install.cmake b/cmake/utils/install/install.cmake index d1478774..3ea11f6f 100644 --- a/cmake/utils/install/install.cmake +++ b/cmake/utils/install/install.cmake @@ -25,7 +25,41 @@ function(ip_install IP_LIB) # Get file sets that were set on the IP block # This is a combination of {LANGUAGE}::{FILE_SET} - get_property(filesets TARGET ${IP_LIB} PROPERTY LANG_FILE_SETS) + unset(filesets) + if(NOT ARG_LANGUAGES AND NOT ARG_FILE_SETS) + get_property(filesets TARGET ${IP_LIB} PROPERTY LANG_FILE_SETS) + elseif(ARG_LANGUAGES AND ARG_FILE_SETS) + foreach(lang ${ARG_LANGUAGES}) + foreach(fileset_name ${ARG_FILE_SETS}) + list(APPEND filesets ${lang}::${fileset_name}) + endforeach() + endforeach() + elseif(ARG_LANGUAGES AND NOT ARG_FILE_SETS) + get_property(set_filesets TARGET ${IP_LIB} PROPERTY LANG_FILE_SETS) + foreach(lang_to_install ${ARG_LANGUAGES}) + foreach(fileset ${set_filesets}) + string(REPLACE "::" ";" fileset_list "${fileset}") + list(GET fileset_list 0 fileset_language) + list(GET fileset_list 1 fileset_name) + if(${lang_to_install} STREQUAL ${fileset_language}) + list(APPEND filesets ${fileset}) + endif() + endforeach() + endforeach() + elseif(NOT ARG_LANGUAGES AND ARG_FILE_SETS) + get_property(set_filesets TARGET ${IP_LIB} PROPERTY LANG_FILE_SETS) + foreach(fileset_to_install ${ARG_FILE_SETS}) + foreach(fileset ${set_filesets}) + string(REPLACE "::" ";" fileset_list "${fileset}") + list(GET fileset_list 0 fileset_language) + list(GET fileset_list 1 fileset_name) + if(${fileset_to_install} STREQUAL ${fileset_name}) + list(APPEND filesets ${fileset}) + endif() + endforeach() + endforeach() + endif() + message("FILE_SETS: ${filesets}") # list(FILTER export_sources INCLUDE REGEX "(_SOURCES|_HEADERS|_INCLUDE_DIRECTORIES)$") diff --git a/examples/install/peakrdl_regblock/CMakeLists.txt b/examples/install/peakrdl_regblock/CMakeLists.txt new file mode 100644 index 00000000..f3c3d775 --- /dev/null +++ b/examples/install/peakrdl_regblock/CMakeLists.txt @@ -0,0 +1,19 @@ +include("../../../SoCMakeConfig.cmake") + +cmake_minimum_required(VERSION 3.25) + +project(adder NONE) + +add_ip(vendor::ip::simple::0.0.1 NO_ALIAS + DESCRIPTION "Just a simple generated IP block" +) + +ip_sources(${IP} SYSTEMRDL + ./simple.rdl + ) + +peakrdl_regblock(${IP}) + +ip_install(${IP} + LANGUAGES SYSTEMVERILOG +) diff --git a/examples/install/peakrdl_regblock/simple.rdl b/examples/install/peakrdl_regblock/simple.rdl new file mode 100644 index 00000000..16e9fb2b --- /dev/null +++ b/examples/install/peakrdl_regblock/simple.rdl @@ -0,0 +1,5 @@ +addrmap simple{ + reg { + field {} f1[32]; + } r1; +}; From 610cb9b92cd36b99596910d0cc2b2f89769c3708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Thu, 26 Jun 2025 23:55:36 +0200 Subject: [PATCH 22/26] Allow excluding languages and file sets in ip install --- cmake/utils/install/install.cmake | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmake/utils/install/install.cmake b/cmake/utils/install/install.cmake index 3ea11f6f..6edbbd00 100644 --- a/cmake/utils/install/install.cmake +++ b/cmake/utils/install/install.cmake @@ -8,7 +8,7 @@ function(make_outdir_path OUTVAR IP_LIB) endfunction() function(ip_install IP_LIB) - cmake_parse_arguments(ARG "" "" "LANGUAGES;FILE_SETS;EXCLUDE_FILE_SETS" ${ARGN}) + cmake_parse_arguments(ARG "" "" "LANGUAGES;FILE_SETS;EXCLUDE_LANGUAGES;EXCLUDE_FILE_SETS" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() @@ -61,6 +61,18 @@ function(ip_install IP_LIB) endif() message("FILE_SETS: ${filesets}") + if(ARG_EXCLUDE_LANGUAGES) + foreach(lang ${ARG_EXCLUDE_LANGUAGES}) + list(FILTER filesets EXCLUDE REGEX "^${lang}::") + endforeach() + endif() + + if(ARG_EXCLUDE_FILE_SETS) + foreach(fileset ${ARG_EXCLUDE_FILE_SETS}) + list(FILTER filesets EXCLUDE REGEX "::${fileset}$") + endforeach() + endif() + # list(FILTER export_sources INCLUDE REGEX "(_SOURCES|_HEADERS|_INCLUDE_DIRECTORIES)$") make_outdir_path(OUTDIR ${IP_LIB}) From 6062f0564f26e9527f20590a9ae4400fe587c2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Wed, 2 Jul 2025 23:12:13 +0200 Subject: [PATCH 23/26] Enable experimental CMake feature to automatically generate find_dependency calls --- cmake/utils/install/install.cmake | 28 ++++++++++------- cmake/utils/install/ipConfig.cmake.in | 4 +-- .../install/simple_verilog/CMakeLists.txt | 31 ++++++++++--------- .../install/simple_verilog/sim/CMakeLists.txt | 18 +++++++++++ .../install/simple_verilog/tb/CMakeLists.txt | 8 +++-- 5 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 examples/install/simple_verilog/sim/CMakeLists.txt diff --git a/cmake/utils/install/install.cmake b/cmake/utils/install/install.cmake index 6edbbd00..5b1074c3 100644 --- a/cmake/utils/install/install.cmake +++ b/cmake/utils/install/install.cmake @@ -8,6 +8,8 @@ function(make_outdir_path OUTVAR IP_LIB) endfunction() function(ip_install IP_LIB) + set(CMAKE_EXPERIMENTAL_EXPORT_PACKAGE_DEPENDENCIES "1942b4fa-b2c5-4546-9385-83f254070067") + cmake_parse_arguments(ARG "" "" "LANGUAGES;FILE_SETS;EXCLUDE_LANGUAGES;EXCLUDE_FILE_SETS" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") @@ -98,7 +100,7 @@ function(ip_install IP_LIB) set_property(TARGET ${IP_LIB} APPEND PROPERTY EXPORT_PROPERTIES ${fileset_property}_COMPILE_DEFINITIONS) # string(REGEX REPLACE "_SOURCES$" "" fileset ${fileset}) # message("fileset is: ${fileset}") - get_ip_sources(${fileset} ${IP_LIB} ${fileset_language} FILE_SETS ${fileset_name}) + get_ip_sources(${fileset} ${IP_LIB} ${fileset_language} FILE_SETS ${fileset_name} NO_DEPS) unset(${fileset}_copy) foreach(source ${${fileset}}) @@ -117,6 +119,7 @@ function(ip_install IP_LIB) get_property(IP_NAME TARGET ${IP_LIB} PROPERTY IP_NAME) get_property(IP_VERSION TARGET ${IP_LIB} PROPERTY VERSION) + set(VERSION_USED FALSE) if(NOT IP_VERSION) set(VERSION 0.0.1) @@ -125,31 +128,34 @@ function(ip_install IP_LIB) set(VERSION_USED TRUE) endif() + string(REPLACE "__${VERSION}" "" package_name "${IP_LIB}") + include(CMakePackageConfigHelpers) write_basic_package_version_file( - "${PROJECT_BINARY_DIR}/${IP_NAME}ConfigVersion.cmake" + "${PROJECT_BINARY_DIR}/${package_name}ConfigVersion.cmake" VERSION ${VERSION} COMPATIBILITY AnyNewerVersion ) install(TARGETS ${IP_LIB} - EXPORT ${IP_NAME}Targets + EXPORT ${package_name}Targets ) - + include(CMakePackageConfigHelpers) configure_package_config_file( "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ipConfig.cmake.in" - "${PROJECT_BINARY_DIR}/${IP_NAME}Config.cmake" - INSTALL_DESTINATION "${OUTDIR}/lib/cmake/${IP_NAME}" + "${PROJECT_BINARY_DIR}/${package_name}Config.cmake" + INSTALL_DESTINATION "${OUTDIR}/lib/cmake/${package_name}" ) - install(EXPORT ${IP_NAME}Targets - DESTINATION "${OUTDIR}/lib/cmake/${IP_NAME}" + install(EXPORT ${package_name}Targets + DESTINATION "${OUTDIR}/lib/cmake/${package_name}" + EXPORT_PACKAGE_DEPENDENCIES ) - install(FILES "${PROJECT_BINARY_DIR}/${IP_NAME}ConfigVersion.cmake" - "${PROJECT_BINARY_DIR}/${IP_NAME}Config.cmake" - DESTINATION "${OUTDIR}/lib/cmake/${IP_NAME}" + install(FILES "${PROJECT_BINARY_DIR}/${package_name}ConfigVersion.cmake" + "${PROJECT_BINARY_DIR}/${package_name}Config.cmake" + DESTINATION "${OUTDIR}/lib/cmake/${package_name}" ) endfunction() diff --git a/cmake/utils/install/ipConfig.cmake.in b/cmake/utils/install/ipConfig.cmake.in index 2b6a1c55..848bfed5 100644 --- a/cmake/utils/install/ipConfig.cmake.in +++ b/cmake/utils/install/ipConfig.cmake.in @@ -1,7 +1,7 @@ @PACKAGE_INIT@ -include("${CMAKE_CURRENT_LIST_DIR}/adderTargets.cmake") -check_required_components("@PROJECT_NAME@") +include("${CMAKE_CURRENT_LIST_DIR}/@package_name@Targets.cmake") +check_required_components("@package_name@") string(REPLACE "__" "::" IP_ALIAS "@IP_LIB@") if(NOT "${IP_ALIAS}" STREQUAL "@IP_LIB@") diff --git a/examples/install/simple_verilog/CMakeLists.txt b/examples/install/simple_verilog/CMakeLists.txt index d43d0cd9..86a32d7d 100644 --- a/examples/install/simple_verilog/CMakeLists.txt +++ b/examples/install/simple_verilog/CMakeLists.txt @@ -1,24 +1,25 @@ + include("../../../SoCMakeConfig.cmake") cmake_minimum_required(VERSION 3.25) project(adder NONE) -foreach(i RANGE 1 10) - add_ip(vendor::ip::adder::0.0.${i} NO_ALIAS - DESCRIPTION "Just a simple adder") - - ip_sources(${IP} VERILOG - ./adder/adder.v - # HEADERS - # ./adder/adder.v - ) - -# ip_include_directories(${IP} VERILOG -# ./adder) - - ip_install(${IP}) -endforeach() +# foreach(i RANGE 1 10) +# add_ip(vendor::ip::adder::0.0.${i} NO_ALIAS +# DESCRIPTION "Just a simple adder") +# +# ip_sources(${IP} VERILOG +# ./adder/adder.v +# # HEADERS +# # ./adder/adder.v +# ) +# +# # ip_include_directories(${IP} VERILOG +# # ./adder) +# +# ip_install(${IP}) +# endforeach() add_ip(vendor::ip::mult::0.0.1 NO_ALIAS DESCRIPTION "Just a simple adder") diff --git a/examples/install/simple_verilog/sim/CMakeLists.txt b/examples/install/simple_verilog/sim/CMakeLists.txt new file mode 100644 index 00000000..fa47439c --- /dev/null +++ b/examples/install/simple_verilog/sim/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.25) +project(simple_verilog_example NONE) + +include("../../../../SoCMakeConfig.cmake") + +find_package(tb CONFIG REQUIRED + HINTS ${PROJECT_SOURCE_DIR}/../tb/build/here/*/*/*/* + ) +# add_subdirectory("..//" mult) +# ip_link(${IP} vendor::ip::mult::0.0.1) +# +# +iverilog(tb) +# ip_install(vendor__ip__mult__0.0.1) +# ip_install(tb) + +help() + diff --git a/examples/install/simple_verilog/tb/CMakeLists.txt b/examples/install/simple_verilog/tb/CMakeLists.txt index 46de4fe0..7c7c4653 100644 --- a/examples/install/simple_verilog/tb/CMakeLists.txt +++ b/examples/install/simple_verilog/tb/CMakeLists.txt @@ -9,12 +9,14 @@ add_ip(tb ip_sources(${IP} VERILOG tb.v) -find_package(adder 0.0.10 CONFIG REQUIRED - HINTS ${PROJECT_SOURCE_DIR}/../build/here/*/*/*/* +find_package(vendor__ip__mult CONFIG REQUIRED + HINTS ${PROJECT_SOURCE_DIR}/../build/here/vendor/ip/mult/0.0.1 ) -ip_link(${IP} vendor::ip::adder) +# add_subdirectory("..//" mult) +ip_link(${IP} vendor::ip::mult::0.0.1) iverilog(${IP}) +ip_install(${IP}) help() From 8855a01440745e2c2fde8aa3cac503e91dbe1608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Thu, 3 Jul 2025 00:23:05 +0200 Subject: [PATCH 24/26] Move cmake package files installation to CMAKE_INSTALL_PREFIX/lib/cmake --- cmake/utils/install/install.cmake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmake/utils/install/install.cmake b/cmake/utils/install/install.cmake index 5b1074c3..6c8a2dc1 100644 --- a/cmake/utils/install/install.cmake +++ b/cmake/utils/install/install.cmake @@ -61,7 +61,6 @@ function(ip_install IP_LIB) endforeach() endforeach() endif() - message("FILE_SETS: ${filesets}") if(ARG_EXCLUDE_LANGUAGES) foreach(lang ${ARG_EXCLUDE_LANGUAGES}) @@ -145,17 +144,17 @@ function(ip_install IP_LIB) configure_package_config_file( "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ipConfig.cmake.in" "${PROJECT_BINARY_DIR}/${package_name}Config.cmake" - INSTALL_DESTINATION "${OUTDIR}/lib/cmake/${package_name}" + INSTALL_DESTINATION "lib/cmake/${package_name}" ) install(EXPORT ${package_name}Targets - DESTINATION "${OUTDIR}/lib/cmake/${package_name}" + DESTINATION "lib/cmake/${package_name}" EXPORT_PACKAGE_DEPENDENCIES ) install(FILES "${PROJECT_BINARY_DIR}/${package_name}ConfigVersion.cmake" "${PROJECT_BINARY_DIR}/${package_name}Config.cmake" - DESTINATION "${OUTDIR}/lib/cmake/${package_name}" + DESTINATION "lib/cmake/${package_name}" ) endfunction() From b1ea09e032ad7bffbd90da4ddc30c7412fddcbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Thu, 3 Jul 2025 23:57:10 +0200 Subject: [PATCH 25/26] Add support for Verible obfuscator --- cmake/misc/verible_obfuscate.cmake | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 cmake/misc/verible_obfuscate.cmake diff --git a/cmake/misc/verible_obfuscate.cmake b/cmake/misc/verible_obfuscate.cmake new file mode 100644 index 00000000..ec1ac3df --- /dev/null +++ b/cmake/misc/verible_obfuscate.cmake @@ -0,0 +1,70 @@ +include_guard(GLOBAL) + +function(verible_obfuscate IP_LIB) + cmake_parse_arguments(ARG "NO_DEPS" "OUTDIR" "FILE_SETS" ${ARGN}) + if(ARG_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") + endif() + + alias_dereference(IP_LIB ${IP_LIB}) + get_target_property(BINARY_DIR ${IP_LIB} BINARY_DIR) + + if(NOT ARG_OUTDIR) + set(OUTDIR ${BINARY_DIR}/${IP_LIB}_${CMAKE_CURRENT_FUNCTION}) + else() + set(OUTDIR ${ARG_OUTDIR}) + endif() + file(MAKE_DIRECTORY ${OUTDIR}) + + if(ARG_FILE_SETS) + set(FILE_SETS_FUNC_ARG FILE_SETS ${ARG_FILE_SETS}) + endif() + + if(ARG_NO_DEPS) + set(ips ${IP_LIB}) + else() + get_ip_links(ips ${IP_LIB}) + endif() + + unset(all_gen_files) + foreach(ip IN LISTS ips) + get_property(filesets TARGET ${ip} PROPERTY LANG_FILE_SETS) + + set(languages VERILOG SYSTEMVERILOG) + + foreach(fileset IN LISTS filesets) + string(REPLACE "::" ";" fileset_list "${fileset}") + list(GET fileset_list 0 fileset_language) + list(GET fileset_list 1 fileset_name) + if(fileset_language IN_LIST languages) + get_ip_sources(sources ${ip} ${fileset_language} FILE_SETS ${fileset_name} NO_DEPS) + unset(replace_sources) + foreach(source ${sources}) + cmake_path(GET source FILENAME source_fn) + set(source_new "${OUTDIR}/${source_fn}") + + list(APPEND replace_sources "${source_new}") + + add_custom_command( + OUTPUT ${source_new} + COMMAND verible-verilog-obfuscate < ${source} > ${source_new} + DEPENDS ${source} + COMMENT "Obfuscate ${source_fn} of ${IP_LIB} with Verible" + ) + list(APPEND all_gen_files ${source_new}) + endforeach() + ip_sources(${ip} ${fileset_language} FILE_SET ${fileset_name} REPLACE "${replace_sources}") + + endif() + endforeach() + endforeach() + + + set(DESCRIPTION "Obfuscating Verilog/SV files of ${IP_LIB} with Verible obfuscate") + add_custom_target(${IP_LIB}_verible_obfuscate + DEPENDS ${all_gen_files} + ) + set_property(TARGET ${IP_LIB}_verible_obfuscate PROPERTY DESCRIPTION ${DESCRIPTION}) + +endfunction() + From 061009e7a2733f9fa6dee04e9a29d65d8817b386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Risto=20Peja=C5=A1inovi=C4=87?= Date: Thu, 3 Jul 2025 23:57:24 +0200 Subject: [PATCH 26/26] Add support for questa vencrypt for HDL code encryption --- cmake/sim/siemens/modelsim_encrypt.cmake | 76 ++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 cmake/sim/siemens/modelsim_encrypt.cmake diff --git a/cmake/sim/siemens/modelsim_encrypt.cmake b/cmake/sim/siemens/modelsim_encrypt.cmake new file mode 100644 index 00000000..9b870b73 --- /dev/null +++ b/cmake/sim/siemens/modelsim_encrypt.cmake @@ -0,0 +1,76 @@ +include_guard(GLOBAL) + +function(modelsim_encrypt IP_LIB) + cmake_parse_arguments(ARG "NO_DEPS;QUIET" "OUTDIR" "FILE_SETS" ${ARGN}) + if(ARG_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") + endif() + + include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../hwip.cmake") + include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../sim_utils.cmake") + + alias_dereference(IP_LIB ${IP_LIB}) + get_target_property(BINARY_DIR ${IP_LIB} BINARY_DIR) + + if(NOT ARG_OUTDIR) + set(OUTDIR ${BINARY_DIR}/${IP_LIB}_${CMAKE_CURRENT_FUNCTION}) + else() + set(OUTDIR ${ARG_OUTDIR}) + endif() + file(MAKE_DIRECTORY ${OUTDIR}) + + if(ARG_FILE_SETS) + set(FILE_SETS_FUNC_ARG FILE_SETS ${ARG_FILE_SETS}) + endif() + + if(ARG_NO_DEPS) + set(ips ${IP_LIB}) + else() + get_ip_links(ips ${IP_LIB}) + endif() + + unset(all_gen_files) + foreach(ip IN LISTS ips) + get_property(filesets TARGET ${ip} PROPERTY LANG_FILE_SETS) + + set(languages VERILOG SYSTEMVERILOG VHDL) + + foreach(fileset IN LISTS filesets) + string(REPLACE "::" ";" fileset_list "${fileset}") + list(GET fileset_list 0 fileset_language) + list(GET fileset_list 1 fileset_name) + if(fileset_language IN_LIST languages) + get_ip_sources(sources ${ip} ${fileset_language} FILE_SETS ${fileset_name} NO_DEPS) + unset(replace_sources) + foreach(source ${sources}) + cmake_path(GET source EXTENSION LAST_ONLY ext) + set(new_ext "${ext}p") + cmake_path(GET source FILENAME source_fn) + cmake_path(REPLACE_EXTENSION source_fn LAST_ONLY "${new_ext}" OUTPUT_VARIABLE source_new) + string(REPLACE "." "" new_ext "${new_ext}") + set(source_new "${OUTDIR}/${source_new}") + + list(APPEND replace_sources "${source_new}") + + add_custom_command( + OUTPUT ${source_new} + COMMAND vencrypt ${source} -e "${new_ext}" -d ${OUTDIR} $<$:-quiet> + DEPENDS ${source} + COMMENT "Encrypt ${source_fn} of ${IP_LIB} with modelsim vencrypt" + ) + list(APPEND all_gen_files ${source_new}) + endforeach() + ip_sources(${ip} ${fileset_language} FILE_SET ${fileset_name} REPLACE "${replace_sources}") + + endif() + endforeach() + endforeach() + + + set(DESCRIPTION "Encrypting HDL files of ${IP_LIB} with modelsim vencrypt") + add_custom_target(${IP_LIB}_modelsim_encrypt + DEPENDS ${all_gen_files} + ) + set_property(TARGET ${IP_LIB}_modelsim_encrypt PROPERTY DESCRIPTION ${DESCRIPTION}) + +endfunction()