Vproc_n1/test/makefile.ghdl
2024-09-27 10:15:39 +01:00

117 lines
3.4 KiB
Text

###################################################################
# Makefile for Virtual Processor VHDL testcode in GHDL
#
# Copyright (c) 2005-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_VHDL
SIMULATOR = -DGHDL
PLIVERSION =
VERIUSEROBJ =
SIMINCLUDEFLAG =
SIMFLAGSSO =
# Optional Memory model definitions
MEM_C =
MEMMODELDIR = .
# Common logic simulator flags
VPROC_TOP = test
WAVEFILE = waves.ghw
WAVESAVEFILE = $(WAVEFILE:%.ghw=%.gtkw)
WORKDIR = work
# Runtime flags for GHDL
SIMFLAGS = --std=08 --workdir=$(WORKDIR)
VHDLFILELIST = files_ghdl.tcl
VHDLFILES =$(foreach vhdlfile, $(file < $(VHDLFILELIST)), $(vhdlfile))
# Get OS type
OSTYPE := $(shell uname)
#------------------------------------------------------
# BUILD RULES
#------------------------------------------------------
all: vhdl
# Include common build rules
include makefile.common
${WORKDIR}:
@mkdir $(WORKDIR)
# Analyse the VHDL files
.PHONY: vhdl
vhdl: $(VPROC_PLI) $(WORKDIR)
@ghdl -a --std=08 --workdir=$(WORKDIR) $(VHDLFILES)
#------------------------------------------------------
# EXECUTION RULES
#------------------------------------------------------
run: vhdl
@ghdl --elab-run $(SIMFLAGS) $(VPROC_TOP)
rungui: vhdl
@ghdl --elab-run $(SIMFLAGS) $(VPROC_TOP) --wave=$(WAVEFILE)
@if [ -e $(WAVESAVEFILE) ]; then \
gtkwave -A $(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 $(VPROC_PLI) $(VLIB) $(VOBJDIR) *.o *.exe $(VPROC_TOP) $(WAVEFILE) work