diff --git a/cyclecount/cyclecount.c b/cyclecount/cyclecount.c deleted file mode 100644 index e4fe8a6..0000000 --- a/cyclecount/cyclecount.c +++ /dev/null @@ -1,25 +0,0 @@ -#include - -uint64_t getcycles(); -static void do_something() -{ - for (int i = 0; i < 1000; ++i) { - __asm__("NOP"); - } -} - -int main(void) -{ - // Instruction cache misses are relatively expensive, so for more - // consistent benchmarks that depend less on the relative speed of - // the QSPI flash, you might want to fill the instruction cache first. - // Note that it can hold 16 KiB of instructions on the HiFive1. - do_something(); - getcycles(); - uint64_t oldcount = getcycles(); - do_something(); - uint64_t newcount = getcycles(); - - printf("That took %d cycles.\n", (unsigned int)(newcount-oldcount)); - return 0; -} diff --git a/cyclecount/getcycles.S b/cyclecount/getcycles.S deleted file mode 100644 index f17b77a..0000000 --- a/cyclecount/getcycles.S +++ /dev/null @@ -1,10 +0,0 @@ -.text - -.globl getcycles -.align 2 -getcycles: - csrr a1, mcycleh - csrr a0, mcycle - csrr a2, mcycleh - bne a1, a2, getcycles - ret diff --git a/cyclecount/Makefile b/helloworld/Makefile similarity index 58% rename from cyclecount/Makefile rename to helloworld/Makefile index 27e95e1..c8a2887 100644 --- a/cyclecount/Makefile +++ b/helloworld/Makefile @@ -1,6 +1,6 @@ -TARGET := cyclecount.elf -LOCAL_SRC_C := cyclecount.c -LOCAL_SRC_S := getcycles.S +TARGET := helloriscv.elf +LOCAL_SRC_C := helloriscv.c +LOCAL_SRC_S := LOCAL_OPT_C := -Os -fno-builtin-printf -Wall -Wextra -pedantic include ../conf/toolchain.mk diff --git a/helloworld/helloriscv.c b/helloworld/helloriscv.c new file mode 100644 index 0000000..898607d --- /dev/null +++ b/helloworld/helloriscv.c @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + printf("Hello RISC-V"); + return 0; +}