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