diff options
-rw-r--r-- | README.md | 95 | ||||
-rw-r--r-- | docs/multinpu.puml | 82 | ||||
-rw-r--r-- | docs/multinpu.svg | 95 | ||||
-rw-r--r-- | docs/startup.puml | 71 | ||||
-rw-r--r-- | docs/startup.svg | 84 |
5 files changed, 427 insertions, 0 deletions
@@ -59,6 +59,101 @@ this. $ FVP_Corstone_SSE-300_Ethos-U55 applications/freertos/freertos.elf ``` +# Multi NPU + +The Tensorflow Lite for Microcontrollers (TFLu) framework supports running +multiple parallel inferences. Each parallel inference requires a TFLu arena +(costs memory) and a stack (requires an RTOS). The examples provided in this +repo are implemented in the application layer, which means that any RTOS could +be used. + +The Ethos-U NPU driver is implemented in plain C. To enable thread safety in a +multi-threading environment the driver defines a set of weak functions that the +application is expected to override, providing implementations for mutex and +semaphore primitives. + +The weak function can be found in +[ethosu_driver.c](https://git.mlplatform.org/ml/ethos-u/ethos-u-core-driver.git/tree/src/ethosu_driver.c?id=35b5d0eebf9709a3439d362a0b53d6270cbc4a94#n173). +An example based on FreeRTOS how to override and implement these functions can +be found in +[applications/freertos/main.cpp](https://git.mlplatform.org/ml/ethos-u/ethos-u-core-platform.git/tree/applications/freertos/main.cpp?id=991af2bd8fb6c79dfb317837353857f34a727b17#n108). + +The sequence diagram below illustrates the call stack for a multi NPU system. +Please note how the `ethosu_mutex_*` and `ethosu_semaphore_*` functions are +implemented in the application layer. Mutexes are used for thread safety and +semaphores for sleeping. + +![Multi NPU](docs/multinpu.svg "Multi NPU sequence diagram") + +## Tradeoffs + +A single Cortex-M is capable of driving multiple Ethos-U. What the optimal +number of Ethos-U is, that is impossible to tell without knowing which network +to run or without detailed knowledge about the limitations of the embedded +system. + +Each parallel inference requires an arena. The arena should for optimal +performance be placed in a high bandwidth low latency memory like SRAM, which is +a cost that has to be considered. The size of the arena varies greatly depending +on the network. + +For networks that map fully to Ethos-U, the memory bandwidth might become a +limiting factor. For networks that run partly in software, the Cortex-M might +become the limiting factor. The placement of the TFLu model and arena (flash, +DRAM, SRAM, etc) will also have a big impact on the performance. + +# Startup + +The applications in this repo use +[CMSIS Device](https://github.com/ARM-software/CMSIS_5/tree/develop/Device/) to +startup the Cortex-M. The standard procedure is to copy and modify the CMSIS +templates, but in this repo we have chosen to include the unmodified templates +directly from CMSIS. + +The sequence diagram below describes what happens after the Cortex-M reset is +lifted, up until the execution enters the application `main()`. + +![Startup](docs/startup.svg "Startup sequence diagram") + +## CMSIS Device + +First thing that happens is that the CPU loads index 0 from the interrupt vector +into the SP register and index 1 into the PC register, and then starts executing +from the PC location. + +Index 1 in the VTOR is referred to as the reset handler and is resposible for +initializing the CPU. If the CPU for example has a FPU or MVE extension, then +these are enabled. + +## Compiler runtime + +The entry function for the compiler runtime setup varies depending on which +compiler that is used. For Arm Clang this function is called `__main()`, not to +be confused with the application `main()`! + +The runtime is responsible for initializing the memory segments and setting up +the runtime environment. Please refer to the compiler documentation for detailed +information about the runtime setup. + +## Target + +The [`init()`](targets/common/src/init.cpp) is defined as a constructor, which +will be called before the application `main()`. We use this constructor to run +`targetSetup()` to initialize the platform. + +For each target there is a `targets/<target>` directory, which contains linker +scripts and code needed to setup the target. `targetSetup()` is implemented in +this folder and is responsible for initializing drivers, configuring the MPU, +enabling caches etc. + +Adding a new target would involve creating a new `targets/<target>` directory, +providing linker scripts and implementing `targetSetup()`. + +## Application + +Finally the runtime calls application `main()`. Ideally the application code +should be generic and have no knowledge about which target it is executing on. + # License The Arm Ethos-U core platform is provided under an Apache-2.0 license. Please diff --git a/docs/multinpu.puml b/docs/multinpu.puml new file mode 100644 index 0000000..e5248b1 --- /dev/null +++ b/docs/multinpu.puml @@ -0,0 +1,82 @@ +@startuml + +skinparam backgroundColor #EEEBDC + +box "Application" #00C1DE +participant "main()" as app +end box + +box "Tensorflow" #FF6B00 +participant "TFLu" as tflu +participant "Ethos-U custom op" as custom +end box + +box "Ethos-U driver" #95D600 +participant "Driver" as driver +end box + +box "Hardware" #FFC700 +participant "Cortex-M" as cortexm +participant "Ethos-U" as ethosu +end box + +app -> tflu++: Invoke() + tflu -> custom++: Eval() + custom -> driver++: ethosu_reserve_driver() + loop Find and reserve driver + driver -> app++: ethosu_mutex_lock() + return + + driver -> driver: ethosu_find_and_reserve_driver() + + driver -> app++: ethosu_mutex_unlock() + return + + alt Found free driver + note over driver + Return free driver + end note + else No driver available + driver -> app++: ethosu_semaphore_take() + note over app + Block on semaphore + end note + return + end + end loop + return + + custom -> driver++: ethosu_invoke() + driver -\\ ethosu: Configure NPU and trigger inference + + driver -> driver++: wait_for_irq() + note over driver + Driver sleeping waiting for IRQ + end note + + ethosu -\\ cortexm: IRQ + cortexm -\\ driver: ethosu_irq_handler() + + note over driver + Driver woken up by IRQ handler + end note + return + return + + custom -> driver++: ethosu_release_driver() + driver -> app++: ethosu_mutex_lock() + return + + driver -> app++: ethosu_semaphore_give() + note over app + Wake up threads blocking on the semaphore + end note + return + + driver -> app++: ethosu_mutex_unlock() + return + return + return +return + +@enduml diff --git a/docs/multinpu.svg b/docs/multinpu.svg new file mode 100644 index 0000000..bc3b6b0 --- /dev/null +++ b/docs/multinpu.svg @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="application/ecmascript" contentStyleType="text/css" height="1073px" preserveAspectRatio="none" style="width:958px;height:1073px;background:#EEEBDC;" version="1.1" viewBox="0 0 958 1073" width="958px" zoomAndPan="magnify"><defs><filter height="300%" id="f161eqf8p7fyeb" width="300%" x="-1" y="-1"><feGaussianBlur result="blurOut" stdDeviation="2.0"/><feColorMatrix in="blurOut" result="blurOut2" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"/><feOffset dx="4.0" dy="4.0" in="blurOut2" result="blurOut3"/><feBlend in="SourceGraphic" in2="blurOut3" mode="normal"/></filter></defs><g><rect fill="#00C1DE" height="1058.5859" style="stroke: #A80036; stroke-width: 1.0;" width="89" x="118" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="83" x="121" y="16.0669">Application</text><rect fill="#FF6B00" height="1058.5859" style="stroke: #A80036; stroke-width: 1.0;" width="220" x="218" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="80" x="288" y="16.0669">Tensorflow</text><rect fill="#95D600" height="1058.5859" style="stroke: #A80036; stroke-width: 1.0;" width="110" x="506.5" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="104" x="509.5" y="16.0669">Ethos-U driver</text><rect fill="#FFC700" height="1058.5859" style="stroke: #A80036; stroke-width: 1.0;" width="171" x="776.5" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="72" x="826" y="16.0669">Hardware</text><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="200.9609"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="286.2266"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="53.2656" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="407.4297"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="824.7578"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="53.2656" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="867.8906"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="950.1563"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="916.8594" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="242.5" y="89.4297"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="873.7266" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="353.5" y="118.5625"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="341" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="556.5" y="147.6953"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="248.9297" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="556.5" y="517.6953"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="161.6641" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="561.5" y="583.9609"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="182.6641" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="556.5" y="795.625"/><rect fill="#EEEBDC" filter="url(#f161eqf8p7fyeb)" height="312.8672" style="stroke: #000000; stroke-width: 2.0;" width="734.5" x="64" y="162.8281"/><rect fill="#EEEBDC" filter="url(#f161eqf8p7fyeb)" height="153.3359" style="stroke: #000000; stroke-width: 2.0;" width="565" x="74" y="315.3594"/><rect fill="#EEEBDC" height="97.0703" style="stroke: none; stroke-width: 1.0;" width="565" x="74" y="371.625"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="162" x2="162" y1="58.4297" y2="1024.2891"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="247" x2="247" y1="58.4297" y2="1024.2891"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="358" x2="358" y1="58.4297" y2="1024.2891"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="561.5" x2="561.5" y1="58.4297" y2="1024.2891"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="820.5" x2="820.5" y1="58.4297" y2="1024.2891"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="906.5" x2="906.5" y1="58.4297" y2="1024.2891"/><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="57" x="132" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="43" x="139" y="43.1279">main()</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="57" x="132" y="1023.2891"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="43" x="139" y="1043.2842">main()</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="47" x="222" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="33" x="229" y="43.1279">TFLu</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="47" x="222" y="1023.2891"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="33" x="229" y="1043.2842">TFLu</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="147" x="283" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="133" x="290" y="43.1279">Ethos-U custom op</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="147" x="283" y="1023.2891"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="133" x="290" y="1043.2842">Ethos-U custom op</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="54" x="532.5" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="40" x="539.5" y="43.1279">Driver</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="54" x="532.5" y="1023.2891"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="40" x="539.5" y="1043.2842">Driver</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="76" x="780.5" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="62" x="787.5" y="43.1279">Cortex-M</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="76" x="780.5" y="1023.2891"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="62" x="787.5" y="1043.2842">Cortex-M</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="69" x="870.5" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="55" x="877.5" y="43.1279">Ethos-U</text><rect fill="#FEFECE" filter="url(#f161eqf8p7fyeb)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="69" x="870.5" y="1023.2891"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="55" x="877.5" y="1043.2842">Ethos-U</text><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="200.9609"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="286.2266"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="53.2656" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="407.4297"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="824.7578"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="53.2656" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="867.8906"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="157.5" y="950.1563"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="916.8594" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="242.5" y="89.4297"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="873.7266" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="353.5" y="118.5625"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="341" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="556.5" y="147.6953"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="248.9297" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="556.5" y="517.6953"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="161.6641" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="561.5" y="583.9609"/><rect fill="#FFFFFF" filter="url(#f161eqf8p7fyeb)" height="182.6641" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="556.5" y="795.625"/><polygon fill="#A80036" points="230.5,85.4297,240.5,89.4297,230.5,93.4297,234.5,89.4297" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="162.5" x2="236.5" y1="89.4297" y2="89.4297"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="51" x="169.5" y="84.4966">Invoke()</text><polygon fill="#A80036" points="341.5,114.5625,351.5,118.5625,341.5,122.5625,345.5,118.5625" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="252.5" x2="347.5" y1="118.5625" y2="118.5625"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="36" x="259.5" y="113.6294">Eval()</text><polygon fill="#A80036" points="544.5,143.6953,554.5,147.6953,544.5,151.6953,548.5,147.6953" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="363.5" x2="550.5" y1="147.6953" y2="147.6953"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="152" x="370.5" y="142.7622">ethosu_reserve_driver()</text><rect fill="none" height="312.8672" style="stroke: #000000; stroke-width: 2.0;" width="734.5" x="64" y="162.8281"/><polygon fill="#EEEEEE" points="64,162.8281,141,162.8281,141,169.8281,131,179.8281,64,179.8281,64,162.8281" style="stroke: #000000; stroke-width: 2.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="32" x="79" y="175.895">loop</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="159" x="156" y="175.0386">[Find and reserve driver]</text><polygon fill="#A80036" points="178.5,196.9609,168.5,200.9609,178.5,204.9609,174.5,200.9609" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="172.5" x2="555.5" y1="200.9609" y2="200.9609"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="134" x="184.5" y="196.0278">ethosu_mutex_lock()</text><polygon fill="#A80036" points="544.5,211.0938,554.5,215.0938,544.5,219.0938,548.5,215.0938" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="162.5" x2="550.5" y1="215.0938" y2="215.0938"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="566.5" x2="608.5" y1="244.2266" y2="244.2266"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="608.5" x2="608.5" y1="244.2266" y2="257.2266"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="567.5" x2="608.5" y1="257.2266" y2="257.2266"/><polygon fill="#A80036" points="577.5,253.2266,567.5,257.2266,577.5,261.2266,573.5,257.2266" style="stroke: #A80036; stroke-width: 1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="213" x="573.5" y="239.1606">ethosu_find_and_reserve_driver()</text><polygon fill="#A80036" points="178.5,282.2266,168.5,286.2266,178.5,290.2266,174.5,286.2266" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="172.5" x2="555.5" y1="286.2266" y2="286.2266"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="150" x="184.5" y="281.2935">ethosu_mutex_unlock()</text><polygon fill="#A80036" points="544.5,296.3594,554.5,300.3594,544.5,304.3594,548.5,300.3594" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="162.5" x2="550.5" y1="300.3594" y2="300.3594"/><rect fill="none" height="153.3359" style="stroke: #000000; stroke-width: 2.0;" width="565" x="74" y="315.3594"/><polygon fill="#EEEEEE" points="74,315.3594,138,315.3594,138,322.3594,128,332.3594,74,332.3594,74,315.3594" style="stroke: #000000; stroke-width: 2.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="19" x="89" y="328.4263">alt</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="121" x="153" y="327.5698">[Found free driver]</text><polygon fill="#FBFB77" filter="url(#f161eqf8p7fyeb)" points="493,337.4922,493,362.4922,625,362.4922,625,347.4922,615,337.4922,493,337.4922" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="615" x2="615" y1="337.4922" y2="347.4922"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="625" x2="615" y1="347.4922" y2="347.4922"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="111" x="499" y="354.5591">Return free driver</text><line style="stroke: #000000; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="74" x2="639" y1="372.625" y2="372.625"/><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="131" x="79" y="382.8354">[No driver available]</text><polygon fill="#A80036" points="178.5,403.4297,168.5,407.4297,178.5,411.4297,174.5,407.4297" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="172.5" x2="555.5" y1="407.4297" y2="407.4297"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="169" x="184.5" y="402.4966">ethosu_semaphore_take()</text><polygon fill="#FBFB77" filter="url(#f161eqf8p7fyeb)" points="84,420.5625,84,445.5625,236,445.5625,236,430.5625,226,420.5625,84,420.5625" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="226" x2="226" y1="420.5625" y2="430.5625"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="236" x2="226" y1="430.5625" y2="430.5625"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="131" x="90" y="437.6294">Block on semaphore</text><polygon fill="#A80036" points="544.5,456.6953,554.5,460.6953,544.5,464.6953,548.5,460.6953" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="162.5" x2="550.5" y1="460.6953" y2="460.6953"/><polygon fill="#A80036" points="374.5,484.6953,364.5,488.6953,374.5,492.6953,370.5,488.6953" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="368.5" x2="560.5" y1="488.6953" y2="488.6953"/><polygon fill="#A80036" points="544.5,513.6953,554.5,517.6953,544.5,521.6953,548.5,517.6953" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="363.5" x2="550.5" y1="517.6953" y2="517.6953"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="102" x="370.5" y="512.7622">ethosu_invoke()</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="905" x2="895" y1="546.8281" y2="542.8281"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="566.5" x2="906" y1="546.8281" y2="546.8281"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="230" x="573.5" y="541.895">Configure NPU and trigger inference</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="566.5" x2="613.5" y1="571.0938" y2="571.0938"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="613.5" x2="613.5" y1="571.0938" y2="584.0938"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="572.5" x2="613.5" y1="584.0938" y2="584.0938"/><polygon fill="#A80036" points="582.5,580.0938,572.5,584.0938,582.5,588.0938,578.5,584.0938" style="stroke: #A80036; stroke-width: 1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="82" x="578.5" y="566.0278">wait_for_irq()</text><polygon fill="#FBFB77" filter="url(#f161eqf8p7fyeb)" points="454,602.0938,454,627.0938,664,627.0938,664,612.0938,654,602.0938,454,602.0938" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="654" x2="654" y1="602.0938" y2="612.0938"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="664" x2="654" y1="612.0938" y2="612.0938"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="189" x="460" y="619.1606">Driver sleeping waiting for IRQ</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="820.5" x2="830.5" y1="657.2266" y2="653.2266"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="820.5" x2="906" y1="657.2266" y2="657.2266"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="21" x="837.5" y="652.2935">IRQ</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="571.5" x2="581.5" y1="686.3594" y2="682.3594"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="571.5" x2="819.5" y1="686.3594" y2="686.3594"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="132" x="588.5" y="681.4263">ethosu_irq_handler()</text><polygon fill="#FBFB77" filter="url(#f161eqf8p7fyeb)" points="450,699.4922,450,724.4922,669,724.4922,669,709.4922,659,699.4922,450,699.4922" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="659" x2="659" y1="699.4922" y2="709.4922"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="669" x2="659" y1="709.4922" y2="709.4922"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="198" x="456" y="716.5591">Driver woken up by IRQ handler</text><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="571.5" x2="613.5" y1="744.625" y2="744.625"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="613.5" x2="613.5" y1="744.625" y2="757.625"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="566.5" x2="613.5" y1="757.625" y2="757.625"/><polygon fill="#A80036" points="576.5,753.625,566.5,757.625,576.5,761.625,572.5,757.625" style="stroke: #A80036; stroke-width: 1.0;"/><polygon fill="#A80036" points="374.5,762.625,364.5,766.625,374.5,770.625,370.5,766.625" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="368.5" x2="560.5" y1="766.625" y2="766.625"/><polygon fill="#A80036" points="544.5,791.625,554.5,795.625,544.5,799.625,548.5,795.625" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="363.5" x2="550.5" y1="795.625" y2="795.625"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="151" x="370.5" y="790.6919">ethosu_release_driver()</text><polygon fill="#A80036" points="178.5,820.7578,168.5,824.7578,178.5,828.7578,174.5,824.7578" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="172.5" x2="555.5" y1="824.7578" y2="824.7578"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="134" x="184.5" y="819.8247">ethosu_mutex_lock()</text><polygon fill="#A80036" points="544.5,834.8906,554.5,838.8906,544.5,842.8906,548.5,838.8906" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="162.5" x2="550.5" y1="838.8906" y2="838.8906"/><polygon fill="#A80036" points="178.5,863.8906,168.5,867.8906,178.5,871.8906,174.5,867.8906" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="172.5" x2="555.5" y1="867.8906" y2="867.8906"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="167" x="184.5" y="862.9575">ethosu_semaphore_give()</text><polygon fill="#FBFB77" filter="url(#f161eqf8p7fyeb)" points="8,881.0234,8,906.0234,314,906.0234,314,891.0234,304,881.0234,8,881.0234" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="304" x2="304" y1="881.0234" y2="891.0234"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="314" x2="304" y1="891.0234" y2="891.0234"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="285" x="14" y="898.0903">Wake up threads blocking on the semaphore</text><polygon fill="#A80036" points="544.5,917.1563,554.5,921.1563,544.5,925.1563,548.5,921.1563" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="162.5" x2="550.5" y1="921.1563" y2="921.1563"/><polygon fill="#A80036" points="178.5,946.1563,168.5,950.1563,178.5,954.1563,174.5,950.1563" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="172.5" x2="555.5" y1="950.1563" y2="950.1563"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="150" x="184.5" y="945.2231">ethosu_mutex_unlock()</text><polygon fill="#A80036" points="544.5,960.2891,554.5,964.2891,544.5,968.2891,548.5,964.2891" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="162.5" x2="550.5" y1="964.2891" y2="964.2891"/><polygon fill="#A80036" points="374.5,974.2891,364.5,978.2891,374.5,982.2891,370.5,978.2891" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="368.5" x2="560.5" y1="978.2891" y2="978.2891"/><polygon fill="#A80036" points="263.5,988.2891,253.5,992.2891,263.5,996.2891,259.5,992.2891" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="257.5" x2="357.5" y1="992.2891" y2="992.2891"/><polygon fill="#A80036" points="173.5,1002.2891,163.5,1006.2891,173.5,1010.2891,169.5,1006.2891" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="167.5" x2="246.5" y1="1006.2891" y2="1006.2891"/><!-- +@startuml
+
+skinparam backgroundColor #EEEBDC
+
+box "Application" #00C1DE
+participant "main()" as app
+end box
+
+box "Tensorflow" #FF6B00
+participant "TFLu" as tflu
+participant "Ethos-U custom op" as custom
+end box
+
+box "Ethos-U driver" #95D600
+participant "Driver" as driver
+end box
+
+box "Hardware" #FFC700
+participant "Cortex-M" as cortexm
+participant "Ethos-U" as ethosu
+end box
+
+app -> tflu++: Invoke()
+ tflu -> custom++: Eval()
+ custom -> driver++: ethosu_reserve_driver()
+ loop Find and reserve driver
+ driver -> app++: ethosu_mutex_lock()
+ return
+
+ driver -> driver: ethosu_find_and_reserve_driver()
+
+ driver -> app++: ethosu_mutex_unlock()
+ return
+
+ alt Found free driver
+ note over driver
+ Return free driver
+ end note
+ else No driver available
+ driver -> app++: ethosu_semaphore_take()
+ note over app
+ Block on semaphore
+ end note
+ return
+ end
+ end loop
+ return
+
+ custom -> driver++: ethosu_invoke()
+ driver -\\ ethosu: Configure NPU and trigger inference
+
+ driver -> driver++: wait_for_irq()
+ note over driver
+ Driver sleeping waiting for IRQ
+ end note
+
+ ethosu -\\ cortexm: IRQ
+ cortexm -\\ driver: ethosu_irq_handler()
+
+ note over driver
+ Driver woken up by IRQ handler
+ end note
+ return
+ return
+
+ custom -> driver++: ethosu_release_driver()
+ driver -> app++: ethosu_mutex_lock()
+ return
+
+ driver -> app++: ethosu_semaphore_give()
+ note over app
+ Wake up threads blocking on the semaphore
+ end note
+ return
+
+ driver -> app++: ethosu_mutex_unlock()
+ return
+ return
+ return
+return
+
+@enduml
+ +PlantUML version 1.2017.15(Mon Jul 03 18:45:34 CEST 2017) +(GPL source distribution) +Java Runtime: OpenJDK Runtime Environment +JVM: OpenJDK 64-Bit Server VM +Java Version: 11.0.10+9-Ubuntu-0ubuntu1.18.04 +Operating System: Linux +OS Version: 5.4.0-70-generic +Default Encoding: UTF-8 +Language: en +Country: US +--></g></svg>
\ No newline at end of file diff --git a/docs/startup.puml b/docs/startup.puml new file mode 100644 index 0000000..f9cb528 --- /dev/null +++ b/docs/startup.puml @@ -0,0 +1,71 @@ +@startuml + +skinparam backgroundColor #EEEBDC + +box "Hardware" #FFC700 +participant "Cortex-M" as cortexm +participant "Ethos-U" as ethosu +end box + +box "CMSIS Device" #0091BD +participant "__VECTOR_TABLE" as ivec +participant "Reset_Handler()" as reset +end box + +box "Compiler" #FF6B00 +participant "Runtime" as runtime +end box + +box "Target" #95D600 +participant "common" as common +participant "corstone-300" as target +end box + +box "Drivers" #00C1DE +participant "NPU" as driver +participant "UART" as uart +participant "MPU" as mpu +end box + +box "Application" #7D868C +participant "main()" as main +end box + +cortexm -> ivec++: + ivec -> reset++: Reset_Handler() + reset -> reset++: SystemInit() + deactivate reset + + reset -> runtime++: __main() + note over runtime + Scatter loading + Initializing stack and heap + end note + + note over runtime + Calling constructors + end note + + runtime -> common++: init() [constructor] + note over common + The constructor is called after stack and heap have been initialized, + but before the main() function is called + end note + + common -> target++: targetSetup() + target -> uart++: uart_init() + return + + target -> driver++: ethosu_init() + return + + target -> mpu++: loadAndEnableConfig() + return + return + return + + runtime -> main++: main() + note over main + Running application + end note +@enduml diff --git a/docs/startup.svg b/docs/startup.svg new file mode 100644 index 0000000..a2c9f52 --- /dev/null +++ b/docs/startup.svg @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="application/ecmascript" contentStyleType="text/css" height="703px" preserveAspectRatio="none" style="width:1160px;height:703px;background:#EEEBDC;" version="1.1" viewBox="0 0 1160 703" width="1160px" zoomAndPan="magnify"><defs><filter height="300%" id="f1tn0zpyov876x" width="300%" x="-1" y="-1"><feGaussianBlur result="blurOut" stdDeviation="2.0"/><feColorMatrix in="blurOut" result="blurOut2" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"/><feOffset dx="4.0" dy="4.0" in="blurOut2" result="blurOut3"/><feBlend in="SourceGraphic" in2="blurOut3" mode="normal"/></filter></defs><g><rect fill="#FFC700" height="688.7188" style="stroke: #A80036; stroke-width: 1.0;" width="171" x="4" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="72" x="53.5" y="16.0669">Hardware</text><rect fill="#0091BD" height="688.7188" style="stroke: #A80036; stroke-width: 1.0;" width="288" x="177" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="99" x="271.5" y="16.0669">CMSIS Device</text><rect fill="#FF6B00" height="688.7188" style="stroke: #A80036; stroke-width: 1.0;" width="84" x="467" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="66" x="476" y="16.0669">Compiler</text><rect fill="#95D600" height="688.7188" style="stroke: #A80036; stroke-width: 1.0;" width="219.5" x="610.5" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="48" x="696.25" y="16.0669">Target</text><rect fill="#00C1DE" height="688.7188" style="stroke: #A80036; stroke-width: 1.0;" width="180" x="851.5" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="52" x="915.5" y="16.0669">Drivers</text><rect fill="#7D868C" height="688.7188" style="stroke: #A80036; stroke-width: 1.0;" width="89" x="1033.5" y="4"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="83" x="1036.5" y="16.0669">Application</text><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="570.9922" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="246.5" y="74.4297"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="541.9922" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="391.5" y="103.4297"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="28" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="396.5" y="140.5625"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="440.7266" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="504" y="204.6953"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="240.9297" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="649" y="327.2266"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="143.5313" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="765" y="410.625"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="874" y="482.8906"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="935.5" y="439.7578"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="998" y="526.0234"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="48.2656" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="1073" y="597.1563"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="48" x2="48" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="134" x2="134" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="251" x2="251" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="396" x2="396" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="509" x2="509" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="653.5" x2="653.5" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="770" x2="770" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="878.5" x2="878.5" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="940.5" x2="940.5" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="1002.5" x2="1002.5" y1="58.4297" y2="654.4219"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="1077.5" x2="1077.5" y1="58.4297" y2="654.4219"/><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="76" x="8" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="62" x="15" y="43.1279">Cortex-M</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="76" x="8" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="62" x="15" y="673.417">Cortex-M</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="69" x="98" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="55" x="105" y="43.1279">Ethos-U</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="69" x="98" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="55" x="105" y="673.417">Ethos-U</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="137" x="181" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="123" x="188" y="43.1279">__VECTOR_TABLE</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="137" x="181" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="123" x="188" y="673.417">__VECTOR_TABLE</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="125" x="332" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="111" x="339" y="43.1279">Reset_Handler()</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="125" x="332" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="111" x="339" y="673.417">Reset_Handler()</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="72" x="471" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="58" x="478" y="43.1279">Runtime</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="72" x="471" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="58" x="478" y="673.417">Runtime</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="75" x="614.5" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="61" x="621.5" y="43.1279">common</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="75" x="614.5" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="61" x="621.5" y="673.417">common</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="108" x="714" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="94" x="721" y="43.1279">corstone-300</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="108" x="714" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="94" x="721" y="673.417">corstone-300</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="43" x="855.5" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="29" x="862.5" y="43.1279">NPU</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="43" x="855.5" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="29" x="862.5" y="673.417">NPU</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="52" x="912.5" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="38" x="919.5" y="43.1279">UART</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="52" x="912.5" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="38" x="919.5" y="673.417">UART</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="45" x="978.5" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="31" x="985.5" y="43.1279">MPU</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="45" x="978.5" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="31" x="985.5" y="673.417">MPU</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="57" x="1047.5" y="23.1328"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="43" x="1054.5" y="43.1279">main()</text><rect fill="#FEFECE" filter="url(#f1tn0zpyov876x)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="57" x="1047.5" y="653.4219"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="43" x="1054.5" y="673.417">main()</text><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="570.9922" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="246.5" y="74.4297"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="541.9922" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="391.5" y="103.4297"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="28" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="396.5" y="140.5625"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="440.7266" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="504" y="204.6953"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="240.9297" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="649" y="327.2266"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="143.5313" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="765" y="410.625"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="874" y="482.8906"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="935.5" y="439.7578"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="14.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="998" y="526.0234"/><rect fill="#FFFFFF" filter="url(#f1tn0zpyov876x)" height="48.2656" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="1073" y="597.1563"/><polygon fill="#A80036" points="234.5,70.4297,244.5,74.4297,234.5,78.4297,238.5,74.4297" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="48" x2="240.5" y1="74.4297" y2="74.4297"/><polygon fill="#A80036" points="379.5,99.4297,389.5,103.4297,379.5,107.4297,383.5,103.4297" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="256.5" x2="385.5" y1="103.4297" y2="103.4297"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="103" x="263.5" y="98.4966">Reset_Handler()</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="406.5" x2="448.5" y1="132.6953" y2="132.6953"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="448.5" x2="448.5" y1="132.6953" y2="145.6953"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="407.5" x2="448.5" y1="145.6953" y2="145.6953"/><polygon fill="#A80036" points="417.5,141.6953,407.5,145.6953,417.5,149.6953,413.5,145.6953" style="stroke: #A80036; stroke-width: 1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="78" x="413.5" y="127.6294">SystemInit()</text><polygon fill="#A80036" points="492,200.6953,502,204.6953,492,208.6953,496,204.6953" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="401.5" x2="498" y1="204.6953" y2="204.6953"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="56" x="408.5" y="199.7622">__main()</text><polygon fill="#FBFB77" filter="url(#f1tn0zpyov876x)" points="414,217.8281,414,257.8281,599,257.8281,599,227.8281,589,217.8281,414,217.8281" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="589" x2="589" y1="217.8281" y2="227.8281"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="599" x2="589" y1="227.8281" y2="227.8281"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="97" x="420" y="234.895">Scatter loading</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="164" x="420" y="250.0278">Initializing stack and heap</text><polygon fill="#FBFB77" filter="url(#f1tn0zpyov876x)" points="433,272.0938,433,297.0938,580,297.0938,580,282.0938,570,272.0938,433,272.0938" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="570" x2="570" y1="272.0938" y2="282.0938"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="580" x2="570" y1="282.0938" y2="282.0938"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="126" x="439" y="289.1606">Calling constructors</text><polygon fill="#A80036" points="637,323.2266,647,327.2266,637,331.2266,641,327.2266" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="514" x2="643" y1="327.2266" y2="327.2266"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="116" x="521" y="322.2935">init() [constructor]</text><polygon fill="#FBFB77" filter="url(#f1tn0zpyov876x)" points="427,340.3594,427,380.3594,877,380.3594,877,350.3594,867,340.3594,427,340.3594" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="867" x2="867" y1="340.3594" y2="350.3594"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="877" x2="867" y1="350.3594" y2="350.3594"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="429" x="433" y="357.4263">The constructor is called after stack and heap have been initialized,</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="247" x="433" y="372.5591">but before the main() function is called</text><polygon fill="#A80036" points="753,406.625,763,410.625,753,414.625,757,410.625" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="659" x2="759" y1="410.625" y2="410.625"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="87" x="666" y="405.6919">targetSetup()</text><polygon fill="#A80036" points="923.5,435.7578,933.5,439.7578,923.5,443.7578,927.5,439.7578" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="775" x2="929.5" y1="439.7578" y2="439.7578"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="62" x="782" y="434.8247">uart_init()</text><polygon fill="#A80036" points="786,449.8906,776,453.8906,786,457.8906,782,453.8906" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="780" x2="939.5" y1="453.8906" y2="453.8906"/><polygon fill="#A80036" points="862,478.8906,872,482.8906,862,486.8906,866,482.8906" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="775" x2="868" y1="482.8906" y2="482.8906"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="80" x="782" y="477.9575">ethosu_init()</text><polygon fill="#A80036" points="786,493.0234,776,497.0234,786,501.0234,782,497.0234" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="780" x2="878" y1="497.0234" y2="497.0234"/><polygon fill="#A80036" points="986,522.0234,996,526.0234,986,530.0234,990,526.0234" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="775" x2="992" y1="526.0234" y2="526.0234"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="145" x="782" y="521.0903">loadAndEnableConfig()</text><polygon fill="#A80036" points="786,536.1563,776,540.1563,786,544.1563,782,540.1563" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="780" x2="1002" y1="540.1563" y2="540.1563"/><polygon fill="#A80036" points="670,550.1563,660,554.1563,670,558.1563,666,554.1563" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="664" x2="769" y1="554.1563" y2="554.1563"/><polygon fill="#A80036" points="525,564.1563,515,568.1563,525,572.1563,521,568.1563" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;" x1="519" x2="653" y1="568.1563" y2="568.1563"/><polygon fill="#A80036" points="1061,593.1563,1071,597.1563,1061,601.1563,1065,597.1563" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="514" x2="1067" y1="597.1563" y2="597.1563"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="42" x="521" y="592.2231">main()</text><polygon fill="#FBFB77" filter="url(#f1tn0zpyov876x)" points="1003,610.2891,1003,635.2891,1148,635.2891,1148,620.2891,1138,610.2891,1003,610.2891" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="1138" x2="1138" y1="610.2891" y2="620.2891"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="1148" x2="1138" y1="620.2891" y2="620.2891"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="124" x="1009" y="627.356">Running application</text><!-- +@startuml
+
+skinparam backgroundColor #EEEBDC
+
+box "Hardware" #FFC700
+participant "Cortex-M" as cortexm
+participant "Ethos-U" as ethosu
+end box
+
+box "CMSIS Device" #0091BD
+participant "__VECTOR_TABLE" as ivec
+participant "Reset_Handler()" as reset
+end box
+
+box "Compiler" #FF6B00
+participant "Runtime" as runtime
+end box
+
+box "Target" #95D600
+participant "common" as common
+participant "corstone-300" as target
+end box
+
+box "Drivers" #00C1DE
+participant "NPU" as driver
+participant "UART" as uart
+participant "MPU" as mpu
+end box
+
+box "Application" #7D868C
+participant "main()" as main
+end box
+
+cortexm -> ivec++:
+ ivec -> reset++: Reset_Handler()
+ reset -> reset++: SystemInit()
+ deactivate reset
+
+ reset -> runtime++: __main()
+ note over runtime
+ Scatter loading
+ Initializing stack and heap
+ end note
+
+ note over runtime
+ Calling constructors
+ end note
+
+ runtime -> common++: init() [constructor]
+ note over common
+ The constructor is called after stack and heap have been initialized,
+ but before the main() function is called
+ end note
+
+ common -> target++: targetSetup()
+ target -> uart++: uart_init()
+ return
+
+ target -> driver++: ethosu_init()
+ return
+
+ target -> mpu++: loadAndEnableConfig()
+ return
+ return
+ return
+
+ runtime -> main++: main()
+ note over main
+ Running application
+ end note
+@enduml
+ +PlantUML version 1.2017.15(Mon Jul 03 18:45:34 CEST 2017) +(GPL source distribution) +Java Runtime: OpenJDK Runtime Environment +JVM: OpenJDK 64-Bit Server VM +Java Version: 11.0.10+9-Ubuntu-0ubuntu1.18.04 +Operating System: Linux +OS Version: 5.4.0-70-generic +Default Encoding: UTF-8 +Language: en +Country: US +--></g></svg>
\ No newline at end of file |