164 lines
No EOL
5 KiB
Text
164 lines
No EOL
5 KiB
Text
###################################################################
|
|
# Makefile for VProc Virtual Processor and mem_model testcode
|
|
# in GHDL
|
|
#
|
|
# 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/>.
|
|
#
|
|
###################################################################
|
|
|
|
# MODEL_TECH environment variable must be set
|
|
|
|
# User C/C++ overridable flags
|
|
USRFLAGS =
|
|
USER_C = VUserMain0.c
|
|
USRCDIR = usercode
|
|
BUSTYPE = AVALON
|
|
|
|
# User simulation overridable flags
|
|
USRSIMFLAGS =
|
|
|
|
VPROCDIR = ../..
|
|
TESTDIR = $(CURDIR)
|
|
VOBJDIR = $(TESTDIR)/obj
|
|
MEMMODELDIR = $(CURDIR)/../../../mem_model
|
|
MEMMODELREPO = https://github.com/wyvernSemi/mem_model.git
|
|
|
|
# VProc C source code
|
|
VPROC_C = VSched.c VUser.c
|
|
|
|
# Memory model C source code
|
|
MEM_C = mem.c mem_model.c
|
|
|
|
# Generated PLI C library
|
|
VPROC_PLI = $(TESTDIR)/VProc.so
|
|
|
|
# Get OS type
|
|
OSTYPE:=$(shell uname)
|
|
|
|
# Set OS specific variables between Linux and Windows (MSYS2/mingw-w64)
|
|
ifeq ($(OSTYPE), Linux)
|
|
CFLAGS_SO = -shared -lpthread -lrt -rdynamic
|
|
CPPSTD = -std=c++11
|
|
else
|
|
CFLAGS_SO = -shared -Wl,-export-all-symbols
|
|
CPPSTD =
|
|
endif
|
|
|
|
CFLAGS = $(USRFLAGS) \
|
|
-I$(MEMMODELDIR)/src \
|
|
-DMEM_ZERO_NEW_PAGES \
|
|
-DINCL_VLOG_MEM_MODEL \
|
|
-DMEM_MODEL_DEFAULT_ENDIAN=1 \
|
|
$(HDLFLAG)
|
|
|
|
# Simulation configuration
|
|
|
|
HDLFLAG =
|
|
|
|
ifeq ("$(BUSTYPE)", "AXI")
|
|
FILELIST = files_axi_ghdl.tcl
|
|
SIM_TOP = testaxi
|
|
HDLFLAG += -DAXI
|
|
else ifeq ("$(BUSTYPE)", "AHB")
|
|
FILELIST = files_ahb_ghdl.tcl
|
|
SIM_TOP = testahb
|
|
HDLFLAG += -DAHB
|
|
else ifeq ("$(BUSTYPE)", "APB")
|
|
FILELIST = files_apb_ghdl.tcl
|
|
SIM_TOP = testapb
|
|
else
|
|
FILELIST = files_av_ghdl.tcl
|
|
SIM_TOP = testavm
|
|
endif
|
|
|
|
WAVEFILE = waves.ghw
|
|
WAVESAVEFILE = $(WAVEFILE:%.ghw=%.gtkw)
|
|
WORKDIR = work
|
|
|
|
SIMFLAGS = --std=08 --workdir=$(WORKDIR)
|
|
|
|
VHDLFILES = $(foreach vhdlfile, $(file < $(FILELIST)), $(vhdlfile))
|
|
|
|
SPACE =
|
|
|
|
#------------------------------------------------------
|
|
# BUILD RULES
|
|
#------------------------------------------------------
|
|
|
|
all: hdl
|
|
|
|
$(VPROC_PLI):
|
|
@make --no-print-directory \
|
|
-C $(VPROCDIR)/test \
|
|
-f makefile.ghdl \
|
|
USRFLAGS="$(CFLAGS)" \
|
|
USRCDIR=$(CURDIR)/$(USRCDIR) \
|
|
USER_C="$(USER_C)" \
|
|
MEMMODELDIR="$(MEMMODELDIR)/src" \
|
|
MEM_C="$(MEM_C)" \
|
|
TESTDIR=$(TESTDIR)
|
|
|
|
$(MEMMODELDIR):
|
|
@git clone $(MEMMODELREPO) $(MEMMODELDIR) --recursive
|
|
|
|
$(WORKDIR):
|
|
@mkdir $(WORKDIR)
|
|
|
|
# Let simulator decide what's changed in the HDL
|
|
hdl: $(VPROC_PLI) $(WORKDIR)
|
|
@ghdl -a --std=08 --workdir=$(WORKDIR) $(VHDLFILES)
|
|
|
|
#------------------------------------------------------
|
|
# EXECUTION RULES
|
|
#------------------------------------------------------
|
|
|
|
run: hdl
|
|
@ghdl --elab-run $(SIMFLAGS) $(SIM_TOP) --ieee-asserts=disable
|
|
|
|
rungui: hdl
|
|
@ghdl --elab-run $(SIMFLAGS) $(SIM_TOP) --ieee-asserts=disable --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)
|
|
@$(info $(SPACE))
|
|
@$(info Command line options:)
|
|
@$(info $(SPACE) BUSTYPE=[AVALON|APB|AHB|AXI])
|
|
@$(info $(SPACE))
|
|
|
|
#------------------------------------------------------
|
|
# CLEANING RULES
|
|
#------------------------------------------------------
|
|
|
|
clean:
|
|
@make --no-print-directory \
|
|
-C $(VPROCDIR)/test \
|
|
-f makefile.ghdl \
|
|
TESTDIR=$(TESTDIR) \
|
|
clean
|
|
@rm -rf $(VPROC_PLI) $(VLIB) $(VOBJDIR) *.o *.exe $(VPROC_TOP) $(WAVEFILE) work |