| 1 | include $(INSTALL_DIR)/tools/inca/files/Makefile.nc.defines |
| 2 | # Uncomment the following line to use the GCC compiler |
| 3 | USE_COMPILER = gcc |
| 4 | # Uncomment the following line to use the C++ compiler to link shared libs |
| 5 | USE_LINKER = gcc |
| 6 | include $(INSTALL_DIR)/tools/inca/files/Makefile.nc.$(ARCH) |
| 7 | ################# PUT ALL USER MACROS AFTER THIS LINE ################# |
| 8 | |
| 9 | # |
| 10 | # Makefile.nc |
| 11 | # |
| 12 | # This makefile can be used as a template makefile for statically or |
| 13 | # dynamically linking PLI/VPI, LMSI, or SWIFT code into the NC-Verilog tools |
| 14 | # For C++ Rules and Macros refer to 'C++ HOWTO' in this file. |
| 15 | # |
| 16 | # All of the defines in this Makefile also exist in |
| 17 | # $(INSTALL_DIR)/tools/inca/files/Makefile.nc.defines |
| 18 | # By modifying them here, you will override the default values there. |
| 19 | # |
| 20 | # Any targets that you do not need can be safely deleted from this file. |
| 21 | # |
| 22 | |
| 23 | # |
| 24 | # The TARGETDIR macro should be set to the directory where the resulting |
| 25 | # executables should be placed. This defaults to the current directory. |
| 26 | # |
| 27 | TARGETDIR=. |
| 28 | |
| 29 | # Shared libraries |
| 30 | VPILIB = $(TARGETDIR)/libvpi.$(SHARED_LIB_POSTFIX) |
| 31 | # PLILIB = $(TARGETDIR)/libpli.$(SHARED_LIB_POSTFIX) |
| 32 | PLILIB = $(TARGETDIR)/libutilitypli.$(SHARED_LIB_POSTFIX) |
| 33 | VHPILIB = $(TARGETDIR)/libvhpi.$(SHARED_LIB_POSTFIX) |
| 34 | CFCLIB = $(TARGETDIR)/libcfc.$(SHARED_LIB_POSTFIX) |
| 35 | FMILIB = $(TARGETDIR)/libfmi.$(SHARED_LIB_POSTFIX) |
| 36 | DPILIB = $(TARGETDIR)/libdpi.$(SHARED_LIB_POSTFIX) |
| 37 | |
| 38 | # |
| 39 | # Set this to the set of targets that you want executed. For example, if |
| 40 | # you want to create a libpli.so file, then set it to: |
| 41 | # |
| 42 | FIRST_TARGET = $(PLILIB) |
| 43 | |
| 44 | # |
| 45 | # Specify any defines that you want set by uncommenting the USR_DEFINES |
| 46 | # Macro below. All defines should have a '-D' prefix to work properly |
| 47 | # e.g. INCA, INCA_test, MYTEST and ETC are defined below. |
| 48 | # |
| 49 | # USR_DEFINES = -DINCA -DINCA_test -DMYTEST -DETC |
| 50 | |
| 51 | # |
| 52 | # The VPI_USER_C macro should be set to the vpi_user.c file containing any |
| 53 | # user defined 'C' routines for use with VPI (PLI 2.0). |
| 54 | # vpi_user.c can be copied from $(INSTALL_DIR)/tools/inca/src/vpi_user.c |
| 55 | # |
| 56 | VPI_USER_C = ./vpi_user.c |
| 57 | VPI_USER_O = $(TARGETDIR)/vpi_user.$(OBJ_POSTFIX) |
| 58 | |
| 59 | # |
| 60 | # The VPI_OBJECTS_SAFE macro should be set to the object files which you do |
| 61 | # not want deleted in "clean" target. |
| 62 | # |
| 63 | VPI_OBJECTS_SAFE = |
| 64 | |
| 65 | # |
| 66 | # Add any VPI objects which need to be compiled, and can be deleted using the |
| 67 | # "clean" target here: |
| 68 | # |
| 69 | VPI_OBJECTS = |
| 70 | |
| 71 | # |
| 72 | # Add any library linking options needed to resolve external references for |
| 73 | # the VPILIB shared library |
| 74 | # |
| 75 | VPI_EXTERN_LIBS = |
| 76 | |
| 77 | # |
| 78 | # The VERIUSER_C macro should be set to the veriuser.c file containing any |
| 79 | # user defined 'C' routines for use with PLI 1.0. |
| 80 | # veriuser.c can be copied from $(INSTALL_DIR)/tools/inca/src/veriuser.c |
| 81 | # |
| 82 | VERIUSER_C = ./veriuser.c |
| 83 | VERIUSER_O = $(TARGETDIR)/veriuser.$(OBJ_POSTFIX) |
| 84 | |
| 85 | # |
| 86 | # The PLI_OBJECTS_SAFE macro should be set to the object files which you do |
| 87 | # not want deleted in "clean" target. |
| 88 | # |
| 89 | PLI_OBJECTS_SAFE = $(DV_ROOT)/verif/env/common/pli/bwutility/loadpli/libutility_loadpli.a |
| 90 | |
| 91 | # |
| 92 | # Add any PLI objects which need to be compiled, and can be deleted using the |
| 93 | # "clean" target here: |
| 94 | # |
| 95 | PLI_OBJECTS = |
| 96 | |
| 97 | # |
| 98 | # Add any library linking options needed to resolve external references for |
| 99 | # the PLILIB shared library |
| 100 | # |
| 101 | PLI_EXTERN_LIBS = |
| 102 | |
| 103 | # |
| 104 | # The VHPI_OBJECTS_SAFE macro should be set to the object files which you do |
| 105 | # not want deleted in "clean" target. |
| 106 | # |
| 107 | VHPI_OBJECTS_SAFE = |
| 108 | |
| 109 | # |
| 110 | # Add any VHPI objects which need to be compiled, and can be deleted using the |
| 111 | # "clean" target here: |
| 112 | # |
| 113 | VHPI_OBJECTS = |
| 114 | |
| 115 | # |
| 116 | # Add any library linking options needed to resolve external references for |
| 117 | # the VHPILIB shared library |
| 118 | # |
| 119 | VHPI_EXTERN_LIBS = |
| 120 | |
| 121 | # |
| 122 | # The CFC_OBJECTS_SAFE macro should be set to the object files which you do |
| 123 | # not want deleted in "clean" target. |
| 124 | # |
| 125 | CFC_OBJECTS_SAFE = |
| 126 | |
| 127 | # |
| 128 | # Add any CFC objects which need to be compiled, and can be deleted using the |
| 129 | # "clean" target here: |
| 130 | # |
| 131 | CFC_OBJECTS = |
| 132 | |
| 133 | # |
| 134 | # Add any library linking options needed to resolve external references for |
| 135 | # the CFCLIB shared library |
| 136 | # |
| 137 | CFC_EXTERN_LIBS = |
| 138 | |
| 139 | # |
| 140 | # The FMI_OBJECTS_SAFE macro should be set to the object files which you do |
| 141 | # not want deleted in "clean" target. |
| 142 | # |
| 143 | FMI_OBJECTS_SAFE = |
| 144 | |
| 145 | # |
| 146 | # Add any FMI objects which need to be compiled, and can be deleted using the |
| 147 | # "clean" target here: |
| 148 | # |
| 149 | FMI_OBJECTS = |
| 150 | |
| 151 | # |
| 152 | # Add any library linking options needed to resolve external references for |
| 153 | # the FMILIB shared library |
| 154 | # |
| 155 | FMI_EXTERN_LIBS = |
| 156 | |
| 157 | # |
| 158 | # The DPI_OBJECTS_SAFE macro should be set to the object files which you do |
| 159 | # not want deleted in "clean" target. |
| 160 | # |
| 161 | DPI_OBJECTS_SAFE = |
| 162 | |
| 163 | # |
| 164 | # Add any DPI objects which need to be compiled, and can be deleted using the |
| 165 | # "clean" target here: |
| 166 | # |
| 167 | DPI_OBJECTS = |
| 168 | |
| 169 | # |
| 170 | # Add any library linking options needed to resolve external references for |
| 171 | # the DPILIB shared library |
| 172 | # |
| 173 | DPI_EXTERN_LIBS = |
| 174 | |
| 175 | DPI_USER_C = ./_sv_export.c |
| 176 | DPI_USER_O = $(TARGETDIR)/_sv_export.$(OBJ_POSTFIX) |
| 177 | |
| 178 | # |
| 179 | # LMC_HOME is set to the swift installation |
| 180 | # Shared library path environment variable should be set to include the |
| 181 | # path of the swift shared library. |
| 182 | # |
| 183 | LMC_HOME = |
| 184 | |
| 185 | # |
| 186 | # The SFI_ROOT macro should be set to the lmsi installation |
| 187 | # |
| 188 | SFI_ROOT = |
| 189 | |
| 190 | # |
| 191 | # The NCELAB macro should be set to the name of the elaborator which should |
| 192 | # be generated by the static link. |
| 193 | # |
| 194 | NCELAB = $(TARGETDIR)/ncelab |
| 195 | |
| 196 | # |
| 197 | # The NCSIM macro should be set to the name of the simulator which should |
| 198 | # be generated by the static link. |
| 199 | # |
| 200 | NCSIM = $(TARGETDIR)/ncsim |
| 201 | |
| 202 | # |
| 203 | # The TARGETS macro should be set to pli/vpi objects/executables with statically |
| 204 | # linked PLI/VPI objects |
| 205 | # |
| 206 | PLI_O_TARGETS = $(VERIUSER_O) $(PLI_OBJECTS) $(PLI_OBJECTS_SAFE) |
| 207 | VPI_O_TARGETS = $(VPI_USER_O) $(VPI_OBJECTS) $(VPI_OBJECTS_SAFE) |
| 208 | VHPI_O_TARGETS = $(VHPI_OBJECTS) $(VHPI_OBJECTS_SAFE) |
| 209 | DPI_O_TARGETS = $(DPI_OBJECTS) $(DPI_OBJECTS_SAFE) |
| 210 | |
| 211 | # To add PLI 1.0 applications when linking statically, add $(PLI_O_TARGETS) to |
| 212 | # the O_TARGETS list below. |
| 213 | # |
| 214 | # To add VPI applications when linking statically, add $(VPI_O_TARGETS) to |
| 215 | # the O_TARGETS list below. |
| 216 | # |
| 217 | # To add VHPI applications when linking statically, add $(VHPI_O_TARGETS) to |
| 218 | # the O_TARGETS list below. |
| 219 | # |
| 220 | #O_TARGETS = $(PLI_O_TARGETS) $(VPI_O_TARGETS) $(VHPI_O_TARGETS) |
| 221 | |
| 222 | O_TARGETS = |
| 223 | |
| 224 | # The CFC_O_TARGETS and FMI_O_TARGETS should be set to CFC/FMI objects/ |
| 225 | # executables with statically linked CFC/FMI objects respectively |
| 226 | CFC_O_TARGETS = $(CFC_OBJECTS) $(CFC_OBJECTS_SAFE) |
| 227 | FMI_O_TARGETS = $(FMI_OBJECTS) $(FMI_OBJECTS_SAFE) |
| 228 | |
| 229 | # To add CFC applications to ncsim when linking statically, add $(CFC_O_TARGETS) |
| 230 | # to the NCSIM_O_TARGETS list below. |
| 231 | # |
| 232 | # To add FMI applications to ncsim when linking statically, add $(FMI_O_TARGETS) |
| 233 | # to the NCSIM_O_TARGETS list below. |
| 234 | |
| 235 | NCSIM_O_TARGETS = \ |
| 236 | $(CFC_OBJECTS) $(CFC_OBJECTS_SAFE) \ |
| 237 | $(FMI_OBJECTS) $(FMI_OBJECTS_SAFE) |
| 238 | |
| 239 | TARGETS = $(NCELAB) $(NCSIM) |
| 240 | |
| 241 | # DYNAMIC LINKING |
| 242 | |
| 243 | # Begin targets for PLI/VPI dynamic linking |
| 244 | # The dynamic target builds the NC executables for debugging with shared |
| 245 | # libraries |
| 246 | # The shared_libs target builds the VPI and PLI shared libraries. |
| 247 | # |
| 248 | |
| 249 | DYN_TARGETS = $(NCELAB)_dynamic $(NCSIM)_dynamic |
| 250 | |
| 251 | # |
| 252 | # |
| 253 | # |
| 254 | # C++ HOWTO |
| 255 | # |
| 256 | # History: |
| 257 | # The Elaborator as well as the Simulator routines are written in C. |
| 258 | # The supporting library routines are written in C too. However, there |
| 259 | # are applications which have been written using C++. There are |
| 260 | # some 3rd party vendors that have written their IP in C++ too. We |
| 261 | # therefore need a way to integrate all of this into a single Elaborator |
| 262 | # executable and a single Simulator executable. |
| 263 | # |
| 264 | # In order for C++ objects to be properly integrated with the ncelab and |
| 265 | # ncsim objects (i.e. ncelab.$(OBJ_POSTFIX) and ncsim.$(OBJ_POSTFIX)) it |
| 266 | # is required that the main() routine be compiled using C++. That was |
| 267 | # the motivation for the following set of Rules and Macros. |
| 268 | # |
| 269 | # Gotchas: |
| 270 | # There are some quirks that you should be aware of before integrating |
| 271 | # the C++ routines. |
| 272 | # |
| 273 | # o You should ensure that the same C++ compiler is used to compile all |
| 274 | # of the code, including the IP's provided by 3rd party vendor's. |
| 275 | # It is not possible for a user.cc, compiled using CC and vendor.cc, |
| 276 | # compiled using gcc, to be integrated together, due to name-mangling and |
| 277 | # various other issues. |
| 278 | # |
| 279 | # o The routines and variables in your C++ code that are used in veriuser.c |
| 280 | # and vpi_user.c, should be explicitly declared in your C++ code as an |
| 281 | # 'extern "C"'. This tells the C++ compiler not to mangle the names that |
| 282 | # will eventually be used in routines compiled using a C compiler. e.g. |
| 283 | # File: veriuser.c |
| 284 | # ---------------- |
| 285 | # extern int hello_world(int); |
| 286 | # s_tfcell veriusertfs[TF_MAXARRAY] = { |
| 287 | # {usertask, 0, 0, 0, (int (*)())hello_world, 0, "$hello_world", 1 }, |
| 288 | # 0 |
| 289 | # }; |
| 290 | # |
| 291 | # File: user_code.cc |
| 292 | # ------------------- |
| 293 | # extern "C" int hello_world(int); |
| 294 | # extern "C" void io_printf(char*); |
| 295 | # int hello_world(int foo) { io_printf("Hello World\n"); return(foo);} |
| 296 | # |
| 297 | # o If you intend on including some of the VPI/PLI include files, you |
| 298 | # should ensure that proper defines are put in place. e.g. |
| 299 | # File: user_code.cc |
| 300 | # ------------------- |
| 301 | # #define PROTO_PARAMS(params) params |
| 302 | # #define PLI_EXTERN extern "C" |
| 303 | # #include <stdio.h> |
| 304 | # #include "vpi_user.h" |
| 305 | # #undef PROTO_PARAMS |
| 306 | # #undef PLI_EXTERN |
| 307 | # /* Other routines and declarations. */ |
| 308 | # |
| 309 | # o '.cc' is the assumed extension of all the C++ files used here. You |
| 310 | # should make appropriate corrections if you are using different |
| 311 | # extensions, via the CC_EXTENSION macro. |
| 312 | # |
| 313 | # o You should copy over main.cc and veriuser.c and/or vpi_user.c from |
| 314 | # $(INSTALL_DIR)/tools/inca/src and make the appropriate changes before |
| 315 | # using them. |
| 316 | # |
| 317 | # o You should remember to modify the following macros as appropriate. |
| 318 | # CCC -> To specify the C++ compiler (Default: CC) |
| 319 | # CCFLAGS -> Flags for the C++ compiler (Default: CFLAGS) |
| 320 | # CC_EXTENSION -> Extensions for C++ files (Default: .cc) |
| 321 | # TARGETDIR -> Directory where targets will be put (Default: .) |
| 322 | # VPI_USER_C -> Your vpi_user.c file if any (Default: ./vpi_user.c) |
| 323 | # VERIUSER_C -> Your veriuser.c file if any (Default: ./veriuser.c) |
| 324 | # CCC_MAIN_CC -> main.cc copied from $(INSTALL_DIR)/tools/inca/src |
| 325 | # CCC_OBJECTS -> Objects created from your C++ files |
| 326 | # |
| 327 | |
| 328 | |
| 329 | # |
| 330 | # The CCC_MAIN_CC macro should be set to the main.cc file containing the |
| 331 | # main() routine. This topmost routine should be compiled using a C++ |
| 332 | # compiler. It can be copied from $(INSTALL_DIR)/tools/inca/src/main.cc. |
| 333 | # If copied to another location make appropriate changes to following macros. |
| 334 | # |
| 335 | CCC_MAIN_CC = $(INSTALL_DIR)/tools/inca/src/main.$(CC_EXTENSION) |
| 336 | CCC_MAIN_O = main.$(OBJ_POSTFIX) |
| 337 | |
| 338 | |
| 339 | # |
| 340 | # The CCC_OBJECTS macro should be populated with the names of your |
| 341 | # C++ files' objects. For example: |
| 342 | # If your sources are foo1.cc and foo2.cc then |
| 343 | # CCC_OBJECTS = foo1.$(OBJ_POSTFIX) foo2.$(OBJ_POSTFIX) |
| 344 | # These objects will be deleted by the 'clean' target. |
| 345 | # |
| 346 | CCC_OBJECTS = |
| 347 | |
| 348 | |
| 349 | # |
| 350 | # The CCC_OBJECTS_SAFE macro should be populated with the names of your |
| 351 | # C++ files' objects. For example: |
| 352 | # If your sources are foo1.cc and foo2.cc then |
| 353 | # CCC_OBJECTS_SAFE = foo1.$(OBJ_POSTFIX) foo2.$(OBJ_POSTFIX) |
| 354 | # These objects will *NOT* be deleted by the 'clean' target. |
| 355 | # |
| 356 | CCC_OBJECTS_SAFE = |
| 357 | |
| 358 | |
| 359 | # |
| 360 | # The OCCC_TARGETS macro should be set to pli/vpi objects |
| 361 | # OCCC_TARGETS = $(VPI_USER_O) $(VERIUSER_O) $(CCC_OBJECTS) $(CCC_OBJECTS_SAFE) |
| 362 | # |
| 363 | OCCC_TARGETS = |
| 364 | |
| 365 | CCC_TARGETS = $(NCELAB)C $(NCSIM)C |
| 366 | |
| 367 | ################# PUT ALL USER MACROS BEFORE THIS LINE ################# |
| 368 | include $(INSTALL_DIR)/tools/inca/files/Makefile.nc.targets |