Skip to content

Commit

Permalink
Merge pull request #30 from jerryz123/cosim
Browse files Browse the repository at this point in the history
Support cosim-mode tests
  • Loading branch information
ksco authored Feb 22, 2024
2 parents 8af4d0f + 512f1e6 commit 63c7d09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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

0 comments on commit 63c7d09

Please sign in to comment.