Skip to content

Commit d1cb403

Browse files
committed
sw: Allow cluster level overwrites of CMake definitions
Less hardcoding of Spatz configurations but instead put the burden on higher-level settings.
1 parent 70bc183 commit d1cb403

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

sw/snRuntime/CMakeLists.txt

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,30 @@ if(SPATZ_CLUSTER_CFG MATCHES "^(spatz_cluster\.(default|mempool|smallvrf)\.dram)
3030
elseif("${SPATZ_CLUSTER_CFG}" MATCHES "^spatz_cluster.carfield\\.(l2|dram)\\.hjson$")
3131
set(_plat_folder "cheshire")
3232
else()
33-
message(FATAL_ERROR
34-
"Unknown configuration SPATZ_CLUSTER_CFG: ${SPATZ_CLUSTER_CFG} for platform assignment")
33+
if(NOT DEFINED SPATZ_CLUSTER_PLATFORM)
34+
message(WARNING
35+
"Unknown configuration SPATZ_CLUSTER_CFG: ${SPATZ_CLUSTER_CFG} for platform assignment")
36+
else()
37+
message(STATUS
38+
"Overwriting platform with SPATZ_CLUSTER_PLATFORM: ${SPATZ_CLUSTER_PLATFORM}")
39+
set(_plat_folder "${SPATZ_CLUSTER_PLATFORM}")
40+
endif()
41+
endif()
42+
43+
# 3. Check for platform folder assignment and throw a FATAL_ERROR if missing
44+
if(NOT _plat_folder)
45+
# Check if a platform was set (either by the match above or externally)
46+
# If no platform was set AND the platform folder is missing, throw FATAL_ERROR
47+
message(FATAL_ERROR
48+
"Could not determine platform folder. "
49+
"Configuration 'SPATZ_CLUSTER_CFG' was unmatched AND "
50+
"required variable 'SPATZ_CLUSTER_PLATFORM' is not set.")
51+
3552
endif()
3653

3754
set(PLATFORM_SOURCE_FOLDER "src/platforms/${_plat_folder}" CACHE STRING "Path to the platform-specific sources")
3855

56+
3957
# Default memory regions
4058
set(MEM_SPATZ_CLUSTER_DEFAULT_DRAM_HJSON_ORIGIN 0x80000000)
4159
set(MEM_SPATZ_CLUSTER_DEFAULT_DRAM_HJSON_SIZE 0x80000000)
@@ -56,6 +74,16 @@ string(TOUPPER "${_key}" _key)
5674
set(_orig_var "MEM_${_key}_ORIGIN")
5775
set(_size_var "MEM_${_key}_SIZE")
5876

77+
if(NOT DEFINED ${_orig_var} AND DEFINED SPATZ_CLUSTER_MEMORY_ORIGIN)
78+
message(STATUS "Overriding memory origin with SPATZ_CLUSTER_MEMORY_ORIGIN: ${SPATZ_CLUSTER_MEMORY_ORIGIN}")
79+
set(_orig_var "SPATZ_CLUSTER_MEMORY_ORIGIN")
80+
endif()
81+
82+
if(NOT DEFINED ${_size_var} AND DEFINED SPATZ_CLUSTER_MEMORY_SIZE)
83+
message(STATUS "Overriding memory size with SPATZ_CLUSTER_MEMORY_SIZE: ${SPATZ_CLUSTER_MEMORY_SIZE}")
84+
set(_size_var "SPATZ_CLUSTER_MEMORY_SIZE")
85+
endif()
86+
5987
if(DEFINED ${_orig_var} AND DEFINED ${_size_var})
6088
# perform the lookup
6189
set(MEM_DRAM_ORIGIN "${${_orig_var}}" CACHE STRING "Base address of external memory")

0 commit comments

Comments
 (0)