aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--benchmarks/Makefile1
-rw-r--r--benchmarks/ioexample/bmark.mk30
-rw-r--r--benchmarks/ioexample/ioexample_main.c51
m---------benchmarks/ioexample/libamf0
5 files changed, 85 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
index a557616..2765f62 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "env"]
path = env
url = https://github.com/riscv/riscv-test-env.git
+[submodule "benchmarks/ioexample/libamf"]
+ path = benchmarks/ioexample/libamf
+ url = git://github.com/palmer-dabbelt/libamf.git
diff --git a/benchmarks/Makefile b/benchmarks/Makefile
index e294f72..b301a10 100644
--- a/benchmarks/Makefile
+++ b/benchmarks/Makefile
@@ -27,6 +27,7 @@ bmarks = \
spmv \
mt-vvadd \
mt-matmul \
+ ioexample \
bmarks_host = \
median \
diff --git a/benchmarks/ioexample/bmark.mk b/benchmarks/ioexample/bmark.mk
new file mode 100644
index 0000000..b0897c7
--- /dev/null
+++ b/benchmarks/ioexample/bmark.mk
@@ -0,0 +1,30 @@
+#=======================================================================
+# UCB CS250 Makefile fragment for benchmarks
+#-----------------------------------------------------------------------
+#
+# Each benchmark directory should have its own fragment which
+# essentially lists what the source files are and how to link them
+# into an riscv and/or host executable. All variables should include
+# the benchmark name as a prefix so that they are unique.
+#
+
+ioexample_c_src = \
+ ioexample_main.c \
+ syscalls.c \
+
+ioexample_riscv_src = \
+ crt.S \
+
+ioexample_c_objs = $(patsubst %.c, %.o, $(ioexample_c_src))
+ioexample_riscv_objs = $(patsubst %.S, %.o, $(ioexample_riscv_src))
+
+ioexample_host_bin = ioexample.host
+$(ioexample_host_bin) : $(ioexample_c_src)
+ $(HOST_COMP) $^ -o $(ioexample_host_bin)
+
+ioexample_riscv_bin = ioexample.riscv
+$(ioexample_riscv_bin) : $(ioexample_c_objs) $(ioexample_riscv_objs)
+ $(RISCV_LINK) $(ioexample_c_objs) $(ioexample_riscv_objs) -o $(ioexample_riscv_bin) $(RISCV_LINK_OPTS)
+
+junk += $(ioexample_c_objs) $(ioexample_riscv_objs) \
+ $(ioexample_host_bin) $(ioexample_riscv_bin)
diff --git a/benchmarks/ioexample/ioexample_main.c b/benchmarks/ioexample/ioexample_main.c
new file mode 100644
index 0000000..bd411d8
--- /dev/null
+++ b/benchmarks/ioexample/ioexample_main.c
@@ -0,0 +1,51 @@
+// See LICENSE for license details.
+
+#include "util.h"
+#include "libamf/src/amf.h"
+
+const char *find_config_string(void)
+{
+ const int* boot_rom = (int*)(0x1000);
+ const int config_string_addr_offset = 3;
+ const char *config_string = (char *)((long)boot_rom[config_string_addr_offset]);
+ return config_string;
+}
+
+long fromhex(char c)
+{
+ if (c >= 'A' && c <= 'F') return c - 'A' + 10;
+ if (c >= 'a' && c <= 'f') return c - 'a' + 10;
+ if (c >= '0' && c <= '9') return c - '0' + 0;
+ return -1;
+}
+
+long tolong(const char *config_snippet)
+{
+ if (config_snippet[0] == '0' && config_snippet[1] == 'x')
+ config_snippet += 2;
+
+ long out = 0;
+ while (*config_snippet != '\0' && *config_snippet != ';')
+ out = (out << 4) + fromhex(*config_snippet++);
+
+ return out;
+}
+
+int main( int argc, char* argv[] )
+{
+ volatile long *base = (long *)(tolong(amf_lookup(find_config_string(), "smiexample/addr")));
+ printf("smiexample/addr: %lx\n", base);
+
+ base[1] = 10; // Period
+ base[2] = 2; // Duty Cycle
+ base[0] = 1; // Enable
+
+ printf("Peroid: %d\n", base[1]);
+
+ base[1] = 15; // Peroid
+ base[2] = 7; // Duty Cycle
+
+ printf("Peroid: %d\n", base[1]);
+
+ return 0;
+}
diff --git a/benchmarks/ioexample/libamf b/benchmarks/ioexample/libamf
new file mode 160000
+Subproject 9d28f8d3adbed4654a95ebbf383134db26be5d9