Merge branch 'test_programs' into 'decode_print'
ONGOING: Test programs See merge request simpleos/burritos!5
This commit is contained in:
commit
fee880e352
14
test_programs/Makefile
Normal file
14
test_programs/Makefile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
TOPDIR=.
|
||||||
|
include $(TOPDIR)/Makefile.config
|
||||||
|
|
||||||
|
#
|
||||||
|
# Main targets
|
||||||
|
#
|
||||||
|
objdumps:
|
||||||
|
$(MAKE) -C riscv_instructions
|
||||||
|
|
||||||
|
programs:
|
||||||
|
$(MAKE) -C programs
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(TOPDIR)/target
|
18
test_programs/Makefile.config
Normal file
18
test_programs/Makefile.config
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# This is part of a GNU -*- Makefile -*-, to specify system-dependent
|
||||||
|
# parts of the Makefile enviroment.
|
||||||
|
#
|
||||||
|
# This gets included as part of the GNU-Makefile used in each of
|
||||||
|
# the subdirectories.
|
||||||
|
#
|
||||||
|
# Depending on your platform, you need to select the correct definition.
|
||||||
|
|
||||||
|
## RISCV target compilation toolchain
|
||||||
|
RISCV_PREFIX=/opt/riscv/bin/
|
||||||
|
RISCV_AS = $(RISCV_PREFIX)riscv64-unknown-elf-gcc -x assembler-with-cpp -march=rv64imfd
|
||||||
|
RISCV_GCC = $(RISCV_PREFIX)riscv64-unknown-elf-gcc
|
||||||
|
RISCV_LD = $(RISCV_PREFIX)riscv64-unknown-elf-ld
|
||||||
|
RISCV_OBJDUMP = $(RISCV_PREFIX)riscv64-unknown-elf-objdump
|
||||||
|
RISCV_ASFLAGS = $(RISCV_CPPFLAGS)
|
||||||
|
RISCV_CPPFLAGS = #nil
|
||||||
|
RISCV_CFLAGS = -Wall $(RISCV_CPPFLAGS) -march=rv64imfd
|
||||||
|
RISCV_LDFLAGS = #nil
|
24
test_programs/Makefile.objdumps
Normal file
24
test_programs/Makefile.objdumps
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
include $(TOPDIR)/Makefile.config
|
||||||
|
|
||||||
|
COVERAGE = $(TOPDIR)/riscv_instructions
|
||||||
|
|
||||||
|
AS = $(RISCV_AS) -c
|
||||||
|
GCC = $(RISCV_GCC)
|
||||||
|
LD = $(RISCV_LD)
|
||||||
|
|
||||||
|
INCPATH += -I$(TOPDIR) -I$(COVERAGE)
|
||||||
|
ASFLAGS = $(RISCV_ASFLAGS) $(INCPATH)
|
||||||
|
CFLAGS = $(RISCV_CFLAGS) $(INCPATH)
|
||||||
|
|
||||||
|
# Rules
|
||||||
|
%.a:
|
||||||
|
$(AR) rcv $@ $^
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(GCC) $(CFLAGS) -c $<
|
||||||
|
|
||||||
|
%.o: %.s
|
||||||
|
$(AS) $(ASFLAGS) -c $<
|
||||||
|
|
||||||
|
$(PROGRAMS):
|
||||||
|
$(LD) $+ -o $@
|
28
test_programs/README.md
Normal file
28
test_programs/README.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# BurritOS Test programs
|
||||||
|
This folder contains small C programs pertaining to the assessment of the correctness of BurritOS' behavior.
|
||||||
|
|
||||||
|
## Folder Structure
|
||||||
|
- **riscv_instructions**: contains small programs for testing simulator instruction coverage.
|
||||||
|
|
||||||
|
## How to build
|
||||||
|
### In the Makefile.config file
|
||||||
|
Set the variables to the correct paths for the [RISCV Newlib compilation toolchain](https://github.com/riscv-collab/riscv-gnu-toolchain). Simply changing the `RISCV_PREFIX` variable should do the trick. **Do not forget to add a trailing slash**.
|
||||||
|
|
||||||
|
### Exporting objdumps
|
||||||
|
|
||||||
|
```
|
||||||
|
$ make objdumps
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compiling programs
|
||||||
|
```
|
||||||
|
$ make programs
|
||||||
|
```
|
||||||
|
|
||||||
|
### Cleaning
|
||||||
|
```
|
||||||
|
$ make clean
|
||||||
|
```
|
||||||
|
|
||||||
|
### Output folder
|
||||||
|
Compilation results are located in the target/objdumps and target/programs directories.
|
2
test_programs/riscv_instructions/Makefile
Normal file
2
test_programs/riscv_instructions/Makefile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
TOPDIR = ../
|
||||||
|
include $(TOPDIR)/Makefile.objdumps
|
15
test_programs/riscv_instructions/boolean_logic/comparisons.c
Normal file
15
test_programs/riscv_instructions/boolean_logic/comparisons.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
int main() {
|
||||||
|
int x = 0;
|
||||||
|
int y = 1;
|
||||||
|
while (x <= y) {
|
||||||
|
if (x > y) {
|
||||||
|
x += 1;
|
||||||
|
} else if (x == y) {
|
||||||
|
x += y;
|
||||||
|
} else if (x < y) {
|
||||||
|
y += 1;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
test_programs/riscv_instructions/boolean_logic/if.c
Normal file
10
test_programs/riscv_instructions/boolean_logic/if.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
int main() {
|
||||||
|
int x = 1;
|
||||||
|
if (x == 1 && x > 0) {
|
||||||
|
x = 2;
|
||||||
|
} else if (x || x == 0 ) {
|
||||||
|
x = 3;
|
||||||
|
} else {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
}
|
7
test_programs/riscv_instructions/boolean_logic/switch.c
Normal file
7
test_programs/riscv_instructions/boolean_logic/switch.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
int main() {
|
||||||
|
int x = 0;
|
||||||
|
switch(1) {
|
||||||
|
case 1: x = 1; break;
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
int test() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int x = test();
|
||||||
|
}
|
3
test_programs/riscv_instructions/jump_instructions/ret.c
Normal file
3
test_programs/riscv_instructions/jump_instructions/ret.c
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
int main() {
|
||||||
|
return 1;
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
# Simple arithmetics program
|
||||||
|
|
||||||
|
These allow to check whether the following instructions are correctly implemented.
|
||||||
|
|
||||||
|
- addi
|
||||||
|
- sd
|
||||||
|
- sw
|
||||||
|
- li
|
||||||
|
- sw
|
||||||
|
- lw
|
||||||
|
- mv
|
||||||
|
- addw
|
||||||
|
- nop
|
||||||
|
- ld
|
||||||
|
- ret
|
@ -0,0 +1,6 @@
|
|||||||
|
// EXPECTS TWO VARIABLES WITH A VALUE OF UNSIGNED 1
|
||||||
|
void main() {
|
||||||
|
unsigned int x = 0;
|
||||||
|
unsigned int y = 1;
|
||||||
|
x = x + y;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
// Expecting two variables with a value of two
|
||||||
|
void main() {
|
||||||
|
unsigned int x = 4;
|
||||||
|
unsigned int y = 2;
|
||||||
|
x = x / y;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
// EXPECTS TWO VARIABLES WITH A VALUE OF UNSIGNED 2
|
||||||
|
void main() {
|
||||||
|
unsigned int x = 1;
|
||||||
|
unsigned int y = 2;
|
||||||
|
x = x * y;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
// EXPECTS TWO VARIABLES WITH A VALUE OF UNSIGNED 1
|
||||||
|
void main() {
|
||||||
|
unsigned int x = 1;
|
||||||
|
unsigned int y = 1;
|
||||||
|
x = x - y;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user