Procházet zdrojové kódy

Adds hello world

master
Kris Kwiatkowski před 5 roky
rodič
revize
b0e6f0813d
4 změnil soubory, kde provedl 10 přidání a 38 odebrání
  1. +0
    -25
      cyclecount/cyclecount.c
  2. +0
    -10
      cyclecount/getcycles.S
  3. +3
    -3
      helloworld/Makefile
  4. +7
    -0
      helloworld/helloriscv.c

+ 0
- 25
cyclecount/cyclecount.c Zobrazit soubor

@@ -1,25 +0,0 @@
#include <stdio.h>

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;
}

+ 0
- 10
cyclecount/getcycles.S Zobrazit soubor

@@ -1,10 +0,0 @@
.text

.globl getcycles
.align 2
getcycles:
csrr a1, mcycleh
csrr a0, mcycle
csrr a2, mcycleh
bne a1, a2, getcycles
ret

cyclecount/Makefile → helloworld/Makefile Zobrazit soubor

@@ -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

+ 7
- 0
helloworld/helloriscv.c Zobrazit soubor

@@ -0,0 +1,7 @@
#include <stdio.h>

int main(void)
{
printf("Hello RISC-V");
return 0;
}

Načítá se…
Zrušit
Uložit