|
| 1 | +## Introduction |
| 2 | + |
| 3 | +### Nios® V/g TinyML LiteRT Example Design Overview |
| 4 | + |
| 5 | +This design demonstrates the TinyML application using LiteRT for microcontrollers software with Nios® V/g processor in the MAX® 10 FPGA 10M50 Evaluation Kit DK-DEV-10M50F484-B. |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | + - MAX® 10 FPGA 10M50 Evaluation Kit, ordering code DK-DEV-10M50F484-B. Refer to the board documentation for more information about the development kit. |
| 10 | + - Mini and Micro USB Cable. Included with the development kit. |
| 11 | + |
| 12 | +### Release Contents |
| 13 | + |
| 14 | +#### Binaries |
| 15 | + - Prebuilt binaries are located [here](https://github.com/altera-fpga/max10-ed-nios/tree/rel/24.1std/max10-10m50-evaluation-dev-kit/niosv_g/tinyml_liteRT/ready_to_test) |
| 16 | + - The sof and elf files required to run the design can be found in "ready_to_test" folder |
| 17 | + - Program the sof and download the elf file on board |
| 18 | + |
| 19 | +### Nios® V/g TinyML LiteRT Design Architecture |
| 20 | + This example design includes a Nios® V processor connected to the LPDDR2 external memory and JTAG UART IP. The objective of the design is to accomplish data transfer between the processor and soft IP peripherals. |
| 21 | + |
| 22 | +```mermaid |
| 23 | +--- |
| 24 | +title: Block Diagram |
| 25 | +--- |
| 26 | +
|
| 27 | +graph TD; |
| 28 | + A[Nios V/g Processor]; |
| 29 | + A <--> B(Bus Interface : AXI / AvMM Interface); |
| 30 | + B <--> C[LPDDR2 SDRAM Controller with UniPHY]; |
| 31 | + B <--> D[JTAG UART]; |
| 32 | +``` |
| 33 | + |
| 34 | +#### Nios® V/g Processor |
| 35 | +- Nios® V/g processor is highly customizable and can be tailored to meet specific application requirements, providing flexibility and scalability in embedded system designs. |
| 36 | + |
| 37 | + |
| 38 | +#### IP Cores |
| 39 | + The following IPs are used in this Platform Designer component of the design: |
| 40 | +- Nios® V/g soft processor core |
| 41 | + |
| 42 | +- LPDDR2 SDRAM Controller with UniPHY |
| 43 | + |
| 44 | +- JTAG UART |
| 45 | + |
| 46 | +- Clock Source, Reset Bridge |
| 47 | + |
| 48 | + |
| 49 | +### Hardware Setup |
| 50 | + |
| 51 | + Refer to [MAX® 10 FPGA 10M50 Evaluation Kit User Guide](https://www.intel.com/content/www/us/en/docs/programmable/683447/current/max-10-fpga-10m50-evaluation-kit-overview.html) to setup the hardware connection. |
| 52 | + |
| 53 | + |
| 54 | +### Address Map Details |
| 55 | + |
| 56 | +#### Nios V Address Map |
| 57 | + |Address Offset |Size (Bytes) |Peripheral | Description| |
| 58 | + |-|-|-|-| |
| 59 | + |0x0|128M|LPDDR2 Memory|To store application| |
| 60 | + |0x0803_0040|8|JTAG UART|Communication between a host PC and the Nios V processor system| |
| 61 | + |
| 62 | + |
| 63 | +## User Flow |
| 64 | + |
| 65 | + There are two ways to test the design based on use case. |
| 66 | + |
| 67 | + <h5> User Flow 1: Testing with Prebuild Binaries.</h5> |
| 68 | + |
| 69 | + <h5> User Flow 2: Testing Complete Flow.</h5> |
| 70 | + |
| 71 | + |User Flow|Description|Required for [User flow 1](#user-flow-1-testing-with-prebuild-binaries)|Required for [User flow 2](#user-flow-2-testing-complete-flow)| |
| 72 | + |-|-|-|-| |
| 73 | + |Environment Setup|[Tools Download and Installation](#tools-download)|Yes|Yes| |
| 74 | + |Compilation|Hardware compilation|No|Yes| |
| 75 | + ||Software compilation|No|Yes| |
| 76 | + |Programing|Program Hardware Binary SOF|Yes|Yes| |
| 77 | + ||Program Software Image ELF|Yes|Yes| |
| 78 | + |Testing|Open JTAG UART Terminal|Yes|Yes| |
| 79 | + |
| 80 | +### Environment Setup |
| 81 | + |
| 82 | +#### Tools Download and Installation |
| 83 | +1. Quartus Prime Standard |
| 84 | + |
| 85 | + - Download the Quartus® Prime Standard Edition software version 24.1 from the FPGA Software Download Center webpage of the Intel website. Follow the on-screen instructions to complete the installation process. Choose an installation directory that is relative to the Quartus® Prime Standard Edition software installation directory. |
| 86 | + - Set up the Quartus tools in the PATH, so they are accessible without full path. |
| 87 | +```console |
| 88 | +export QUARTUS_ROOTDIR=~/altera/24.1std/quartus/ |
| 89 | +export PATH=$QUARTUS_ROOTDIR/bin:$QUARTUS_ROOTDIR/linux64:$QUARTUS_ROOTDIR/../qsys/bin:$PATH |
| 90 | +``` |
| 91 | + |
| 92 | +### Compilation |
| 93 | + |
| 94 | +#### Hardware Compilation |
| 95 | + - Invoke the `quartus_py` shell in the terminal |
| 96 | + - Run the following command in the terminal from top level project directory: |
| 97 | + |
| 98 | +```console |
| 99 | +quartus_py ./scripts/build_sof.py |
| 100 | +``` |
| 101 | + |
| 102 | + - The quartus tool will compile the design and generate the output files |
| 103 | + |
| 104 | +#### Software Compilation |
| 105 | +- To create software app, run the following commands in the terminal: |
| 106 | +```console |
| 107 | +niosv-bsp -c --sopcinfo=hw/top.sopcinfo --type=hal --bsp-dir=sw/tflite_bsp --script=sw/bsp_script.tcl sw/tflite_bsp/settings.bsp |
| 108 | +niosv-app --bsp-dir=sw/tflite_bsp --app-dir=sw/tflite_app --srcs-recursive=sw/tflite_app/image_classification,sw/tflite_app/signal,sw/tflite_app/tensorflow --incs=sw/tflite_app,sw/tflite_app/image_classification/model,sw/tflite_app/image_classification/image,sw/tflite_app/tensorflow,sw/tflite_app/third_party/flatbuffers/include,sw/tflite_app/third_party/gemmlowp,sw/tflite_app/third_party/kissfft,sw/tflite_app/third_party/ruy |
| 109 | +cmake -S sw/tflite_app -B sw/tflite_app/build/Release -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release |
| 110 | +make -C sw/tflite_app/build/Release |
| 111 | +``` |
| 112 | +Note:The software can be compiled using the Ashling Visual Studio Code Extension for Altera FPGAs |
| 113 | + |
| 114 | +For information on the build process, please refer to the following document- [Ashling VSCode Extension](https://www.intel.com/content/www/us/en/docs/programmable/730783/current/ashling-visual-studio-code-extension.html) |
| 115 | + |
| 116 | +### Programing |
| 117 | +Note: Reduce the JTAG clock frequency to 6MHz using the following command, before programming the sof file |
| 118 | +```console |
| 119 | +jtagconfig --setparam 1 JtagClock 6M |
| 120 | +``` |
| 121 | + |
| 122 | +#### Program Hardware Binary SOF |
| 123 | +- Program the generated sof and then download the elf file on the board |
| 124 | + |
| 125 | +```console |
| 126 | +quartus_pgm --cable=1 -m jtag -o 'p;ready_to_test/top.sof' |
| 127 | +``` |
| 128 | + |
| 129 | +#### Program Software Image ELF |
| 130 | +- Download the elf file on the board |
| 131 | +```console |
| 132 | +niosv-download -g -r ready_to_test/tflite_app.elf -c 1 |
| 133 | +``` |
| 134 | + |
| 135 | +### Testing |
| 136 | + |
| 137 | +#### Open JTAG UART Terminal |
| 138 | +- Verify the output on the terminal by using the following command in the terminal: |
| 139 | + |
| 140 | +```console |
| 141 | +juart-terminal -c 1 -i 0 |
| 142 | +``` |
| 143 | + |
| 144 | + |
0 commit comments