149 lines
4.7 KiB
Text
149 lines
4.7 KiB
Text
###################################################################
|
|
# Makefile for Virtual Processor SystemVerilog for Verilator
|
|
#
|
|
# Copyright (c) 2024 Simon Southwell.
|
|
#
|
|
# This file is part of VProc.
|
|
#
|
|
# VProc is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# VProc is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with VProc. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
###################################################################
|
|
|
|
#------------------------------------------------------
|
|
# User overridable definitions
|
|
|
|
MAX_NUM_VPROC = 64
|
|
USRFLAGS =
|
|
SRCDIR = ../code
|
|
USRCDIR = usercode
|
|
TESTDIR = .
|
|
VOBJDIR = $(TESTDIR)/obj
|
|
|
|
# User test source code file list
|
|
USER_C = VUserMain0.c VUserMain1.cpp
|
|
|
|
#------------------------------------------------------
|
|
# Settings specific to target simulator
|
|
|
|
# Simulator/Language specific C/C++ compile and link flags
|
|
ARCHFLAG = -m64
|
|
OPTFLAG = -g
|
|
HDLLANGUAGE = -DVPROC_SV
|
|
SIMULATOR = -DVERILATOR
|
|
SIMINCLUDEFLAG =
|
|
USRSIMFLAGS =
|
|
|
|
# Get OS type
|
|
OSTYPE := $(shell uname)
|
|
|
|
ifeq (${OSTYPE}, Linux)
|
|
SIMFLAGSSO = -Wl,-E -lrt -rdynamic
|
|
else
|
|
SIMFLAGSSO = -Wl,-export-all-symbols
|
|
endif
|
|
|
|
# Optional Memory model definitions
|
|
MEM_C =
|
|
MEMMODELDIR = .
|
|
|
|
# Optional auxilary user code definitions
|
|
AUX_C =
|
|
AUXDIR = .
|
|
|
|
#......................................................
|
|
# Common logic simulator flags
|
|
#.....................................................
|
|
|
|
# Top level module name
|
|
VPROC_TOP = test
|
|
|
|
# Set to +define+VPROC_BURST_IF for burst interface, or blank for none
|
|
BURSTDEF = +define+VPROC_BURST_IF +define+VPROC_BYTE_ENABLE
|
|
|
|
# set to -GVCD_DUMP=1 to generate VCD ouput, or blank for none
|
|
VCDFLAG = -GVCD_DUMP=1
|
|
|
|
# Set to -GFINISH=1 for $finish at execution end, or blank for $stop
|
|
# (Verilator generates an error on $stop)
|
|
FINISHFLAG = -GFINISH=1
|
|
|
|
# Set to --timing for delta cycle support, or -GDISABLE_DELTA for no delta-cycle
|
|
TIMINGFLAG = --timing
|
|
|
|
# C++ version 20 required for Verilator
|
|
CPPSTD = -std=c++20
|
|
|
|
# Compilation flags for Verilator
|
|
SIMFLAGS = --binary -sv --trace \
|
|
$(FINISHFLAG) \
|
|
$(TIMINGFLAG) \
|
|
$(VCDFLAG) $(BURSTDEF) \
|
|
$(USRSIMFLAGS) \
|
|
-Mdir work -I../ -Wno-WIDTH \
|
|
--top $(VPROC_TOP) \
|
|
-MAKEFLAGS "--quiet" \
|
|
-CFLAGS "$(CPPSTD) -Wno-attributes" \
|
|
-LDFLAGS "$(SIMFLAGSSO) \
|
|
-Wl,-whole-archive -L../ -lvproc -Wl,-no-whole-archive -ldl"
|
|
|
|
SIMEXE = work/V$(VPROC_TOP)
|
|
FILELIST = files.verilator
|
|
|
|
WAVEFILE = waves.vcd
|
|
WAVESAVEFILE = wave.gtkw
|
|
|
|
#------------------------------------------------------
|
|
# BUILD RULES
|
|
#------------------------------------------------------
|
|
|
|
all: sysverilog
|
|
|
|
# Include common build rules
|
|
include makefile.common
|
|
|
|
# Analyse SystemVerilog files
|
|
.PHONY: sysverilog
|
|
sysverilog: $(VLIB)
|
|
@verilator -F $(FILELIST) $(SIMFLAGS)
|
|
|
|
#------------------------------------------------------
|
|
# EXECUTION RULES
|
|
#------------------------------------------------------
|
|
|
|
run: sysverilog
|
|
@$(SIMEXE)
|
|
|
|
rungui: sysverilog
|
|
@$(SIMEXE)
|
|
@if [ -e $(WAVESAVEFILE) ]; then \
|
|
gtkwave -a $(WAVESAVEFILE) $(WAVEFILE); \
|
|
else \
|
|
gtkwave $(WAVEFILE); \
|
|
fi
|
|
|
|
gui: rungui
|
|
|
|
help:
|
|
@$(info make help Display this message)
|
|
@$(info make Build C/C++ and HDL code without running simulation)
|
|
@$(info make run Build and run batch simulation)
|
|
@$(info make rungui/gui Build and run GUI simulation)
|
|
@$(info make clean clean previous build artefacts)
|
|
|
|
#------------------------------------------------------
|
|
# CLEANING RULES
|
|
#------------------------------------------------------
|
|
|
|
clean:
|
|
@rm -rf $(VLIB) $(VOBJDIR) waves.fst work $(WAVEFILE)
|