2010年9月17日星期五

Makefile example

#***************************************************************************
#
# Author:      $SVF TG (auto generated)$
# File:        $Makefile$
# Revision:    $Revision:$
# Date:        $Date:$
#
#****************************************************************************/
## Variables and scripts
VIP    = ../../vips
APB    = $(VIP)/apb
APB_INC    = $(APB)/include
APB_SRC    = $(APB)/src
AXI    = $(VIP)/axi
AXI_INC    = $(AXI)/include
AXI_SRC    = $(AXI)/src
FWD    = $(VIP)/fwd
FWD_INC    = $(FWD)/include
FWD_SRC    = $(FWD)/src
MAC    = $(VIP)/mac
MAC_INC    = $(MAC)/include
MAC_SRC    = $(MAC)/src
ENV    = ../env
COMMON    = ../../common
COMMON_INC   = ../../common/include
COMMON_SRC   = ../../common/src
TEST_DIR   = .
# USER - Change this to point to your actual RTL code.
#   Also, for MTI, uncomment the vlog line in the run_mti section
#   once there is actual RTL code to run
DUT    = ../../../../../rtl
DUT_SRC    =
INC    = +incdir+$(COMMON_INC) \
      +incdir+$(COMMON_SRC) \
      +incdir+$(APB_INC) \
      +incdir+$(APB_SRC) \
      +incdir+$(AXI_INC) \
      +incdir+$(AXI_SRC) \
      +incdir+$(FWD_INC) \
      +incdir+$(FWD_SRC) \
      +incdir+$(MAC_INC) \
      +incdir+$(MAC_SRC) \
      +incdir+$(ENV) \
      +incdir+$(TEST_DIR)/basic \
      +incdir+$(TEST_DIR)/advanced \
      +incdir+$(TEST_DIR)
# If UVM_HOME is not set, then attempt to determine if it is distributed with
# the simulator.
ifeq ($(strip $(UVM_HOME)),)
  ifeq (test_mti,$(findstring test_mti,$(MAKECMDGOALS)))
    ERROR_MSG := Unable to determine UVM_HOME for Modelsim, please set UVM_HOME or MTI_HOME environment variable
    ifneq ($(strip $(MTI_HOME)),)
      UVM_HOME := /usr/proj/work/svf/nguo/uvm
      ifneq (${UVM_HOME},$(shell ls -d ${UVM_HOME} 2>&1))
        $(error $(ERROR_MSG))
      endif
    else
      $(error $(ERROR_MSG))
    endif
  endif
  ifeq (test_ius,$(findstring test_ius,$(MAKECMDGOALS)))
    ERROR_MSG := Unable to determine UVM_HOME for IUS, please set UVM_HOME environment variable
    NCROOT    := $(shell ncroot)
    UVM_HOME  := $(NCROOT)/tools/uvm
    ifneq (${UVM_HOME},$(shell ls -d ${UVM_HOME} 2>&1))
      $(error $(ERROR_MSG))
    endif
  endif
endif
ifneq ($(strip $(UVM_HOME)),)
UVM               = $(UVM_HOME)
else
UVM               = "<UVM_HOME UNDEFINED>"
endif
UVM_SRC_DIR   = $(UVM)/src
UVM_SRC       = $(UVM_SRC_DIR)/uvm_pkg.sv
UVM_MACRO_SRC = $(UVM_SRC_DIR)/uvm_macros.svh
UVM_VERSION   = "1_0"
ifneq ($(strip $(USE_SV_PACKAGE)),)
USE_SV_PACKAGE = 1
PKG_OPT     =   +define+USE_SV_PACKAGE
PKG_LIST    =   $(UVM_SRC) \
                $(COMMON_INC)/common_pkg.sv \
             $(APB_INC)/apb_pkg.sv \
             $(AXI_INC)/axi_pkg.sv \
             $(FWD_INC)/fwd_pkg.sv \
             $(MAC_INC)/mac_pkg.sv \
                $(ENV)/txd_pkg.sv
IUS_OPT     =
else
PKG_OPT     =
PKG_LIST    =
IUS_OPT     = $(UVM)/src/uvm.svh $(UVM_MACROS_SRC)
endif
TESTNAME          = test_example
SEED              = 1
TB_FILENAME       = $(ENV)/txd_tb_top.sv
VERBOSITY         = UVM_FULL
IUS_OPTIONS    =  \
      $(IUS_OPT) \
      +svseed=$(SEED) \
      +incdir+$(UVM_SRC_DIR) \
             $(INC) \
             -nowarn IGNFMT \
             +UVM_TESTNAME=$(TESTNAME) \
             +UVM_MSG_DETAIL=$(VERBOSITY) \
             $(PKG_OPT) \
             $(PKG_LIST) \
      +incdir+$(DUT) $(DUT_SRC) \
             $(TB_FILENAME)
VCS_OPTIONS   = -q +warn=noISALS \
  -sverilog \
  -timescale=1ns/100ps \
  $(INC) \
  +incdir+$(UVM_SRC_DIR) \
  +incdir+$(DUT) $(DUT_SRC) \
  $(COMPILE_OPT) \
  -Mdir=./csrc \
  -o simv \
                -Mupdate \
                -debug_pp \
         +libext+.sv+.v+.vh+.vmd+.vo+.bv+.lmcds \
                +v2k \
                +define+UVM_VERSION_STRING=$(UVM_VERSION) \
         +error+100 +lint=TMR
VCS_RUN_OPTIONS = +wc \
                  +notimingchecks \
                  +ntb_random_seed=$(SEED) \
           +UVM_TESTNAME=$(TESTNAME) \
    +UVM_MSG_DETAIL=$(VERBOSITY)

#******************************************************************************#
# Targets
#******************************************************************************#
help :
 @echo " ----------------------------------------------------------------";
 @echo "|             PW TEMPLATE GENERATOR EXAMPLE MAKEFILE             |";
 @echo " ----------------------------------------------------------------";
 @echo "|                                                                |";
 @echo "| Usage:                                                         |";
 @echo "|                                                                |";
 @echo "| make <target> [ TESTNAME=<testname> SEED=<num> USE_SV_PACKAGE  |";
 @echo "|               VERBOSITY=<verbosity_level> OPT=<user options> ] |";
 @echo "|                                                                |";
 @echo "| Mandatory Arguments:                                           |";
 @echo "| Available targets                                              |";
 @echo "|   test_ius    : Execute a test using cadence simulator.        |";
 @echo "|   test_mti    : Execute a test using mentor simulator.         |";
 @echo "|   test_vcs    : Execute a test using synopsys simulator.       |";
 @echo "|   clean       : Remove simulation files and directories.       |";
 @echo "|                                                                |";
 @echo "| Optional Arguments:                                            |";
 @echo "| To compile using SystemVerilog Packages use the following:     |";
 @echo "|  USE_SV_PACKAGE=1                                              |"
 @echo "|                                                                |";
 @echo "| Available verbosity_level for VERBOSITY                        |";
 @echo "|  UVM_NONE, UVM_LOW, UVM_MEDIUM, UVM_HIGH, UVM_FULL, or integer |";
 @echo "|  default is UVM_FULL                                           |";
 @echo "|                                                                |";
 @echo " ----------------------------------------------------------------";
test_ius   : clean run_ius check_test_ius
test_mti : clean run_mti check_test_mti
test_vcs : clean run_vcs check_test_vcs
clean:
 -rm -rf *.log *.df waves.shm INCA_libs *~ assertion_summary *.trn *.vcd simvision verilog.dump waves.shm irun.key irun.log* work transcript svp_work vsim.wlf csrc simv simv.daidir simv.vdb
run_ius :
 @echo "PKG LIST =  $(PKG_LIST)"
 @echo "USE_SV_PACKAGE =  $(USE_SV_PACKAGE)"
 irun $(IUS_OPTIONS) $(OPT)
run_mti:
 rm -rf work
 @echo "PKG LIST =  $(PKG_LIST)"
 @echo "USE_SV_PACKAGE =  $(USE_SV_PACKAGE)"
 vlib work
# vlog +incdir+$(DUT) $(DUT_SRC)
 vlog +incdir+$(UVM_SRC_DIR) \
        $(INC) \
        $(PKG_OPT) \
        $(PKG_LIST) \
 $(ENV)/txd_tb_top.sv
 vsim -do vsim.do -c -suppress 3829 -sv_seed $(SEED) +UVM_TESTNAME=$(TESTNAME) +UVM_MSG_DETAIL=$(VERBOSITY) $(OPT) txd_tb_top
run_vcs :
 @echo "PKG LIST =  $(PKG_LIST)"
 @echo "USE_SV_PACKAGE =  $(USE_SV_PACKAGE)"
 vcs +vcs+lic+wait $(VCS_OPTIONS) $(COMPILE_OPT) $(OPT) -l $(TESTNAME).log $(TB_FILENAME)
 ./simv $(VCS_RUN_OPTIONS) $(OPT) $(PKG_OPT) $(PKG_LIST) -l vrun.log
check_test_ius:
 @if test -f irun.log; then \
 if ( (grep "ERR" irun.log|grep -v "0">/dev/null) || (grep "WARN" irun.log|grep -v "0">/dev/null) || (grep "FATAL" irun.log|grep -v "0">/dev/null) ); then \
 echo "TEST FAILED - check irun.log file for details."; \
 else \
 echo "TEST PASSED";\
 fi; \
 else \
 echo "TEST FAILED - logfile irun.log does not exist."; \
 exit -1; \
 fi; \
 if test -f INCA_libs/svpplib/assertion_summary; then \
 mv INCA_libs/svpplib/assertion_summary .; \
 fi
check_test_mti:
 @if test -f transcript; then \
 if ( (grep "ERR" transcript|grep -v "0">/dev/null) || (grep "WARN" transcript|grep -v "0">/dev/null) || (grep "FATAL" transcript|grep -v "0">/dev/null) ); then \
 echo "TEST FAILED - check transcript file for details."; \
 else \
 echo "TEST PASSED";\
 fi; \
 else \
 echo "TEST FAILED - logfile transcript does not exist."; \
 exit -1; \
 fi;
check_test_vcs:
 @if test -f vrun.log; then \
 if ( (grep "ERR" vrun.log|grep -q "1") || (grep "WARN" vrun.log|grep -q "1") || (grep "FATAL" vrun.log|grep -q "1") ); then \
 echo "TEST FAILED - check vrun.log file for details."; \
 else \
 echo "TEST PASSED";\
 fi; \
 else \
 echo "TEST FAILED - logfile vrun.log does not exist."; \
 exit -1; \
 fi;

没有评论:

发表评论