From 844de1745beb7f484239f0f5d443e5457744f09c Mon Sep 17 00:00:00 2001 From: Sadoon Albader Date: Fri, 8 Sep 2023 17:47:41 +0300 Subject: [PATCH] verilator optimizations up to 25% speedup --- Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Makefile b/Makefile index b764793..cca51a6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,14 @@ GHDL ?= ghdl GHDLFLAGS=--std=08 -frelaxed CFLAGS=-O3 -Wall + +ifeq ($(shell uname -m),ppc64le) +CFLAG_ARCH_OPT=-mcpu=native +else +CFLAG_ARCH_OPT=-march=native +endif + +CFLAGS=-O3 -Wall $(CFLAG_ARCH_OPT) -mtune=native CXXFLAGS=-g -g GHDLSYNTH ?= ghdl.so @@ -250,6 +258,7 @@ microwatt.v: $(synth_files) $(RAM_INIT_FILE) $(YOSYS) -m $(GHDLSYNTH) -p "ghdl --std=08 --no-formal $(GHDL_IMAGE_GENERICS) $(GHDL_TARGET_GENERICS) $(synth_files) -e toplevel; write_verilog $@" THREADS=1 # How many threads should be used for verilator binary +THREADS=3 # How many threads should be used for verilator binary, 3 is optimal # Need to investigate why yosys is hitting verilator warnings, and eventually turn on -Wall # --top-module toplevel microwatt-verilator: microwatt.v verilator/microwatt-verilator.cpp verilator/uart-verilator.c @@ -266,6 +275,11 @@ microwatt-verilator: microwatt.v verilator/microwatt-verilator.cpp verilator/uar -Wno-WIDTH \ --savable \ --trace \ + --threads-dpi all --x-initial fast \ + -CFLAGS $(CFLAG_ARCH_OPT) \ + -CFLAGS -mtune=native \ + -CFLAGS -O3 \ + # -CFLAGS -flto #disabled for now, no measured performance benefit \ # --unroll-count 256 \ # --output-split 5000 \ # --output-split-cfuncs 500 \ -- 2.30.2