sw/kelvin: revamp layout to support setting model input data

Split the memory layout so there are two loadable elf segments. The second
segment is one page (4096 bytes) and holds the model_output_header and
a model_input region where the host can write input data that models
either copy into the TfLite input data area, or, for IEEE, are passed
in without copying.

The page size is chosen to satsify elf loadable segment alignment.

Models are expected to declare a model_input symbol with suitable size
(4096 - sizeof(model_output_header)).

Host support (e.g. MlCoordinator) expects this layout; it does not,
in particular deduce this from the contents of the elf file.

Change-Id: I34c3d6893dabbe067cf0b07e472c80e49a5652de
1 file changed
tree: c196336241c8acc7d8225fc23e5aaff5df1e7c9f
  1. build_tools/
  2. crt/
  3. docs/
  4. examples/
  5. host_tools/
  6. platforms/
  7. tests/
  8. tflm/
  9. third_party/
  10. toolchains/
  11. .bazelrc
  12. .bazelversion
  13. .gitignore
  14. CONTRIBUTING.md
  15. LICENSE
  16. PREUPLOAD.cfg
  17. README.md
  18. WORKSPACE
README.md

Kelvin SW Repository

This project contains the BSP to build the SW artifact that can run on the Kelvin core, and integrated as part of the Shodan repository.

The project supports two build systems -- Bazel and CMake -- for OSS integration reasons. Bazel is used by TFLM flow, while CMake is the build system for IREE.

Prerequisite

If you get this project from Project Shodan manifest, you are all set. If not, you need to have following projects as well to build the project successfully.

  • Kelvin crosscompile toolchain: Under <dir>/cache/toolchain_kelvin

This project needs to be at <dir>/sw/kelvin.

Code structure

  • build_tools: Build tool/rules for both Bazel and CMake
  • crt: Kelvin BSP
  • examples: Source code to build Kelvin SW artifacts.
  • host_tools: host tool to generate the intrinsic header and toolchain op files
  • platforms: Crosscompile platform setup for Bazel.
  • tests: Tests to exercise features of the Kelvin core.
  • tflm: Support code and optimized routines for TFLM.
  • third_party: Third party repositories for Bazel.
  • toolchains: Crosscomple toolchain setup for Bazel.

Build the project

Bazel

The project uses Bazel 5.1.1, to align with OpenTitan build system requirements.

bazel build //...

To run the unit tests (with the kelvin_sim ISS) Make sure the Environment variable $ROOTDIR is set to the root directory of the local repo (or run source build/setup.sh)

bazel test //...

CMake

TODO: Add CMake flow

Run the executable

The binaries can be simulated with the kelvin simulator, located at <dir>/sim/kelvin.

sim_kelvin <elf location>

Load the generated .bin binaries to the FPGA emulator/Renode simulator.