-
Notifications
You must be signed in to change notification settings - Fork 3
/
makefile.avhdl
175 lines (140 loc) · 5.36 KB
/
makefile.avhdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File Name: makefile
# Purpose: make file for compiling cosimulation shared object
# for Active-HDL
# Revision: OSVVM MODELS STANDARD VERSION
#
# Maintainer: Simon Southwell email: [email protected]
# Contributor(s):
# Simon Southwell email: [email protected]
#
# Description
# Make file supporting compiling of Co-simuation C/C++ code
# using make
#
# Revision History:
# Date Version Description
# 10/2022 2023.01 Initial version
#
# This file is part of OSVVM.
#
# Copyright (c) 2022 by [OSVVM Authors](AUTHORS.md)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# --------------------------------------------------------------------------
#
# User overridable variables: make VAR=NEW_VALUE ...
#
# USRCDIR : Directory where the test source directory is located
# OPDIR : Directory for compilation output
# USRFLAGS : Additional user defined compile and link flags
# AVHDLCDIR : Location of Active-HDL installation
#
# --------------------------------------------------------------------------
USRCDIR = usercode
OPDIR = .
USRFLAGS =
AVHDLCDIR = /c/Aldec/Active-HDL-13-x64
# Derived directory locations
SRCDIR = code
TESTDIR = ${OPDIR}
VOBJDIR = ${TESTDIR}/obj
# VPROC C source code
VPROC_C = $(wildcard ${SRCDIR}/*.c*)
VPROC_C_BASE = $(notdir $(filter %c, ${VPROC_C}))
VPROC_CPP_BASE = $(notdir $(filter %cpp, ${VPROC_C}))
# Test user code
USER_C = $(wildcard ${USRCDIR}/*.c*)
EXCLFILE =
USER_CPP_BASE = $(patsubst ${EXCLFILE},,$(notdir $(filter %cpp, ${USER_C})))
USER_C_BASE = $(notdir $(filter %c, ${USER_C}))
#$(info ${USRCDIR})
SRC_INCL = $(wildcard ${SRCDIR}/*.h)
USER_INCL = $(wildcard ${USRCDIR}/*.h)
VOBJS = $(addprefix ${VOBJDIR}/, ${VPROC_C_BASE:%.c=%.o} ${VPROC_CPP_BASE:%.cpp=%.o})
VUOBJS = $(addprefix ${VOBJDIR}/, ${USER_C_BASE:%.c=%.o} ${USER_CPP_BASE:%.cpp=%.o})
AVHDLFLAGS = -m64 -DALDEC -DACTIVEHDL -I${ALDECDIR}/pli/Include -L${ALDECDIR}/pli/Lib -l:aldecpli.lib
RV32EXE = test.exe
RV32CMD = cp ${USRCDIR}/test.exe ${OPDIR}
ifneq ("$(wildcard ${USRCDIR}/test.exe)", "")
RV32TEST = ${RV32EXE}
else
RV32TEST = dummy
endif
# Generated PLI C library
VPROC_PLI = ${OPDIR}/VProc.so
VLIB = ${TESTDIR}/libvproc.a
VULIB = ${TESTDIR}/libvuser.a
# Get OS type
OSTYPE:=$(shell uname)
# Set OS specific variables between Linux and Windows (MinGW)
ifeq (${OSTYPE}, Linux)
CFLAGS_SO = -shared -lpthread -lrt -rdynamic
WLIB =
else
CFLAGS_SO = -shared -Wl,-export-all-symbols
WLIB = -lWs2_32
endif
# Define the maximum number of supported VProcs in the compile pli library
MAX_NUM_VPROC = 16
CC = gcc
C++ = g++
CPPSTD = -std=c++11
CCSTD = -std=c99
CFLAGS = ${AVHDLFLAGS} \
-g \
-I${SRCDIR} \
-I${USRCDIR} \
-DVP_MAX_NODES=${MAX_NUM_VPROC} \
-D_REENTRANT
#------------------------------------------------------
# BUILD RULES
#------------------------------------------------------
all: ${VPROC_PLI}
${VOBJDIR}/%.o: ${SRCDIR}/%.c ${SRC_INCL}
@${CC} -c ${CCSTD} ${CFLAGS} ${USRFLAGS} $< -o $@
${VOBJDIR}/%.o: ${SRCDIR}/%.cpp ${SRC_INCL}
@${C++} -c ${CPPSTD} ${CFLAGS} ${USRFLAGS} $< -o $@
${VOBJDIR}/%.o: ${USRCDIR}/%.c ${USER_INCL}
@${CC} -Wno-write-strings -c ${CCSTD} ${CFLAGS} ${USRFLAGS} $< -o $@
${VOBJDIR}/%.o: ${USRCDIR}/%.cpp ${USER_INCL}
@${C++} ${CPPSTD} -Wno-write-strings -c ${CFLAGS} ${USRFLAGS} $< -o $@
${VLIB} : ${VOBJS} ${VOBJDIR}
@ar cr ${VLIB} ${VOBJS}
${VULIB} : ${VUOBJS} ${VOBJDIR}
@ar cr ${VULIB} ${VUOBJS}
${VOBJS}: | ${VOBJDIR}
${VUOBJS}: | ${VOBJDIR}
${VOBJDIR}:
@mkdir ${VOBJDIR}
${OPDIR}:
@mkdir ${OPDIR}
${RV32EXE}:
@${RV32CMD}
.PHONY: dummy
dummy:
${VPROC_PLI}: ${VLIB} ${VULIB} ${RV32TEST}
@${C++} ${CPPSTD} \
${CFLAGS_SO} \
-Wl,-whole-archive \
${CFLAGS} \
${USRFLAGS} \
-L${TESTDIR} -lvproc -lvuser \
-Wl,-no-whole-archive \
${WLIB} \
-o $@
#------------------------------------------------------
# CLEANING RULES
#------------------------------------------------------
clean:
@rm -rf ${VPROC_PLI} ${VUSER_PLI} ${VLIB} ${VULIB} ${VOBJS} ${VOBJDIR} ${RV32EXE}