@@ -30,12 +30,30 @@ if(SPATZ_CLUSTER_CFG MATCHES "^(spatz_cluster\.(default|mempool|smallvrf)\.dram)
3030elseif ("${SPATZ_CLUSTER_CFG} " MATCHES "^spatz_cluster.carfield\\ .(l2|dram)\\ .hjson$" )
3131 set (_plat_folder "cheshire" )
3232else ()
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+
3552endif ()
3653
3754set (PLATFORM_SOURCE_FOLDER "src/platforms/${_plat_folder} " CACHE STRING "Path to the platform-specific sources" )
3855
56+
3957# Default memory regions
4058set (MEM_SPATZ_CLUSTER_DEFAULT_DRAM_HJSON_ORIGIN 0x80000000)
4159set (MEM_SPATZ_CLUSTER_DEFAULT_DRAM_HJSON_SIZE 0x80000000)
@@ -56,6 +74,16 @@ string(TOUPPER "${_key}" _key)
5674set (_orig_var "MEM_${_key} _ORIGIN" )
5775set (_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+
5987if (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