Merge "Kelvin vld ISA test."
diff --git a/.bazelrc b/.bazelrc
index 741adf4..5dd1c3b 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -7,6 +7,9 @@
build:kelvin --platforms=//platforms/riscv32:kelvin
+# Test environment variable for kelvin_sim test_runner.sh
+test --test_env=ROOTDIR
+
# Set preprocessor defines for tflite-micro.
build --copt=-DTF_LITE_USE_GLOBAL_CMATH_FUNCTIONS
build --copt=-DTF_LITE_USE_GLOBAL_MIN
diff --git a/README.md b/README.md
index 299d223..35f2db5 100644
--- a/README.md
+++ b/README.md
@@ -40,9 +40,11 @@
```
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`)
```bash
-bazel test --test_env=ROOTDIR=${ROOTDIR} //...
+bazel test //...
```
### CMake
diff --git a/build_tools/bazel/repos.bzl b/build_tools/bazel/repos.bzl
index 7579eda..d6e4ded 100644
--- a/build_tools/bazel/repos.bzl
+++ b/build_tools/bazel/repos.bzl
@@ -42,41 +42,6 @@
maybe(
http_archive,
- name = "gemmlowp",
- sha256 = "43146e6f56cb5218a8caaab6b5d1601a083f1f31c06ff474a4378a7d35be9cfb", # SHARED_GEMMLOWP_SHA
- strip_prefix = "gemmlowp-fda83bdc38b118cc6b56753bd540caa49e570745",
- urls = [
- "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/gemmlowp/archive/fda83bdc38b118cc6b56753bd540caa49e570745.zip",
- "https://github.com/google/gemmlowp/archive/fda83bdc38b118cc6b56753bd540caa49e570745.zip",
- ],
- patches = [
- "@kelvin_sw//third_party/gemmlowp:pthread.patch",
- ],
- patch_args = [
- "-p1",
- ],
- )
-
- maybe(
- http_archive,
- name = "ruy",
- sha256 = "da5ec0cc07472bdb21589b0b51c8f3d7f75d2ed6230b794912adf213838d289a",
- strip_prefix = "ruy-54774a7a2cf85963777289193629d4bd42de4a59",
- urls = [
- "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/ruy/archive/54774a7a2cf85963777289193629d4bd42de4a59.zip",
- "https://github.com/google/ruy/archive/54774a7a2cf85963777289193629d4bd42de4a59.zip",
- ],
- build_file = "@tflite-micro//third_party/ruy:BUILD",
- patches = [
- "@kelvin_sw//third_party/ruy:pthread.patch",
- ],
- patch_args = [
- "-p1",
- ],
- )
-
- maybe(
- http_archive,
name = "rules_python",
sha256 = "497ca47374f48c8b067d786b512ac10a276211810f4a580178ee9b9ad139323a",
strip_prefix = "rules_python-0.16.1",
diff --git a/crt/kelvin_start.S b/crt/kelvin_start.S
index 3e2bae3..cd2496f 100644
--- a/crt/kelvin_start.S
+++ b/crt/kelvin_start.S
@@ -64,6 +64,13 @@
bltu s0, s1, init_array_loop
init_array_loop_end:
+ # Set up sentinel value in _ret
+ # If we see this after an ebreak,
+ # the break source is unlikely to
+ # be a clean return from main.
+ la t0, _ret
+ li a0, 0x0badd00d
+ sw a0, 0(t0)
#############
# Call main #
@@ -75,6 +82,11 @@
# Store the application's return value at _ret
la t0, _ret
sw a0, 0(t0)
+ beqz a0, success
+failure:
+ ebreak
+ j loop
+success:
mpause # Kelvin end of program op
-1:
- j 1b
+loop:
+ j loop
diff --git a/docs/kelvin_isa.md b/docs/kelvin_isa.md
index f6c9ae9..b00f3f5 100644
--- a/docs/kelvin_isa.md
+++ b/docs/kelvin_isa.md
@@ -39,10 +39,10 @@
<br>
-31..26 | 25..20 | 19..14 | 13..12 | 11..6 | 5 | 4..3 | 2..0 | form
-:----: | :----: | :----: | :----: | :---: | :-: | :---: | :--: | :--:
-vs3 | vs2 | vs1 | func3 | vd | m | func3 | 001 | .vvv
-vs3 | [0]xs2 | vs1 | func3 | vd | m | func3 | 101 | .vxv
+31..26 | 25..20 | 19..14 | 13..12 | 11..6 | 5 | 4..3 | 2..0 | form
+:----: | :----: | :----: | :--------: | :---: | :-: | :--------: | :--: | :--:
+vs3 | vs2 | vs1 | func3[3:2] | vd | m | func3[1:0] | 001 | .vvv
+vs3 | [0]xs2 | vs1 | func3[3:2] | vd | m | func3[1:0] | 101 | .vxv
### Types ".b" ".h" ".w"
@@ -303,14 +303,14 @@
### Exit Cause
-* enum_IDLE = 0
-* enum_EBREAK = 1
-* enum_ECALL = 2
-* enum_EEXIT = 3
-* enum_EYIELD = 4
-* enum_ECTXSW = 5
-* enum_UNDEF_INST = (1u<<31) | 2
-* enum_USAGE_FAULT = (1u<<31) | 16
+* `enum_IDLE = 0`
+* `enum_EBREAK = 1`
+* `enum_ECALL = 2`
+* `enum_EEXIT = 3`
+* `enum_EYIELD = 4`
+* `enum_ECTXSW = 5`
+* `enum_UNDEF_INST = (1u<<31) | 2`
+* `enum_USAGE_FAULT = (1u<<31) | 16`
## Instruction Definitions
@@ -885,7 +885,7 @@
vd[L] = vs1[L] & MSB ? CLZ(~vs1[L]) : CLZ(vs1[L])
```
-Note: (clb - 1) is equivalent to __builtin_clrsb.
+Note: (clb - 1) is equivalent to `__builtin_clrsb`.
**clb examples**
@@ -1156,18 +1156,18 @@
#### VGE
-Integer greater-than comparison.
+Integer greater-than-or-equal comparison.
**Encodings**
-vgt.[b,h,w].{u}.vv.{m} vd, vs1, vs2 \
-vgt.[b,h,w].{u}.vx.{m} vd, vs1, xs2
+vge.[b,h,w].{u}.vv.{m} vd, vs1, vs2 \
+vge.[b,h,w].{u}.vx.{m} vd, vs1, xs2
**Operation**
```
for L in Op.typelen
- vd[L] = vs1[L] > vs2[L] ? 1 : 0
+ vd[L] = vs1[L] >= vs2[L] ? 1 : 0
```
--------------------------------------------------------------------------------
@@ -1972,7 +1972,7 @@
vsubw.[h,w].{u}.vv.{m} vd, vs1, vs2 \
vsubw.[h,w].{u}.vx.{m} vd, vs1, xs2
-**Operation**`
+**Operation**
```
for L in Op.typelen
diff --git a/third_party/gemmlowp/BUILD b/third_party/gemmlowp/BUILD
deleted file mode 100644
index 584f7e9..0000000
--- a/third_party/gemmlowp/BUILD
+++ /dev/null
@@ -1,4 +0,0 @@
-# Copyright 2023 Google LLC
-package(default_visibility = ["//visibility:public"])
-
-exports_files(glob(["*.patch"]))
diff --git a/third_party/gemmlowp/pthread.patch b/third_party/gemmlowp/pthread.patch
deleted file mode 100644
index 547dd52..0000000
--- a/third_party/gemmlowp/pthread.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/flags.bzl b/flags.bzl
-index e35fe9e..e26a448 100644
---- a/flags.bzl
-+++ b/flags.bzl
-@@ -4,7 +4,7 @@ LIB_COPTS = []
- LIB_LINKOPTS = select({
- ":android": [],
- ":windows": [],
-- "//conditions:default": ["-lpthread"],
-+ "//conditions:default": [],
- })
-
- BIN_LINKOPTS = LIB_LINKOPTS
\ No newline at end of file
diff --git a/third_party/ruy/BUILD b/third_party/ruy/BUILD
deleted file mode 100644
index 584f7e9..0000000
--- a/third_party/ruy/BUILD
+++ /dev/null
@@ -1,4 +0,0 @@
-# Copyright 2023 Google LLC
-package(default_visibility = ["//visibility:public"])
-
-exports_files(glob(["*.patch"]))
diff --git a/third_party/ruy/pthread.patch b/third_party/ruy/pthread.patch
deleted file mode 100644
index c8ddf4d..0000000
--- a/third_party/ruy/pthread.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff --git a/ruy/build_defs.oss.bzl b/ruy/build_defs.oss.bzl
-index e405b41..1d7612b 100644
---- a/ruy/build_defs.oss.bzl
-+++ b/ruy/build_defs.oss.bzl
-@@ -11,5 +11,5 @@ def ruy_linkopts_thread_standard_library():
- # https://github.com/abseil/abseil-cpp/blob/1112609635037a32435de7aa70a9188dcb591458/absl/base/BUILD.bazel#L155
- return select({
- "@bazel_tools//src/conditions:windows": [],
-- "//conditions:default": ["-pthread"],
-+ "//conditions:default": [],
- })
\ No newline at end of file