Skip to content

Commit

Permalink
Cleanup examples; merge tests into systest example
Browse files Browse the repository at this point in the history
  • Loading branch information
saursin committed Nov 13, 2023
1 parent 134b5f0 commit ec788b7
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 359 deletions.
32 changes: 16 additions & 16 deletions sw/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ soctarget ?= None
ex ?= None

# Compile for simulation (may be overridden)
sim ?= false
sim ?= 0

# Compile for use with bootloader (may be overridden)
boot ?= false
boot ?= 0

# Vuart for make run example (may be overridden)
vuart ?= None

# Save objdump while compiling (may be overridden)
objdump ?= true
objdump ?= 1

# Save binary while compiling (may be overridden)
bin ?= true
bin ?= 1

# Save map file while compiling (may be overridden)
map ?= true
map ?= 1

########################################################################
# Checks
Expand Down Expand Up @@ -81,8 +81,8 @@ endif


RVPREFIX := riscv64-unknown-elf
CFLAGS := -Wall
CFLAGS += -mabi=ilp32 -march=rv32i -nostartfiles -ffreestanding -Os -g
CFLAGS += -Wall
CFLAGS += -mabi=ilp32 -march=rv32i -nostartfiles -ffreestanding -O0 -g
CFLAGS += -I $(RVATOM_LIB)/include -L $(RVATOM_LIB)

LINKERSCRIPT := None
Expand Down Expand Up @@ -114,7 +114,7 @@ ifeq ($(__check_soctarget),true)
endif
endif

ifeq ($(boot), true)
ifeq ($(boot), 1)
LINKERSCRIPT:= ../flashboot/link_app.lds
endif

Expand Down Expand Up @@ -150,18 +150,18 @@ EXAMPLE_DIRS = $(sort $(dir $(wildcard */)))
SRC_FILES = $(patsubst %, $(ex)/%, $(src_files))

# atomsim args
ATOMSIM_ARGS = --maxitr=999999999 --enable-uart-dump
ATOMSIM_ARGS = --maxitr=999999999 -uv

# VUART setting
ifneq ($(vuart), None)
ATOMSIM_ARGS += --vuart=$(vuart)
endif

ifeq ($(map), true)
ifeq ($(map), 1)
LFLAGS += -Xlinker -Map $(executable).map
endif

ifeq ($(sim), true)
ifeq ($(sim), 1)
CFLAGS += -DSIM
endif

Expand Down Expand Up @@ -190,7 +190,7 @@ help: ## Show help
@printf "Note:\n"
@printf " - Following TARGETs can be run without overriding \"ex\" & \"soctarget\" variables\n"
@printf " help, all, clean-all\n"
@printf " - To save objdump,, set the \"objdump\" variable to \"true\" in the CLI.\n"
@printf " - To save objdump,, set the \"objdump\" variable to \"1\" in the CLI.\n"
@printf " - To save run using vuart, set the vuart variable to the path of the simport\n"


Expand All @@ -203,11 +203,11 @@ $(ex)/$(executable): $(SRC_FILES)
@printf "$(COLOR_CYAN)%-15s | Compiling %-35s <- %s$(COLOR_NC)\n" ${ex} $@ $<
cd $(ex) && $(RVPREFIX)-gcc $(CFLAGS) $(src_files) -o $(executable) $(LFLAGS)

ifeq ($(objdump), true)
ifeq ($(objdump), 1)
$(RVPREFIX)-objdump -Shtd $@ > [email protected]
endif

ifeq ($(bin), true)
ifeq ($(bin), 1)
$(RVPREFIX)-objcopy -O binary $@ [email protected]
@printf "Binary size: %s bytes\n" $$(stat --format=%s "[email protected]")
endif
Expand Down Expand Up @@ -236,11 +236,11 @@ clean: ## Clean executable


all: ## Build all examples
@$(patsubst %/, make -s ex=% compile;,${EXAMPLE_DIRS})
@$(patsubst %/, make -s ex=% sim=1 compile;,${EXAMPLE_DIRS})


run-all: ## Build & run all examples
@$(patsubst %/, printf "${COLOR_CYAN}----------------------------------------------------${COLOR_NC}\n"; make -s ex=% run;,${EXAMPLE_DIRS})
@$(patsubst %/, printf "${COLOR_CYAN}----------------------------------------------------${COLOR_NC}\n"; make -s ex=% sim=1 run;,${EXAMPLE_DIRS})


.PHONY: clean-all
Expand Down
5 changes: 3 additions & 2 deletions sw/examples/banner/banner.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ int main()
puts(banner);
printf("CPU : RISC-V Atom @ %d Hz\n", CLK_FREQ);
puts("Arch : RV32I - little endian\n");
printf("CODE RAM : 0x%8x (%d bytes)\n", CODERAM_BASE, CODERAM_SIZE);
printf("DATA RAM : 0x%8x (%d bytes)\n", DATARAM_BASE, DATARAM_SIZE);
printf("CODE RAM : 0x%08x (%d bytes)\n", (unsigned)CODERAM_BASE, (unsigned)CODERAM_SIZE);
printf("DATA RAM : 0x%08x (%d bytes)\n", (unsigned)DATARAM_BASE, (unsigned)DATARAM_SIZE);
puts("Exiting...\n");
asm volatile("ecall");
return 0;
}
2 changes: 0 additions & 2 deletions sw/examples/csr/Makefile.include

This file was deleted.

23 changes: 0 additions & 23 deletions sw/examples/csr/csr.S

This file was deleted.

57 changes: 0 additions & 57 deletions sw/examples/csr/csr.c

This file was deleted.

2 changes: 0 additions & 2 deletions sw/examples/dining-phil/Makefile.include

This file was deleted.

129 changes: 0 additions & 129 deletions sw/examples/dining-phil/dining-phil.c

This file was deleted.

2 changes: 0 additions & 2 deletions sw/examples/fibonacci/Makefile.include

This file was deleted.

34 changes: 0 additions & 34 deletions sw/examples/fibonacci/fibonacci.c

This file was deleted.

2 changes: 0 additions & 2 deletions sw/examples/hanoi/Makefile.include

This file was deleted.

Loading

0 comments on commit ec788b7

Please sign in to comment.