Skip to content

Commit

Permalink
Uniquify level (#102)
Browse files Browse the repository at this point in the history
Co-authored-by: Benoit Denkinger <[email protected]>
  • Loading branch information
benoitdenkinger and Benoit Denkinger authored Nov 18, 2024
1 parent 1120f31 commit 96ef16a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cmake/firmware/linker_script/src/template/linker.lds.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
23 changes: 15 additions & 8 deletions cmake/sim/cadence/xcelium.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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()

Expand All @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions cmake/utils/uniquify_files_by_basename.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand All @@ -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()

0 comments on commit 96ef16a

Please sign in to comment.