mirror of
https://github.com/openhwgroup/cva5.git
synced 2025-04-20 03:57:18 -04:00
embench benchmarks added and binary tool made more robust
This commit is contained in:
parent
553a193a3c
commit
976ad3d5ee
3 changed files with 83 additions and 37 deletions
|
@ -50,7 +50,7 @@ int main(int argc, char **argv) {
|
|||
VerilatedVcdC *tracer;
|
||||
tracer = new VerilatedVcdC;
|
||||
tb->trace(tracer, 99);
|
||||
tracer->open("sim_results.vcd");
|
||||
tracer->open("/data/sim-logs/sim_results.vcd");
|
||||
#endif
|
||||
|
||||
cout << "--------------------------------------------------------------\n";
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
MAKEFLAGS += --silent
|
||||
MAKEFILE_DIR=$(pwd)
|
||||
TAIGA_DIR=..
|
||||
TAIGA_DIR=/home/ematthew/taiga
|
||||
|
||||
RISCV_PREFIX ?= riscv32-newlib-elf-
|
||||
RISCV_PREFIX ?= riscv32-unknown-elf-
|
||||
|
||||
|
||||
#Verilator parameters
|
||||
|
@ -24,7 +24,7 @@ export RANLIB
|
|||
|
||||
#Compiance parameters
|
||||
###############################################################
|
||||
COMPLIANCE_DIR=/home/ematthew/Research/RISCV/riscv-compliance/
|
||||
COMPLIANCE_DIR=/home/ematthew/Research/RISCV/software/riscv-compliance/
|
||||
COMPLIANCE_TARGET=rv32im
|
||||
###############################################################
|
||||
|
||||
|
@ -45,9 +45,37 @@ BENCHMARKS = \
|
|||
###############################################################
|
||||
|
||||
|
||||
|
||||
#Benchmark parameters
|
||||
#Assumes binaries are in the BENCHMARK_DIR
|
||||
###############################################################
|
||||
EMBENCH_DIR=/home/ematthew/Research/RISCV/software/embench/build/src
|
||||
EMBENCH_BENCHMARKS = \
|
||||
aha-mont64 \
|
||||
crc32 \
|
||||
cubic \
|
||||
edn \
|
||||
huffbench \
|
||||
matmult-int \
|
||||
minver \
|
||||
nbody \
|
||||
nettle-aes \
|
||||
nettle-sha256 \
|
||||
nsichneu \
|
||||
picojpeg \
|
||||
qrduino \
|
||||
sglib-combined \
|
||||
slre \
|
||||
st \
|
||||
statemate \
|
||||
ud \
|
||||
wikisort \
|
||||
|
||||
###############################################################
|
||||
|
||||
#Binary to Verilog HW init file
|
||||
###############################################################
|
||||
ELF_TO_HW_INIT ?= python3 taiga_binary_converter.py $(RISCV_PREFIX) 0x80000000 131072
|
||||
ELF_TO_HW_INIT ?= python3 $(TAIGA_DIR)/tools/taiga_binary_converter.py $(RISCV_PREFIX) 0x80000000 131072
|
||||
###############################################################
|
||||
|
||||
|
||||
|
@ -58,7 +86,7 @@ define verilator_local_mem_test
|
|||
mkdir -p $@
|
||||
cp $(VERILATOR_DIR)/taiga_local_mem.cc $@/
|
||||
verilator -cc --exe --Mdir $@ $(VERILATOR_LINT_IGNORE) $(VERILATOR_CFLAGS) $(TAIGA_SRCS) \
|
||||
../test_benches/verilator/taiga_local_mem.sv --top-module taiga_local_mem taiga_local_mem.cc \
|
||||
../test_benches/verilator/taiga_local_mem.sv --top-module taiga_local_mem taiga_local_mem.cc \
|
||||
-GMEMORY_FILE=$1
|
||||
$(MAKE) -C $@ -f Vtaiga_local_mem.mk AR="gcc-ar" RANLIB="gcc-ranlib"
|
||||
time ./$@/Vtaiga_local_mem $2 $3
|
||||
|
@ -69,7 +97,7 @@ lint:
|
|||
verilator -cc $(TAIGA_SRCS) \
|
||||
../test_benches/verilator/taiga_local_mem.sv \
|
||||
--top-module taiga_local_mem \
|
||||
--lint-only -Wno-WIDTH
|
||||
--lint-only
|
||||
|
||||
.PHONY: verilator_taiga_dhrystone
|
||||
verilator_taiga_dhrystone:
|
||||
|
@ -81,6 +109,15 @@ verilator_taiga_benchmarks:
|
|||
$(call verilator_local_mem_test,\"$(BENCHMARK_DIR)$(BENCHMARK).riscv.hw_init\", $@/$(BENCHMARK).log, "/dev/null") \
|
||||
)
|
||||
|
||||
.PHONY: verilator_taiga_embench
|
||||
verilator_taiga_embench:
|
||||
$(foreach BENCHMARK,$(EMBENCH_BENCHMARKS), \
|
||||
cd $(EMBENCH_DIR)/$(BENCHMARK); \
|
||||
$(ELF_TO_HW_INIT) $(BENCHMARK) $(BENCHMARK).hw_init $(BENCHMARK).sim_init; \
|
||||
cd $(TAIGA_DIR)/tools; \
|
||||
$(call verilator_local_mem_test,\"$(EMBENCH_DIR)/$(BENCHMARK)/$(BENCHMARK).hw_init\", $@/$(BENCHMARK).log, "/dev/null"); \
|
||||
)
|
||||
|
||||
#Called by compliance makefile
|
||||
.PHONY: verilator_taiga_compliance_unit_test
|
||||
verilator_taiga_compliance_unit_test:
|
||||
|
@ -88,11 +125,12 @@ verilator_taiga_compliance_unit_test:
|
|||
|
||||
.PHONY: verilator_taiga_compliance_tests
|
||||
verilator_taiga_compliance_tests:
|
||||
$(MAKE) -C $(COMPLIANCE_DIR) clean
|
||||
$(MAKE) -C $(COMPLIANCE_DIR) RISCV_TARGET=taiga RISCV_DEVICE=$(COMPLIANCE_TARGET) RISCV_PREFIX=$(RISCV_PREFIX)
|
||||
|
||||
.PHONY: verilator_taiga_coremark
|
||||
verilator_taiga_coremark:
|
||||
$(MAKE) -C $(COREMARK_DIR) compile PORT_DIR=taiga-sim ITERATIONS=5000
|
||||
$(MAKE) -C $(COREMARK_DIR) compile PORT_DIR=taiga-sim ITERATIONS=5000;
|
||||
cd $(MAKEFILE_DIR);
|
||||
$(ELF_TO_HW_INIT) $(COREMARK_DIR)/coremark.bin coremark.hw_init coremark.sim_init
|
||||
$(call verilator_local_mem_test,\"coremark.hw_init\", "coremark.log", "coremark.sig")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright © 2017 Eric Matthews, Lesley Shannon
|
||||
# Copyright © 2017-2019 Eric Matthews, Lesley Shannon
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -52,15 +52,16 @@ parser.add_argument('--quiet', '-q', help='Suppresses diagnostic output ', actio
|
|||
args = parser.parse_args()
|
||||
|
||||
# open input file
|
||||
subprocess.run([args.toolPrefix + 'objdump', '-Dzs', args.inputFile], stdout=open(args.inputFile + '.dumpDzs', "w"))
|
||||
subprocess.run([args.toolPrefix + 'objdump', '-d', args.inputFile], stdout=open(args.inputFile + '.dumpd', "w"))
|
||||
print(args.inputFile)
|
||||
subprocess.run([args.toolPrefix + 'objcopy', '--gap-fill=0x00', '-O', 'binary', args.inputFile, args.inputFile + '.rawbinary'])
|
||||
subprocess.run([args.toolPrefix + 'objdump', '-fd', '--prefix-addresses', args.inputFile], stdout=open(args.inputFile + '.dissasembled', "w"))
|
||||
|
||||
|
||||
try:
|
||||
program_input = open(args.inputFile + '.dumpDzs', 'r')
|
||||
opcode_input = open(args.inputFile + '.dumpd', 'r')
|
||||
program_input = open(args.inputFile + '.rawbinary', 'rb')
|
||||
opcode_input = open(args.inputFile + '.dissasembled', 'r')
|
||||
except IOError:
|
||||
print('Could not open files: ', args.inputFile + '.dumpDzs ', args.inputFile + '.dumpd')
|
||||
print('Could not open files: ', args.inputFile + '.raw ', args.inputFile + '.dissasembled')
|
||||
sys.exit()
|
||||
|
||||
program_output = args.inputFile + '.bin'
|
||||
|
@ -82,37 +83,44 @@ except IOError:
|
|||
|
||||
print('array size ', int(int(args.ramSize)/4))
|
||||
|
||||
#Initialize with zero
|
||||
ramData = ['00000000'] * int((int(args.ramSize)/4));
|
||||
|
||||
lineRegex = re.compile(r'\s+')
|
||||
instLineRegex = re.compile(r'\s+|:\s+')
|
||||
dataLineRegex = re.compile(r' [a-f0-9]{8}\s+')
|
||||
|
||||
instLineRegex = re.compile(r'\s+')
|
||||
isInstLine = re.compile(r'[a-f0-9]{8}\s+<\S+') #pattern hexaddress <function name and offset> instruction
|
||||
#parses the block output format
|
||||
addressRegex = re.compile(r'0x[a-f0-9]{8}')
|
||||
hexRegex = re.compile(r'[a-f0-9]{8}')
|
||||
|
||||
#parses the block output format
|
||||
for line in program_input:
|
||||
lineContents = lineRegex.split(line)
|
||||
|
||||
if (dataLineRegex.match(line) != None) :
|
||||
index = int((int(lineContents[1],16) - int(args.baseAddr,16))/4)
|
||||
|
||||
for entry in lineContents[2:]: #skip address
|
||||
if (hexRegex.match(entry)) :
|
||||
ramData[index] = stringByteSwap(entry)
|
||||
index+=1
|
||||
|
||||
#Find start address and lowest address in dissasembly file
|
||||
index = 0
|
||||
lowestAddress = sys.maxsize
|
||||
for line in opcode_input:
|
||||
if (isInstLine.match(line)) :
|
||||
addressMatch = hexRegex.match(line)
|
||||
if (int(addressMatch[0],16) < lowestAddress) :
|
||||
lowestAddress = int(addressMatch[0],16)
|
||||
index = int(lowestAddress/4) - int(int(args.baseAddr,16)/4)
|
||||
if (line.find('start address') != -1) :
|
||||
addressMatch = addressRegex.search(line)
|
||||
print('start address: ', addressMatch[0])
|
||||
|
||||
#Reads binary 4 bytes at a time and converts to Verilog readmemh format
|
||||
word = program_input.read(4)
|
||||
while word != b"":
|
||||
ramData[index] = stringByteSwap(word.hex())
|
||||
index+=1
|
||||
word = program_input.read(4)
|
||||
|
||||
program_output.write('\n'.join(str(line) for line in ramData))
|
||||
|
||||
#overwrite instruction entries with instruction info
|
||||
#<ins hex> <opcode> <instruction details>...
|
||||
#append instruction details to data
|
||||
opcode_input.seek(0)
|
||||
for line in opcode_input:
|
||||
lineContents = instLineRegex.split(line)
|
||||
if (hexRegex.match(lineContents[0])) :
|
||||
if (isInstLine.match(line)) :
|
||||
lineContents = list(filter(None, instLineRegex.split(line))) #split line and remove empty strings
|
||||
index = int((int(lineContents[0],16) - int(args.baseAddr,16))/4)
|
||||
|
||||
for entry in lineContents[1:]: #skip address
|
||||
ramData[index] = lineContents[1] + ' ' + ' '.join(lineContents[2:])
|
||||
ramData[index] += ' ' + ' '.join(lineContents[1:])
|
||||
|
||||
sim_output.write(' --\n'.join(str(line) for line in ramData))
|
||||
sim_output.write(' --')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue