diff --git a/code/VProc.h b/code/VProc.h index 3028f2a..7da6977 100644 --- a/code/VProc.h +++ b/code/VProc.h @@ -35,7 +35,7 @@ #include #include -#define VERSION_STRING "VProc version 1.8. Copyright (c) 2004-2024 Simon Southwell." +#define VERSION_STRING "VProc version 1.8.1 (dev). Copyright (c) 2004-2024 Simon Southwell." #ifndef VP_MAX_NODES #define VP_MAX_NODES 64 diff --git a/test/makefile b/test/makefile index c9a29f0..560684f 100644 --- a/test/makefile +++ b/test/makefile @@ -23,35 +23,64 @@ #------------------------------------------------------ # 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 +# Target HDL language (VERILOG | VHDL) +HDL = VERILOG # Simulator/Language specific C/C++ compile and link flags -ARCHFLAG = -m32 OPTFLAG = -g -HDLLANGUAGE = + +# User specific C/C++ compile flags +USRFLAGS = + +# User test source code file list +USER_C = VUserMain0.c \ + VUserMain1.cpp + +# Location of user code and test directories +USRCDIR = usercode +TESTDIR = . + +# Optional memory model (or other additional auxiliary code) definitions +MEM_C = +MEMMODELDIR = . + +#------------------------------------------------------ +# Internal variable definitions + +MAX_NUM_VPROC = 64 +SRCDIR = ../code +VOBJDIR = $(TESTDIR)/obj + +#------------------------------------------------------ +# Settings specific to target simulator + SIMULATOR = -DMODELSIM -PLIVERSION = -DVPROC_PLI_VPI VERIUSEROBJ = $(VOBJDIR)/veriuser.o SIMINCLUDEFLAG = -I$(MODEL_TECH)/../include SIMFLAGSSO = -L$(MODEL_TECH) -lmtipli -# Optional Memory model definitions -MEM_C = -MEMMODELDIR = . +# Get the help message from the simulator, filtered on Questa +SIMTYPE = $(shell vsim -help | grep -i questa) + +# If the SIMTYPE string is not empty, then this is Questa and a 64-bit compile, +# else assume it's ModelSim and do a 32-bit compile. +ifneq ("$(SIMTYPE)", "") + ARCHFLAG = -m64 +else + ARCHFLAG = -m32 +endif + +ifeq ("$(HDL)", "VHDL") + HDLLANGUAGE = -DVPROC_VHDL + HDLCMD = vcom -quiet -2008 -work work -f files.tcl + PLIVERSION = +else + HDLLANGUAGE = + HDLCMD = vlog +define+VPROC_BURST_IF +define+VPROC_BYTE_INTERFACE +incdir+../ -f test.vc + PLIVERSION = -DVPROC_PLI_VPI +endif # Common logic simulator flags -VLOGFLAGS = +define+VPROC_BURST_IF +define+VPROC_BYTE_INTERFACE +incdir+../ VPROC_TOP = test VSIMFLAGS = -pli $(VPROC_PLI) $(VPROC_TOP) @@ -75,34 +104,38 @@ ifeq ("$(MODEL_TECH)", "") MODEL_TECH = $(shell dirname $(PLILIBPATH)) endif +#------------------------------------------------------ +# Include common build rules +#------------------------------------------------------ + +include makefile.common + #------------------------------------------------------ # BUILD RULES #------------------------------------------------------ -all: verilog +all: hdl -# Include common build rules -include makefile.common - -# Let modelsim decide what's changed in the verilog -.PHONY: verilog -verilog: $(VPROC_PLI) +# Let the simulator decide what's changed in the HDL +.PHONY: hdl +hdl: $(VPROC_PLI) @if [ ! -d "./work" ]; then \ vlib work; \ fi - @vlog ${VLOGFLAGS} -f test.vc + @$(HDLCMD) + #------------------------------------------------------ # EXECUTION RULES #------------------------------------------------------ -sim: verilog +sim: hdl @vsim -c $(VSIMFLAGS) -run: verilog +run: hdl @vsim -c $(VSIMFLAGS) -do "run -all" -do "quit" -rungui: verilog +rungui: hdl @if [ -e wave.do ]; then \ vsim -gui -do wave.do $(VSIMFLAGS) -do "run -all"; \ else \ diff --git a/test/makefile.common b/test/makefile.common index 6083e76..d3df24c 100644 --- a/test/makefile.common +++ b/test/makefile.common @@ -43,8 +43,8 @@ # POSTVPROCSOFLAGS : Simulator specific flags for shared object compliation/linking post vproc library flag # Generated PLI C library -VPROC_PLI = ${TESTDIR}/VProc.so -VLIB = ${TESTDIR}/libvproc.a +VPROC_PLI = $(TESTDIR)/VProc.so +VLIB = $(TESTDIR)/libvproc.a # VPROC C source code VPROC_C = VSched.c VUser.c @@ -99,6 +99,8 @@ C++ = g++ # Build rules #------------------------------------------------------ +default: all + # Rule to build VProc C sources $(VOBJDIR)/%.o: $(SRCDIR)/%.c $(SRCDIR)/*.h @$(CC) -c -fPIC $(CFLAGS) $< -o $@ diff --git a/test/makefile.questa b/test/makefile.questa index 35ae018..5c5a8de 100644 --- a/test/makefile.questa +++ b/test/makefile.questa @@ -21,11 +21,31 @@ # ################################################################### -USRFLAGS = +################################################################### +# THIS FILE IS DEPRECATED AND IS FOR BACKWARDS COMPATIBILITY # +################################################################### -# Set up the common make command for the ModelSim makefile with -m64 -# set as the architecture flag -COMMONCMD = $(MAKE) --no-print-directory USRFLAGS=${USRFLAGS} ARCHFLAG=-m64 -f makefile +# User overridable variables +HDL = VERILOG +USRFLAGS = +OPTFLAG = -g +USER_C = VUserMain0.c VUserMain1.cpp +USRCDIR = usercode +TESTDIR = . +MEMC = +MEMMODELDIR = . + +# Set up the common make command for the ModelSim/Questa makefile +COMMONCMD = $(MAKE) --no-print-directory \ + HDL="$(HDL)" \ + USRFLAGS="$(USRFLAGS)" \ + OPTFLAG="$(OPTFLAG)" \ + USER_C="$(USER_C)" \ + USRCDIR="$(USRCDIR)" \ + TESTDIR="$(TESTDIR)" \ + MEMC="$(MEMC)" \ + MEMMODELDIR="$(MEMMODELDIR)" \ + -f makefile #------------------------------------------------------ # BUILD RULES diff --git a/test/makefile.vhd b/test/makefile.vhd index 2261c7b..29bf479 100644 --- a/test/makefile.vhd +++ b/test/makefile.vhd @@ -20,112 +20,56 @@ # ################################################################### -#------------------------------------------------------ -# User overridable definitions +################################################################### +# THIS FILE IS DEPRECATED AND IS FOR BACKWARDS COMPATIBILITY # +################################################################### -MAX_NUM_VPROC = 64 +# User overridable variables +HDL = VHDL USRFLAGS = -SRCDIR = ../code +OPTFLAG = -g +USER_C = VUserMain0.c VUserMain1.cpp 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 = -m32 -OPTFLAG = -g -HDLLANGUAGE = -DVPROC_VHDL -SIMULATOR = -DMODELSIM -PLIVERSION = -VERIUSEROBJ = $(VOBJDIR)/veriuser.o -SIMINCLUDEFLAG = -I$(MODEL_TECH)/../include -SIMFLAGSSO = -L$(MODEL_TECH) -lmtipli - -# Optional Memory model definitions -MEM_C = +MEMC = MEMMODELDIR = . -# Common flags for vsim -VPROC_TOP = test -VSIMFLAGS = -pli $(VPROC_PLI) $(VPROC_TOP) - -#------------------------------------------------------ -# MODEL_TECH path - -# Get OS type -OSTYPE:=$(shell uname) - -# If run from a place where MODEL_TECH is not defined, construct from path to PLI library -ifeq ("$(MODEL_TECH)", "") - ifeq ($(OSTYPE), Linux) - PLILIB = libmtipli.so - else - PLILIB = mtipli.dll - endif - - VSIMPATH = $(shell which vsim) - SIMROOT = $(shell dirname $(VSIMPATH))/.. - PLILIBPATH = $(shell find $(SIMROOT) -name "$(PLILIB)") - MODEL_TECH = $(shell dirname $(PLILIBPATH)) -endif +# Set up the common make command for the ModelSim/Questa makefile +COMMONCMD = $(MAKE) --no-print-directory \ + HDL="$(HDL)" \ + USRFLAGS="$(USRFLAGS)" \ + OPTFLAG="$(OPTFLAG)" \ + USER_C="$(USER_C)" \ + USRCDIR="$(USRCDIR)" \ + TESTDIR="$(TESTDIR)" \ + MEMC="$(MEMC)" \ + MEMMODELDIR="$(MEMMODELDIR)" \ + -f makefile #------------------------------------------------------ # BUILD RULES #------------------------------------------------------ -all: vhdl - -# Include common build rules -include makefile.common - -# Let modelsim decide what's changed in the VHDL -.PHONY: vhdl -vhdl: $(VPROC_PLI) - @if [ ! -d "./work" ]; then \ - vlib work; \ - fi - @vcom -quiet -2008 -f files.tcl -work work +all: + @$(COMMONCMD) #------------------------------------------------------ # EXECUTION RULES #------------------------------------------------------ -sim: vhdl - @vsim -c $(VSIMFLAGS) +sim: + @$(COMMONCMD) sim -run: vhdl - @vsim -c $(VSIMFLAGS) -do "run -all" -do "quit" +run: + @$(COMMONCMD) run -rungui: vhdl - @if [ -e wave.do ]; then \ - vsim -gui -do wave.do $(VSIMFLAGS) -do "run -all"; \ - else \ - vsim -gui $(VSIMFLAGS); \ - fi +rungui: + @$(COMMONCMD) rungui gui: rungui -.SILENT: help: - @$(info make help Display this message) - @$(info make Build C/C++ and HDL code without running simulation) - @$(info make sim Build and run command line interactive (sim not started)) - @$(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 -#------------------------------------------------------ + @$(COMMONCMD) help clean: - @rm -rf $(VPROC_PLI) $(VLIB) $(VOBJDIR) *.wlf transcript - @if [ -d "./work" ]; then \ - vdel -all; \ - fi - + @$(COMMONCMD) clean