@@ -221,6 +221,7 @@ elseif(SYSTEM_CONFIG STREQUAL "Ethos_U55_Deep_Embedded")
221221 )
222222 elseif (MEMORY_MODE STREQUAL "Sram_Only" )
223223 target_compile_definitions (ethosu_target_common INTERFACE
224+ ETHOSU_MODEL=1
224225 # Configure NPU architecture timing adapters
225226 # This is just example numbers and you should make this match your hardware
226227 # SRAM
@@ -411,6 +412,53 @@ else()
411412 message (FATAL_ERROR "Unsupported SYSTEM_CONFIG: ${SYSTEM_CONFIG} " )
412413endif ()
413414
415+ # The REGIONCFG registers of the Ethos-U control whether the NPU
416+ # reads/writes data through the SRAM or the external memory.
417+ # By default, the Ethos-U driver provides REGIONCFG configuration for Shared Sram memory mode.
418+ # For Sram_Only and Dedicated_Sram memory modes, we need to change the settings for optimal performance.
419+ #
420+ # Currently, the convention used by Vela and the Ethos-U driver is that the NPU uses:
421+ # Region 0 for traffic of the Read-Only data(weights & biases)
422+ # Region 1 for traffic of of the intermediate Read/Write buffers required for the computation
423+ # Region 2 for traffic of of the cache in Dedicated_Sram memory mode(not applicable in Sram_Only or Shared_Sram)
424+ #
425+ # NOTE: The above convention is determined by the Vela compiler and the Ethos-U driver and can change in the future.
426+ #
427+ # Common definitions:
428+ # For Ethos-U55/U65/U85, region configs are set as:
429+ # 0 or 1 = AXI0 (Ethos-U55 or Ethos-U65) or AXI_SRAM(Ethos-U85)
430+ # 2 or 3 = AXI1 (Ethos-U55 or Ethos-U65) or AXI_EXT(Ethos-U85)
431+ #
432+ # When we compile a model for Sram_Only, the memory traffic for Region 0 and Region 1 should pass via the SRAM(hence regioncfg = 1)
433+ # When we compile a model for Dedicated_Sram, the memory traffic for Region 0 should pass via the external memory(3),
434+ # the memory traffic of Region 1 should pass via the external memory(3) and the traffic for Region 2 should pass via the SRAM(0)
435+ #
436+
437+ if (MEMORY_MODE STREQUAL "Sram_Only" )
438+ target_compile_definitions (ethosu_core_driver PRIVATE
439+ NPU_QCONFIG=1
440+ NPU_REGIONCFG_0=1
441+ NPU_REGIONCFG_1=0
442+ NPU_REGIONCFG_2=0
443+ NPU_REGIONCFG_3=0
444+ NPU_REGIONCFG_4=0
445+ NPU_REGIONCFG_5=0
446+ NPU_REGIONCFG_6=0
447+ NPU_REGIONCFG_7=0)
448+ elseif (MEMORY_MODE STREQUAL "Dedicated_Sram" )
449+ target_compile_definitions (ethosu_core_driver PRIVATE
450+ NPU_QCONFIG=3
451+ NPU_REGIONCFG_0=3
452+ NPU_REGIONCFG_1=3
453+ NPU_REGIONCFG_2=0
454+ NPU_REGIONCFG_3=0
455+ NPU_REGIONCFG_4=0
456+ NPU_REGIONCFG_5=0
457+ NPU_REGIONCFG_6=0
458+ NPU_REGIONCFG_7=0)
459+ endif ()
460+
461+
414462# Dependencies from the ExecuTorch build
415463add_library (executorch STATIC IMPORTED )
416464set_property (
0 commit comments