Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cosim-mode tests #30

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ OUTPUT_STAGE2_PATCH = $(OUTPUT)/patches/stage2/
OUTPUT_STAGE1_BIN = $(OUTPUT)/bin/stage1/
OUTPUT_STAGE2_BIN = $(OUTPUT)/bin/stage2/
CONFIGS = configs/
TEST_MODE = self

SPIKE = spike
PATCHER_SPIKE = build/pspike
Expand All @@ -27,6 +28,14 @@ RISCV_PREFIX = riscv64-unknown-elf-
RISCV_GCC = $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS = -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -DENTROPY=0xdeadbeef -DLFSR_BITS=9 -fno-tree-loop-distribute-patterns

ifeq ($(TEST_MODE), self)
STAGE2_GCC_OPTS =
else ifeq ($(TEST_MODE), cosim)
STAGE2_GCC_OPTS = -DCOSIM_TEST_CASE
else
$(error "Only self and cosim are supported for TEST_MODE")
endif

PK =

ifeq ($(MODE),machine)
Expand Down Expand Up @@ -94,7 +103,7 @@ compile-stage2: generate-stage2
tests_stage2 = $(addsuffix .stage2, $(tests))

$(tests_stage2):
$(RISCV_GCC) -march=${MARCH} -mabi=${MABI} $(RISCV_GCC_OPTS) -I$(ENV) -Imacros/general -T$(ENV)/link.ld $(ENV_CSRCS) ${OUTPUT_STAGE2}$(shell basename $@ .stage2).S -o ${OUTPUT_STAGE2_BIN}$(shell basename $@ .stage2)
$(RISCV_GCC) -march=${MARCH} -mabi=${MABI} $(RISCV_GCC_OPTS) $(STAGE2_GCC_OPTS) -I$(ENV) -Imacros/general -T$(ENV)/link.ld $(ENV_CSRCS) ${OUTPUT_STAGE2}$(shell basename $@ .stage2).S -o ${OUTPUT_STAGE2_BIN}$(shell basename $@ .stage2)
${SPIKE} --isa=${MARCH} --varch=vlen:${VLEN},elen:${XLEN} $(PK) ${OUTPUT_STAGE2_BIN}$(shell basename $@ .stage2)


Expand Down
9 changes: 8 additions & 1 deletion macros/general/test_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
#define load lw
#endif

#ifdef COSIM_TEST_CASE
// With cosim, only need to load the value to check that it is correct
#define TEST_CASE( testnum, testreg, correctval, code... ) \
li TESTNUM, testnum; \
code;
#else
// Ugly, this currently inlines the correctval in with the code,
// but this avoids many SLLI/ADDI to generate it from an immediate
#define TEST_CASE( testnum, testreg, correctval, code... ) \
#define TEST_CASE( testnum, testreg, correctval, code... ) \
test_ ## testnum: \
li TESTNUM, testnum; \
code; \
Expand All @@ -32,6 +38,7 @@ test_ ## testnum: \
test_ ## testnum ## _data: \
.quad MASK_XLEN(correctval); \
test_ ## testnum ## _success:
#endif

# We use a macro hack to simpify code generation for various numbers
# of bubble cycles.
Expand Down
Loading