From 96ef16adb5eb2247b5632b1f84fdbce6b0259bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Denkinger?= <42833463+benoitdenkinger@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:32:09 +0100 Subject: [PATCH] Uniquify level (#102) Co-authored-by: Benoit Denkinger --- .../linker_script/src/template/linker.lds.j2 | 4 ++-- cmake/sim/cadence/xcelium.cmake | 23 ++++++++++++------- cmake/utils/uniquify_files_by_basename.cmake | 6 +++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/cmake/firmware/linker_script/src/template/linker.lds.j2 b/cmake/firmware/linker_script/src/template/linker.lds.j2 index 5a55d6c..d7f5011 100644 --- a/cmake/firmware/linker_script/src/template/linker.lds.j2 +++ b/cmake/firmware/linker_script/src/template/linker.lds.j2 @@ -27,8 +27,8 @@ SECTIONS {% if boot_mem is not none %} .bootloader : { - *bootloader.S.o*(*); - *bootloader.cpp.o*(*); + *bootloader.S.o*(.text .text.*); + *bootloader.cpp.o*(.text .text.*); . = ALIGN(4); } > {{ boot_mem.parent.inst_name }} {% endif %} diff --git a/cmake/sim/cadence/xcelium.cmake b/cmake/sim/cadence/xcelium.cmake index 15a4cbf..847bf59 100644 --- a/cmake/sim/cadence/xcelium.cmake +++ b/cmake/sim/cadence/xcelium.cmake @@ -10,7 +10,7 @@ # # :keyword ELABORATE: sets xrun to compile and elaborate only the design (no simulation). # :type ELABORATE: string -# :keyword UNIQUIFY: Uniquifies the list of ip sources based on the basename of the files. +# :keyword UNIQUIFY: Uniquifies the list of ip sources based on the basename of the files: WARNING or FATAL_ERROR. # :type UNIQUIFY: string # :keyword SYNTHESIS: Prevents behavioural/generic RTL files to be fetched. # :type SYNTHESIS: string @@ -24,7 +24,7 @@ # :type ARGS: string #]] function(xcelium IP_LIB) - cmake_parse_arguments(ARG "ELABORATE;UNIQUIFY;SYNTHESIS" "ACCESS" "SETENV;DEFINES;ARGS" ${ARGN}) + cmake_parse_arguments(ARG "ELABORATE;SYNTHESIS" "UNIQUIFY;ACCESS;TIMESCALE" "SETENV;DEFINES;ARGS" ${ARGN}) if(ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}") endif() @@ -44,11 +44,18 @@ function(xcelium IP_LIB) get_ip_tb_only_rtl_sources(TB_SOURCES_LIST ${IP_LIB}) list(APPEND SOURCES_LIST ${TB_SOURCES_LIST}) - if(${ARG_UNIQUIFY}) - # uniquify the list of files to avoid redefinition (comparing file basenames) - # This function also check files with same basename have the same content - uniquify_files_by_basename(SOURCES_LIST_UNIQUIFY "${SOURCES_LIST}") + # Why do I need to this #@!$ NOT?!?!?! + if(NOT ${ARG_UNIQUIFY}) + if (${ARG_UNIQUIFY} STREQUAL "WARNING" OR ${ARG_UNIQUIFY} STREQUAL "FATAL_ERROR") + message(DEBUG "xcelium: UNIQUIFY argument is ${ARG_UNIQUIFY}") + # uniquify the list of files to avoid redefinition (comparing file basenames) + # This function also check files with same basename have the same content + uniquify_files_by_basename(SOURCES_LIST_UNIQUIFY "${SOURCES_LIST}" ${ARG_UNIQUIFY}) + else() + message(WARNING "xcelium: unrecognized UNIQUIFY argument ${ARG_UNIQUIFY}. It should be equal to WARNING or FATAL_ERROR for unquifiy to be applied.") + endif() else() + message(DEBUG "xcelium: UNIQUIFY argument is not set (value=${ARG_UNIQUIFY})") set(SOURCES_LIST_UNIQUIFY ${SOURCES_LIST}) endif() @@ -73,8 +80,8 @@ function(xcelium IP_LIB) endforeach() # Change the default timescale 1ps/1ps if TIMESCALE argument is passed - if(${TIMESCALE_ARG}) - set(TIMESCALE_ARG -timescale ${TIMESCALE_ARG}) + if(${ARG_TIMESCALE}) + set(TIMESCALE_ARG -timescale ${ARG_TIMESCALE}) else() set(TIMESCALE_ARG -timescale 1ps/1ps) endif() diff --git a/cmake/utils/uniquify_files_by_basename.cmake b/cmake/utils/uniquify_files_by_basename.cmake index 74aa044..e150f4e 100644 --- a/cmake/utils/uniquify_files_by_basename.cmake +++ b/cmake/utils/uniquify_files_by_basename.cmake @@ -11,7 +11,7 @@ # :type OUTPUT_LIST: string # #]] -function(uniquify_files_by_basename OUTPUT_LIST INPUT_LIST) +function(uniquify_files_by_basename OUTPUT_LIST INPUT_LIST MESSAGE_MODE) # Define a dictionary to keep track of seen basenames # set(_seen_basenames "") set(_unique_files "") @@ -34,11 +34,13 @@ function(uniquify_files_by_basename OUTPUT_LIST INPUT_LIST) file(READ ${file} CURRENT_CONTENT) file(READ ${_seen_basenames_${basename}} ORIGINAL_CONTENT) if(NOT "${CURRENT_CONTENT}" STREQUAL "${ORIGINAL_CONTENT}") - message(FATAL_ERROR "Files ${file} and ${_seen_basenames_${basename}} have the same basename (${basename}) but different content.") + message(${MESSAGE_MODE} "Files ${file} and ${_seen_basenames_${basename}} have the same basename (${basename}) but different content.") endif() endif() endforeach() + message(DEBUG "UNIQUIFY: OUTPUT_LIST ${_unique_files}") + # Return the list of unique files set(${OUTPUT_LIST} ${_unique_files} PARENT_SCOPE) endfunction()