Generate loadarch checkpoints in directories
This commit is contained in:
Submodule generators/testchipip updated: 3183617053...702daddd20
@@ -44,64 +44,74 @@ done
|
|||||||
BASEMEM="$((0x80000000)):$((0x10000000))"
|
BASEMEM="$((0x80000000)):$((0x10000000))"
|
||||||
SPIKEFLAGS="-p$NHARTS --pmpregions=0 --isa=rv64gc -m$BASEMEM"
|
SPIKEFLAGS="-p$NHARTS --pmpregions=0 --isa=rv64gc -m$BASEMEM"
|
||||||
|
|
||||||
rm -rf cmds_tmp.txt
|
BASENAME=$(basename -- $BINARY)
|
||||||
touch cmds_tmp.txt
|
DIRNAME=$BASENAME.$PC.$CYCLES.loadarch
|
||||||
|
echo "Generating loadarch directory $DIRNAME"
|
||||||
|
rm -rf $DIRNAME
|
||||||
|
mkdir -p $DIRNAME
|
||||||
|
|
||||||
echo "Generating state capture spike interactive commands in cmds_tmp.txt"
|
LOADARCH_FILE=$DIRNAME/loadarch
|
||||||
echo "until pc 0 $PC" >> cmds_tmp.txt
|
RAWMEM_ELF=$DIRNAME/raw.elf
|
||||||
echo "rs $CYCLES" >> cmds_tmp.txt
|
LOADMEM_ELF=$DIRNAME/mem.elf
|
||||||
echo "dump" >> cmds_tmp.txt
|
CMDS_FILE=$DIRNAME/cmds_tmp.txt
|
||||||
|
|
||||||
|
echo "Generating state capture spike interactive commands in $CMDS_FILE"
|
||||||
|
echo "until pc 0 $PC" >> $CMDS_FILE
|
||||||
|
echo "rs $CYCLES" >> $CMDS_FILE
|
||||||
|
echo "dump" >> $CMDS_FILE
|
||||||
for (( h=0; h<$NHARTS; h++ ))
|
for (( h=0; h<$NHARTS; h++ ))
|
||||||
do
|
do
|
||||||
echo "pc $h" >> cmds_tmp.txt
|
echo "pc $h" >> $CMDS_FILE
|
||||||
echo "priv $h" >> cmds_tmp.txt
|
echo "priv $h" >> $CMDS_FILE
|
||||||
echo "reg $h fcsr" >> cmds_tmp.txt
|
echo "reg $h fcsr" >> $CMDS_FILE
|
||||||
|
|
||||||
echo "reg $h stvec" >> cmds_tmp.txt
|
echo "reg $h stvec" >> $CMDS_FILE
|
||||||
echo "reg $h sscratch" >> cmds_tmp.txt
|
echo "reg $h sscratch" >> $CMDS_FILE
|
||||||
echo "reg $h sepc" >> cmds_tmp.txt
|
echo "reg $h sepc" >> $CMDS_FILE
|
||||||
echo "reg $h scause" >> cmds_tmp.txt
|
echo "reg $h scause" >> $CMDS_FILE
|
||||||
echo "reg $h stval" >> cmds_tmp.txt
|
echo "reg $h stval" >> $CMDS_FILE
|
||||||
echo "reg $h satp" >> cmds_tmp.txt
|
echo "reg $h satp" >> $CMDS_FILE
|
||||||
|
|
||||||
echo "reg $h mstatus" >> cmds_tmp.txt
|
echo "reg $h mstatus" >> $CMDS_FILE
|
||||||
echo "reg $h medeleg" >> cmds_tmp.txt
|
echo "reg $h medeleg" >> $CMDS_FILE
|
||||||
echo "reg $h mideleg" >> cmds_tmp.txt
|
echo "reg $h mideleg" >> $CMDS_FILE
|
||||||
echo "reg $h mie" >> cmds_tmp.txt
|
echo "reg $h mie" >> $CMDS_FILE
|
||||||
echo "reg $h mtvec" >> cmds_tmp.txt
|
echo "reg $h mtvec" >> $CMDS_FILE
|
||||||
echo "reg $h mscratch" >> cmds_tmp.txt
|
echo "reg $h mscratch" >> $CMDS_FILE
|
||||||
echo "reg $h mepc" >> cmds_tmp.txt
|
echo "reg $h mepc" >> $CMDS_FILE
|
||||||
echo "reg $h mcause" >> cmds_tmp.txt
|
echo "reg $h mcause" >> $CMDS_FILE
|
||||||
echo "reg $h mtval" >> cmds_tmp.txt
|
echo "reg $h mtval" >> $CMDS_FILE
|
||||||
echo "reg $h mip" >> cmds_tmp.txt
|
echo "reg $h mip" >> $CMDS_FILE
|
||||||
|
|
||||||
echo "reg $h mcycle" >> cmds_tmp.txt
|
echo "reg $h mcycle" >> $CMDS_FILE
|
||||||
echo "reg $h minstret" >> cmds_tmp.txt
|
echo "reg $h minstret" >> $CMDS_FILE
|
||||||
|
|
||||||
echo "mtime" >> cmds_tmp.txt
|
echo "mtime" >> $CMDS_FILE
|
||||||
echo "mtimecmp $h" >> cmds_tmp.txt
|
echo "mtimecmp $h" >> $CMDS_FILE
|
||||||
|
|
||||||
for (( fr=0; fr<32; fr++ ))
|
for (( fr=0; fr<32; fr++ ))
|
||||||
do
|
do
|
||||||
echo "freg $h $fr" >> cmds_tmp.txt
|
echo "freg $h $fr" >> $CMDS_FILE
|
||||||
done
|
done
|
||||||
for (( xr=0; xr<32; xr++ ))
|
for (( xr=0; xr<32; xr++ ))
|
||||||
do
|
do
|
||||||
echo "reg $h $xr" >> cmds_tmp.txt
|
echo "reg $h $xr" >> $CMDS_FILE
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
echo "quit" >> cmds_tmp.txt
|
echo "quit" >> $CMDS_FILE
|
||||||
|
|
||||||
#cat cmds_tmp.txt
|
#cat $CMDS_FILE
|
||||||
BASENAME=$(basename -- $BINARY)
|
|
||||||
|
|
||||||
echo "Capturing state at checkpoint to spikeout"
|
echo "Capturing state at checkpoint to spikeout"
|
||||||
spike -d --debug-cmd=cmds_tmp.txt $SPIKEFLAGS $BINARY 2> $BASENAME.loadarch
|
spike -d --debug-cmd=$CMDS_FILE $SPIKEFLAGS $BINARY 2> $LOADARCH_FILE
|
||||||
|
|
||||||
echo "Finding tohost/fromhost in elf file"
|
echo "Finding tohost/fromhost in elf file"
|
||||||
TOHOST=$(riscv64-unknown-elf-nm $BINARY | grep tohost | head -c 16)
|
TOHOST=$(riscv64-unknown-elf-nm $BINARY | grep tohost | head -c 16)
|
||||||
FROMHOST=$(riscv64-unknown-elf-nm $BINARY | grep fromhost | head -c 16)
|
FROMHOST=$(riscv64-unknown-elf-nm $BINARY | grep fromhost | head -c 16)
|
||||||
|
|
||||||
echo "Compiling memory to elf"
|
echo "Compiling memory to elf"
|
||||||
riscv64-unknown-elf-objcopy -I binary -O elf64-littleriscv mem.0x80000000.bin $BASENAME.mem.elf
|
riscv64-unknown-elf-objcopy -I binary -O elf64-littleriscv mem.0x80000000.bin $RAWMEM_ELF
|
||||||
riscv64-unknown-elf-ld -Tdata=0x80000000 -nmagic --defsym tohost=0x$TOHOST --defsym fromhost=0x$FROMHOST -o $BASENAME.loadarch.elf $BASENAME.mem.elf
|
rm -rf mem.0x80000000.bin
|
||||||
|
|
||||||
|
riscv64-unknown-elf-ld -Tdata=0x80000000 -nmagic --defsym tohost=0x$TOHOST --defsym fromhost=0x$FROMHOST -o $LOADMEM_ELF $RAWMEM_ELF
|
||||||
|
rm -rf $RAWMEM_ELF
|
||||||
|
|||||||
@@ -247,12 +247,14 @@ PERMISSIVE_OFF=+permissive-off
|
|||||||
BINARY ?=
|
BINARY ?=
|
||||||
override SIM_FLAGS += +dramsim +dramsim_ini_dir=$(TESTCHIP_DIR)/src/main/resources/dramsim2_ini +max-cycles=$(timeout_cycles)
|
override SIM_FLAGS += +dramsim +dramsim_ini_dir=$(TESTCHIP_DIR)/src/main/resources/dramsim2_ini +max-cycles=$(timeout_cycles)
|
||||||
VERBOSE_FLAGS ?= +verbose
|
VERBOSE_FLAGS ?= +verbose
|
||||||
sim_out_name = $(output_dir)/$(subst $() $(),_,$(notdir $(basename $(BINARY))))
|
OUT_NAME ?= $(subst $() $(),_,$(notdir $(basename $(BINARY))))
|
||||||
LOADMEM ?=
|
LOADMEM ?=
|
||||||
LOADARCH ?=
|
LOADARCH ?=
|
||||||
|
|
||||||
ifneq ($(LOADARCH),)
|
ifneq ($(LOADARCH),)
|
||||||
override BINARY = $(LOADARCH)/mem.elf
|
override BINARY = $(LOADARCH)/mem.elf
|
||||||
|
override OUT_NAME = $(shell basename $(LOADARCH))
|
||||||
|
override LOADMEM = 1
|
||||||
override SIM_FLAGS += +loadarch=$(LOADARCH)/loadarch
|
override SIM_FLAGS += +loadarch=$(LOADARCH)/loadarch
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -264,6 +266,8 @@ else ifneq ($(LOADMEM),)
|
|||||||
override SIM_FLAGS += +loadmem=$(LOADMEM)
|
override SIM_FLAGS += +loadmem=$(LOADMEM)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
sim_out_name = $(output_dir)/$(OUT_NAME)
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# build output directory for compilation
|
# build output directory for compilation
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user