diff --git a/common.mk b/common.mk index 75dc55d..8dc8ef1 100644 --- a/common.mk +++ b/common.mk @@ -13,6 +13,7 @@ NUMACTL=#numactl -m 0 -C 0,1 -- ifeq "${QUIET}" "1" QUIET_AS = @echo ' AS '$@; + QUIET_CC = @echo ' CC '$@; QUIET_VVP = @echo ' VVP '$@; QUIET_IVERILOG = @echo ' IVERILOG '$@; QUIET_VERILATOR = @echo ' VERILATOR '$@; diff --git a/system/Makefile b/system/Makefile index bee2bba..cdb7321 100644 --- a/system/Makefile +++ b/system/Makefile @@ -29,14 +29,31 @@ MICROCODE=ucode.txt NO_ASM=0 include ../common.mk +#build options +VERILATOR_OPTS += --cc --exe + +#binary options +VERILATOR_OPTS += --trace-fst --threads 1 --autoflush + +#linter options +VERILATOR_OPTS += -Wall --Wno-DECLFILENAME -Wno-SYNCASYNCNET -Wno-MULTIDRIVEN + +#optimisation options +VERILATOR_OPTS += -x-assign fast --x-initial fast +#For testing use: +#VERILATOR_OPTS=-x-assign unique --x-initial unique + # COMPILING ${SYSTEM_VVP} : ${TOP_LEVEL_SOURCE} ${SOURCES} ${INCLUDES} ${EVENT_SIM_TESTBENCH} ${QUIET_IVERILOG} ${Q}iverilog -g2012 -o "$@" ${TOP_LEVEL_SOURCE} ${SOURCES} ${EVENT_SIM_TESTBENCH} -${VERILATOR_BIN}: ${VERILATOR_TESTBENCH} ${TOP_LEVEL_SOURCE} ${SOURCES} ${INCLUDES} +${VERILATOR_BIN}: ${VERILATOR_BIN}.mk + ${Q}make ${MAKEOPTS} OPT_FAST="-O2 -march=native -mtune=native" -C obj_dir -f ../verilator_makefile Vsystem + +${VERILATOR_BIN}.mk: ${VERILATOR_TESTBENCH} ${TOP_LEVEL_SOURCE} ${SOURCES} ${INCLUDES} ${QUIET_VERILATOR} - ${Q}verilator --trace-fst --cc --exe --build -j 0 $^ -Wall --Wno-DECLFILENAME -Wno-SYNCASYNCNET -Wno-MULTIDRIVEN 2>&1 --threads 1 --autoflush >/dev/null #TODO: remove the silencing and make the generated Makefiles print quietly as well + ${Q}verilator ${VERILATOR_OPTS} $^ .PHONY: clean clean: diff --git a/system/verilator_makefile b/system/verilator_makefile new file mode 100644 index 0000000..c149dc7 --- /dev/null +++ b/system/verilator_makefile @@ -0,0 +1,21 @@ +# This file is basicly to make verilator compilation look pretty. +# If the project doesn't compile it might be because verilator handles compilation +# differently and this patch doesn't work anymore. In such case remove everything +# except the include Vsystem.mk line and try again. +VM_DEFAULT_RULES=0 + +include Vsystem.mk + +include ../../common.mk + +%.o: %.cpp + ${QUIET_CC} + ${Q}$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $< + +$(VK_SLOW_OBJS): %.o: %.cpp + ${QUIET_CC} + ${Q}$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_SLOW) -c -o $@ $< + +$(VK_GLOBAL_OBJS): %.o: %.cpp + ${QUIET_CC} + ${Q}$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_GLOBAL) -c -o $@ $<