Skip to content
Draft
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
9 changes: 6 additions & 3 deletions bin/objdump2itb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It very clean makes regex intent clear and avoids issues with backslash escaping.

Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,22 @@ class CFunction:
# Regular expression to extract a function from objdump
# Example:
# 00000256 <end_handler_incr_mepc>:
FUNC_PATTERN = "(?P<addr>[0-9a-f]{8}) <(?P<name>\S*)>:"
# Note: raw string to treat \S literally for regex
FUNC_PATTERN = r"(?P<addr>[0-9a-f]{8}) <(?P<name>\S*)>:"
FUNC_RE = re.compile(FUNC_PATTERN)

# Regular expression to extract an individual instruction
# Example:
# 264: 00a31363 bne t1,a0,26a <end_handler_incr_mepc2>
INST_PATTERN = "(?P<addr>[0-9a-f]{1,8}):\t*(?P<mcode>[0-9a-f]{4}([0-9a-f]{4})?)\s{2,}(?P<asm>[a-z].*)$"
# Note: raw string to treat \s literally for regex
INST_PATTERN = r"(?P<addr>[0-9a-f]{1,8}):\t*(?P<mcode>[0-9a-f]{4}([0-9a-f]{4})?)\s{2,}(?P<asm>[a-z].*)$"
INST_RE = re.compile(INST_PATTERN)

# Regular expression to extract a source annotation for each instruction
# Example:
# /work/strichmo/core-v-verif/cv32e40x/tests/programs/custom/debug_test_trigger/debugger.S:47
SRC_FILE_PATTERN = "^(?P<dir>/\S+)/(?P<file>[^/\s]+):(?P<line>[0-9]*)$"
# Note: raw string to treat \S and \s literally for regex
SRC_FILE_PATTERN = r"^(?P<dir>/\S+)/(?P<file>[^/\s]+):(?P<line>[0-9]*)$"
SRC_FILE_RE = re.compile(SRC_FILE_PATTERN)

parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
Expand Down
47 changes: 28 additions & 19 deletions cv32e40p/sim/core/Makefile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a solid cleanup, the build system is now easier to maintain and more flexible. Using ?= lets people override settings without editing the Makefile, quoting in find makes it safer, and splitting the flags makes things clearer. The only thing to check is whether any CI scripts still use the old VERI_FLAGS name. But I think if all the tests are passed we are good.

Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,20 @@ XRUN_FLAGS = -clean -smartorder -sv -top worklib.tb_top -timescale 1ns/1p
XRUN_DIR = xcelium.d

# verilator configuration
VERILATOR = verilator
VERI_FLAGS +=
VERI_COMPILE_FLAGS += -Wno-BLKANDNBLK -Wno-MULTIDRIVEN -Wno-COMBDLY $(SV_CMP_FLAGS)
VERILATOR ?= verilator
VERI_RUN_FLAGS ?=
VERI_COMPILE_FLAGS ?= -Wno-BLKANDNBLK \
-Wno-MULTIDRIVEN \
-Wno-COMBDLY \
-Wno-lint \
-Wno-UNOPTFLAT \
-Wno-MODDUP \
$(SV_CMP_FLAGS)
VERI_TRACE ?=
VERI_OBJ_DIR ?= cobj_dir
#VERI_LOG_DIR ?= cobj_dir/logs
VERI_LOG_DIR ?= $(SIM_TEST_PROGRAM_RESULTS)
VERI_CFLAGS += -O2
VERI_CFLAGS ?= -std=c++14 \
-O2

#riviera configuration

Expand Down Expand Up @@ -472,7 +478,7 @@ xrun-clean-all: xrun-clean
# We first test if the user wants to to vcd dumping. This hacky part is required
# because we need to conditionally compile the testbench (-DVCD_TRACE) and pass
# the --trace flags to the verilator call
#ifeq ($(findstring +vcd,$(VERI_FLAGS)),+vcd)
#ifeq ($(findstring +vcd,$(VERI_RUN_FLAGS)),+vcd)

ifneq (${WAVES}, 0)
VERI_TRACE="--trace"
Expand All @@ -488,15 +494,17 @@ testbench_verilator: CV_CORE_pkg $(TBSRC_VERI) $(TBSRC_PKG)
@echo "$(BANNER)"
@echo "* Compiling CORE TB and CV32E40P with Verilator"
@echo "$(BANNER)"
$(VERILATOR) --cc --sv --exe \
$(VERILATOR) \
--cc \
--sv \
--exe \
$(VERI_TRACE) \
--Wno-lint --Wno-UNOPTFLAT \
--Wno-MODDUP --top-module \
tb_top_verilator $(TBSRC_VERI) \
--top-module tb_top_verilator \
$(TBSRC_VERI) \
-f $(CV_CORE_MANIFEST) \
$(CV_CORE_PKG)/bhv/$(CV_CORE_LC)_core_log.sv \
$(TBSRC_CORE)/tb_top_verilator.cpp --Mdir $(VERI_OBJ_DIR) \
-CFLAGS "-std=gnu++11 $(VERI_CFLAGS)" \
-CFLAGS $(VERI_CFLAGS) \
$(VERI_COMPILE_FLAGS)
$(MAKE) -C $(VERI_OBJ_DIR) -f Vtb_top_verilator.mk
mkdir -p $(SIM_RESULTS)
Expand All @@ -509,7 +517,7 @@ veri-test: verilate $(TEST_PROGRAM_PATH)/$(TEST)/$(TEST).hex
@echo "$(BANNER)"
mkdir -p $(VERI_LOG_DIR)
$(SIM_TEST_RESULTS)/verilator_executable \
$(VERI_FLAGS) \
$(VERI_RUN_FLAGS) \
"+firmware=$(TEST_PROGRAM_RELPATH)/$(TEST)/$(TEST).hex" \
| tee $(VERI_LOG_DIR)/$(TEST).log

Expand Down Expand Up @@ -682,13 +690,14 @@ clean-sim-results:

# clean up toolchain generated files
clean-test-programs:
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name *.o -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name *.hex -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name *.elf -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name *.map -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name *.readelf -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name *.objdump -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name corev_*.S -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name "*.o" -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name "*.hex" -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name "*.elf" -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name "*.map" -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name "*.itb" -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name "*.readelf" -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name "*.objdump" -exec rm {} \;
find $(CORE_V_VERIF)/$(CV_CORE_LC)/tests/programs -name "corev_*.S" -exec rm {} \;

.PHONY: clean clean_all distclean
clean: clean-sim-results clean-test-programs questa-clean verilate-clean vcs-clean firmware-clean dsim-clean xrun-clean vcs-clean riviera-clean
Expand Down
12 changes: 6 additions & 6 deletions mk/Common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,12 @@ endif
-S \
$*.elf > $*.objdump
$(RISCV_EXE_PREFIX)objdump \
-d \
-S \
-M no-aliases \
-M numeric \
-l \
$*.elf | ${CORE_V_VERIF}/bin/objdump2itb - > $*.itb
-d \
-S \
-M no-aliases \
-M numeric \
-l \
$*.elf | ${CORE_V_VERIF}/bin/objdump2itb - > $*.itb

# Patterned targets to generate ELF. Used only if explicit targets do not match.
#
Expand Down