File: launch_modelsim.sh

package info (click to toggle)
uhd 4.9.0.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 184,180 kB
  • sloc: cpp: 262,887; python: 112,011; ansic: 102,670; vhdl: 57,031; tcl: 19,924; xml: 8,581; makefile: 3,028; sh: 2,812; pascal: 230; javascript: 120; csh: 94; asm: 20; perl: 11
file content (98 lines) | stat: -rwxr-xr-x 3,104 bytes parent folder | download
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
#!/bin/bash

#------------------------------------------
# Colorize
#------------------------------------------

# VIV_COLOR_SCHEME must be defined in the environment setup script
case "$VIV_COLOR_SCHEME" in
    default)
        CLR_OFF='tput sgr0'
        ERR_CLR='tput setaf 1'
        WARN_CLR='tput setaf 3'
        INFO_CLR='tput setaf 6'
        ;;
    *)
        CLR_OFF=''
        ERR_CLR=$CLR_OFF
        WARN_CLR=$CLR_OFF
        INFO_CLR=$CLR_OFF
esac

# Display output string colorized
function print_color {
    case $line in
        *Fatal:*|*Failure:*)
            eval $ERR_CLR; echo "$line"; eval $CLR_OFF
            ;;
        *Error:*|*Error[[:space:]]\(suppressible\):*)
            eval $ERR_CLR; echo "$line"; eval $CLR_OFF
            ;;
        *Warning:*)
            eval $WARN_CLR; echo "$line"; eval $CLR_OFF
            ;;
        *Info:*|*Note:*)
            eval $INFO_CLR; echo "$line"; eval $CLR_OFF
            ;;
        *)
            echo "$line"
    esac
}

#------------------------------------------
# Launch ModelSim
#------------------------------------------

SCRIPT_DIR=$(dirname "$(realpath "$0")")

# Setting -onfinish to "final" ensures final blocks run and prevents the
# simulator from trying to exit immediately when $finish() is called, which is
# not desirable in the GUI.
MSIM_DEFAULT="-quiet -L unisims_ver -onfinish final"

# Use specified modelsim.ini, if set
if [[ -z $MSIM_MODELSIM_INI ]]; then
    MODELSIMINI_ARG=""
else
    MODELSIMINI_ARG="-modelsimini $MSIM_MODELSIM_INI"
fi

cd $MSIM_PROJ_DIR

# Generate the library options string
MSIM_LIB_ARGS=
for lib in $MSIM_LIBS
do
    MSIM_LIB_ARGS+="-L $lib "
done

if [ $MSIM_MODE == "gui" ]; then
    if [ $MSIM_VARIANT == "questa" ]; then
        echo "* Launching Visualizer GUI"
        MSIM_DEFAULT+=" -voptargs=\"-debug,events,livesim +designfile\" -visualizer -qwavedb=+signal+memory+vhdlvariable+class"
    else
        echo "* Launching classic GUI"
        MSIM_DEFAULT+=" -voptargs=+acc"
    fi
    # Use stdbuf to line buffer the pipe and avoid long block buffering delays
    stdbuf -oL -eL vsim $MSIM_DEFAULT $MODELSIMINI_ARG $MSIM_ARGS $MSIM_LIB_ARGS $MSIM_SIM_TOP 2>&1 | while IFS= read -r line; do
        print_color $line
    done
    exit_status=${PIPESTATUS[0]}
    if [ ${exit_status} -ne 0 ]; then exit ${exit_status}; fi
elif [ $MSIM_MODE == "batch" ]; then
    if [ $MSIM_VARIANT == "questa" ]; then
        echo "* Launching Questa batch mode"
    else
        echo "* Launching ModelSim batch mode"
        # Using +acc for GUI and batch sim ensures we get the same behavior in
        # both, with the downside that simulation might be slower.
        MSIM_DEFAULT+=" -voptargs=+acc"
    fi
    # Use stdbuf to line buffer the pipe and avoid long block buffering delays
    stdbuf -oL -eL vsim -batch -do $SCRIPT_DIR/modelsim.do $MODELSIMINI_ARG $MSIM_DEFAULT $MSIM_ARGS $MSIM_LIB_ARGS $MSIM_SIM_TOP 2>&1 | while IFS= read -r line; do
        print_color $line
    done
    exit_status=${PIPESTATUS[0]}
    if [ ${exit_status} -ne 0 ]; then exit ${exit_status}; fi
fi