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..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}") @@ -304,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() @@ -355,16 +353,18 @@ 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() + 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) @@ -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}") @@ -457,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 - get_ip_property(ip_filesets ${_reallib} FILE_SETS ${_no_deps}) + # Otherwise return only files in listed file sets + get_ip_property(ip_filesets ${_reallib} LANG_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 @@ -509,7 +511,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() @@ -720,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}") @@ -768,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 - get_ip_property(ip_filesets ${_reallib} FILE_SETS ${_no_deps}) + # Otherwise return only files in listed file sets + get_ip_property(ip_filesets ${_reallib} LANG_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 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() + 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() 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..6c8a2dc1 --- /dev/null +++ b/cmake/utils/install/install.cmake @@ -0,0 +1,160 @@ +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) + 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}") + 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 LANG_FILE_SETS) + get_property(export_sources TARGET ${IP_LIB} PROPERTY EXPORT_PROPERTIES) + + # Get file sets that were set on the IP block + # This is a combination of {LANGUAGE}::{FILE_SET} + 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() + + 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}) + + 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 ${filesets}) + string(REPLACE "::" ";" fileset_list "${fileset}") + 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} NO_DEPS) + + unset(${fileset}_copy) + foreach(source ${${fileset}}) + cmake_path(GET source FILENAME filename) + list(APPEND ${fileset}_copy "\${_IMPORT_PREFIX}/${OUTDIR}/${fileset_language}/${fileset_name}/${filename}") + endforeach() + + ip_sources(${IP_LIB} ${fileset_language} FILE_SET ${fileset_name} REPLACE + ${${fileset}_copy} + ) + + install(FILES ${${fileset}} + DESTINATION "${OUTDIR}/${fileset_language}/${fileset_name}" + ) + 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() + + string(REPLACE "__${VERSION}" "" package_name "${IP_LIB}") + + include(CMakePackageConfigHelpers) + write_basic_package_version_file( + "${PROJECT_BINARY_DIR}/${package_name}ConfigVersion.cmake" + VERSION ${VERSION} + COMPATIBILITY AnyNewerVersion + ) + + install(TARGETS ${IP_LIB} + EXPORT ${package_name}Targets + ) + + include(CMakePackageConfigHelpers) + configure_package_config_file( + "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ipConfig.cmake.in" + "${PROJECT_BINARY_DIR}/${package_name}Config.cmake" + INSTALL_DESTINATION "lib/cmake/${package_name}" + ) + + install(EXPORT ${package_name}Targets + 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 "lib/cmake/${package_name}" + ) + +endfunction() diff --git a/cmake/utils/install/ipConfig.cmake.in b/cmake/utils/install/ipConfig.cmake.in new file mode 100644 index 00000000..848bfed5 --- /dev/null +++ b/cmake/utils/install/ipConfig.cmake.in @@ -0,0 +1,16 @@ +@PACKAGE_INIT@ + +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@") + add_library(${IP_ALIAS} ALIAS @IP_LIB@) +endif() + +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/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; +}; diff --git a/examples/install/simple_verilog/CMakeLists.txt b/examples/install/simple_verilog/CMakeLists.txt new file mode 100644 index 00000000..86a32d7d --- /dev/null +++ b/examples/install/simple_verilog/CMakeLists.txt @@ -0,0 +1,36 @@ + +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() + +add_ip(vendor::ip::mult::0.0.1 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}) 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/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 new file mode 100644 index 00000000..7c7c4653 --- /dev/null +++ b/examples/install/simple_verilog/tb/CMakeLists.txt @@ -0,0 +1,22 @@ +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(vendor__ip__mult CONFIG REQUIRED + HINTS ${PROJECT_SOURCE_DIR}/../build/here/vendor/ip/mult/0.0.1 + ) +# add_subdirectory("..//" mult) +ip_link(${IP} vendor::ip::mult::0.0.1) + + +iverilog(${IP}) +ip_install(${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 +