OpenCores
URL https://opencores.org/ocsvn/amber/amber/trunk

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [isim/] [run.sh] - Blame information for rev 82

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 63 csantifort
#!/bin/bash
2
 
3
#--------------------------------------------------------------#
4
#                                                              #
5
#  run.sh                                                      #
6
#                                                              #
7
#  This file is part of the Amber project                      #
8
#  http://www.opencores.org/project,amber                      #
9
#                                                              #
10
#  Description                                                 #
11
#  Run a Verilog simulation using Modelsim                     #
12
#                                                              #
13
#  Author(s):                                                  #
14
#      - Conor Santifort, csantifort.amber@gmail.com           #
15
#                                                              #
16
#//////////////////////////////////////////////////////////////#
17
#                                                              #
18
# Copyright (C) 2013 Authors and OPENCORES.ORG                 #
19
#                                                              #
20
# This source file may be used and distributed without         #
21
# restriction provided that this copyright statement is not    #
22
# removed from the file and that any derivative work contains  #
23
# the original copyright notice and the associated disclaimer. #
24
#                                                              #
25
# This source file is free software; you can redistribute it   #
26
# and/or modify it under the terms of the GNU Lesser General   #
27
# Public License as published by the Free Software Foundation; #
28
# either version 2.1 of the License, or (at your option) any   #
29
# later version.                                               #
30
#                                                              #
31
# This source is distributed in the hope that it will be       #
32
# useful, but WITHOUT ANY WARRANTY; without even the implied   #
33
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      #
34
# PURPOSE.  See the GNU Lesser General Public License for more #
35
# details.                                                     #
36
#                                                              #
37
# You should have received a copy of the GNU Lesser General    #
38
# Public License along with this source; if not, download it   #
39
# from http://www.opencores.org/lgpl.shtml                     #
40
#                                                              #
41
#--------------------------------------------------------------#
42
 
43
#--------------------------------------------------------
44
# Defaults
45
#--------------------------------------------------------
46
AMBER_LOAD_MAIN_MEM=" "
47
AMBER_TIMEOUT=0
48
AMBER_LOG_FILE="tests.log"
49
SET_G=0
50
SET_M=0
51
SET_T=0
52
SET_S=0
53
SET_5=0
54
SET_L=0
55
 
56
 
57
# show program usage
58
show_usage() {
59
    echo "Usage:"
60
    echo "run <test_name> [-a] [-g] [-d] [-t] [-s] [-v]"
61
    echo " -h : Help"
62
    echo " -g : Use ISIM GUI"
63
    echo " -l : Create dump of complete design"
64
    echo " -s : Use Xilinx Spatran6 Libraries (slower sim)"
65
    echo " -5 : Use Amber25 core instead of Amber23 core"
66
    echo ""
67
    exit
68
}
69
 
70
 
71
#--------------------------------------------------------
72
# Parse command-line options
73
#--------------------------------------------------------
74
 
75
# Minimum number of arguments needed by this program
76
MINARGS=1
77
 
78
# show usage if '-h' or  '--help' is the first argument or no argument is given
79
case $1 in
80
        ""|"-h"|"--help"|"help"|"?") show_usage ;;
81
esac
82
 
83
# get the number of command-line arguments given
84
ARGC=$#
85
 
86
# check to make sure enough arguments were given or exit
87
if [[ $ARGC -lt $MINARGS ]] ; then
88
 echo "Too few arguments given (Minimum:$MINARGS)"
89
 echo
90
 show_usage
91
fi
92
 
93
# self-sorting argument types LongEquals, ShortSingle, ShortSplit, and ShortMulti
94
# process command-line arguments
95
while [ "$1" ]
96
do
97
    case $1 in
98
        -*)  true ;
99
            case $1 in
100
                -s)     SET_S=1   # Xilinx Spartan6 libs
101
                        shift ;;
102
                -5)     SET_5=1   # Amber25 core (default is Amber23 core)
103
                        shift ;;
104
                -g)     SET_G=1   # Bring up GUI
105
                        shift ;;
106
                -l)     SET_L=1   # Create wave dump file
107
                        shift ;;
108
                -*)
109
                        echo "Unrecognized argument $1"
110
                        shift ;;
111
            esac ;;
112
        * ) AMBER_TEST_NAME=$1
113
            shift ;;
114
 
115
    esac
116
done
117
 
118
 
119
if [ $SET_5 == 1 ]; then
120 82 csantifort
    AMBER_CORE="AMBER_A25_CORE"
121 63 csantifort
else
122 82 csantifort
    AMBER_CORE="AMBER_A23_CORE"
123 63 csantifort
fi
124
 
125
 
126
 
127
#--------------------------------------------------------
128
# Compile the test
129
#--------------------------------------------------------
130
 
131
# First check if its an assembly test
132
if [ -f ../tests/${AMBER_TEST_NAME}.S ]; then
133
    # hw-test
134
    TEST_TYPE=1
135
elif [ ${AMBER_TEST_NAME} == vmlinux ]; then
136
    TEST_TYPE=3
137
elif [ -d ../../sw/${AMBER_TEST_NAME} ]; then
138
    # Does this test type need the boot-loader ?
139
    if [ -e ../../sw/${AMBER_TEST_NAME}/sections.lds ]; then
140
        grep 8000 ../../sw/${AMBER_TEST_NAME}/sections.lds > /dev/null
141
        if [ $? == 0 ]; then
142
            # Needs boot loader, starts at 0x8000
143
            TEST_TYPE=4
144
        else
145
            TEST_TYPE=2
146
        fi
147
    else
148
        TEST_TYPE=2
149
    fi
150
else
151
    echo "Test ${AMBER_TEST_NAME} not found"
152
    exit
153
fi
154
 
155
echo "Test ${AMBER_TEST_NAME}, type $TEST_TYPE"
156
 
157
# Uncompress the vmlinux.mem file
158
if [ $TEST_TYPE == 3 ]; then
159
    pushd ../../sw/${AMBER_TEST_NAME} > /dev/null
160
    if [ ! -e vmlinux.mem ]; then
161
        bzip2 -dk vmlinux.mem.bz2
162
        bzip2 -dk vmlinux.dis.bz2
163
    fi
164
    popd > /dev/null
165
fi
166
 
167
 
168
# Now compile the test
169
if [ $TEST_TYPE == 1 ]; then
170
    # hw assembly test
171
    echo "Compile ../tests/${AMBER_TEST_NAME}.S"
172
    pushd ../tests > /dev/null
173
    make --quiet TEST=${AMBER_TEST_NAME}
174
    MAKE_STATUS=$?
175
 
176
    popd > /dev/null
177
    BOOT_MEM_FILE="../tests/${AMBER_TEST_NAME}.mem"
178
 
179
    if [ $SET_5 == 1 ]; then
180
        BOOT_MEM_PARAMS_FILE="../tests/${AMBER_TEST_NAME}_memparams128.v"
181
    else
182
        BOOT_MEM_PARAMS_FILE="../tests/${AMBER_TEST_NAME}_memparams32.v"
183
    fi
184
 
185
elif [ $TEST_TYPE == 2 ]; then
186
    # sw Stand-alone C test
187
    pushd ../../sw/${AMBER_TEST_NAME} > /dev/null
188
    make CPPFLAGS=-DSIM_MODE
189
    MAKE_STATUS=$?
190
    popd > /dev/null
191
    BOOT_MEM_FILE="../../sw/${AMBER_TEST_NAME}/${AMBER_TEST_NAME}.mem"
192
    if [ $SET_5 == 1 ]; then
193
        BOOT_MEM_PARAMS_FILE="../../sw/${AMBER_TEST_NAME}/${AMBER_TEST_NAME}_memparams128.v"
194
    else
195
        BOOT_MEM_PARAMS_FILE="../../sw/${AMBER_TEST_NAME}/${AMBER_TEST_NAME}_memparams32.v"
196
    fi
197
 
198
elif [ $TEST_TYPE == 3 ] || [ $TEST_TYPE == 4 ]; then
199
    # sw test using boot loader
200 67 csantifort
    pushd ../../sw/boot-loader-serial > /dev/null
201 63 csantifort
    make
202
    MAKE_STATUS=$?
203
    popd > /dev/null
204
    if [ $MAKE_STATUS != 0 ]; then
205 67 csantifort
        echo "Error compiling boot-loader-serial"
206 63 csantifort
        exit 1
207
    fi
208
 
209
    pushd ../../sw/${AMBER_TEST_NAME} > /dev/null
210
    if [ -e Makefile ]; then
211
        make
212
    fi
213
    MAKE_STATUS=$?
214
    popd > /dev/null
215
 
216 67 csantifort
    BOOT_MEM_FILE="../../sw/boot-loader-serial/boot-loader-serial.mem"
217 63 csantifort
    if [ $SET_5 == 1 ]; then
218 67 csantifort
        BOOT_MEM_PARAMS_FILE="../../sw/boot-loader-serial/boot-loader-serial_memparams128.v"
219 63 csantifort
    else
220 67 csantifort
        BOOT_MEM_PARAMS_FILE="../../sw/boot-loader-serial/boot-loader-serial_memparams32.v"
221 63 csantifort
    fi
222
    MAIN_MEM_FILE="../../sw/${AMBER_TEST_NAME}/${AMBER_TEST_NAME}.mem"
223
    AMBER_LOAD_MAIN_MEM="-d AMBER_LOAD_MAIN_MEM"
224
 
225
else
226
    echo "Error unrecognized test type"
227
fi
228
 
229
if [ $MAKE_STATUS != 0 ]; then
230
    echo "Failed " $AMBER_TEST_NAME " compile error" >> $AMBER_LOG_FILE
231
    exit
232
fi
233
 
234
 
235
 
236
#--------------------------------------------------------
237
# ISIM
238
#--------------------------------------------------------
239
fuse tb -o amber-test.exe -prj amber-isim.prj \
240 82 csantifort
  -d $AMBER_CORE \
241 63 csantifort
  -d BOOT_MEM_FILE=\"$BOOT_MEM_FILE\" \
242
  -d BOOT_MEM_PARAMS_FILE=\"$BOOT_MEM_PARAMS_FILE\" \
243
  -d MAIN_MEM_FILE=\"$MAIN_MEM_FILE\" \
244
  -d AMBER_LOG_FILE=\"$AMBER_LOG_FILE\" \
245
  -d AMBER_TEST_NAME=\"$AMBER_TEST_NAME\" \
246
  -d AMBER_SIM_CTRL=$TEST_TYPE \
247
  -d AMBER_TIMEOUT=$AMBER_TIMEOUT \
248
  $AMBER_LOAD_MAIN_MEM \
249
  -incremental \
250
  -i ../vlog/lib \
251
  -i ../vlog/system \
252
  -i ../vlog/amber23 \
253
  -i ../vlog/amber25 \
254
  -i ../vlog/tb
255
 
256
if [ $? != 0 ]; then exit; fi
257
 
258
if [ $SET_G == 1 ]; then
259
        ./amber-test.exe -tclbatch run.do -gui
260
else
261
        ./amber-test.exe -tclbatch run.do
262
fi
263
 
264
 
265
# Set a timeout value for the test if it passed
266
if [ $TEST_TYPE == 1 ]; then
267
    tail -1 < ${AMBER_LOG_FILE} | grep Passed > /dev/null
268
    if [ $? == 0 ]; then
269
        TICKS=`tail -1 < ${AMBER_LOG_FILE} | awk '{print $3}'`
270
        TOTICKS=$(( $TICKS * 4 + 1000 ))
271
        ../tools/set_timeout.sh ${AMBER_TEST_NAME} $TOTICKS
272 82 csantifort
    else
273
        # return non-zero on test fail
274
        exit 1
275 63 csantifort
    fi
276
fi
277
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.