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

Subversion Repositories amber

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

Go to most recent revision | 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_A=0
54
SET_5=0
55
SET_L=0
56
 
57
 
58
# show program usage
59
show_usage() {
60
    echo "Usage:"
61
    echo "run <test_name> [-a] [-g] [-d] [-t] [-s] [-v]"
62
    echo " -h : Help"
63
    echo " -a : Run hardware tests (all tests in \$AMBER_BASE/hw/tests)"
64
    echo " -g : Use ISIM GUI"
65
    echo " -l : Create dump of complete design"
66
    echo " -s : Use Xilinx Spatran6 Libraries (slower sim)"
67
    echo " -5 : Use Amber25 core instead of Amber23 core"
68
    echo ""
69
    exit
70
}
71
 
72
 
73
#--------------------------------------------------------
74
# Parse command-line options
75
#--------------------------------------------------------
76
 
77
# Minimum number of arguments needed by this program
78
MINARGS=1
79
 
80
# show usage if '-h' or  '--help' is the first argument or no argument is given
81
case $1 in
82
        ""|"-h"|"--help"|"help"|"?") show_usage ;;
83
esac
84
 
85
# get the number of command-line arguments given
86
ARGC=$#
87
 
88
# check to make sure enough arguments were given or exit
89
if [[ $ARGC -lt $MINARGS ]] ; then
90
 echo "Too few arguments given (Minimum:$MINARGS)"
91
 echo
92
 show_usage
93
fi
94
 
95
# self-sorting argument types LongEquals, ShortSingle, ShortSplit, and ShortMulti
96
# process command-line arguments
97
while [ "$1" ]
98
do
99
    case $1 in
100
        -*)  true ;
101
            case $1 in
102
                -a)     SET_A=1   # all tests
103
                        shift ;;
104
                -s)     SET_S=1   # Xilinx Spartan6 libs
105
                        shift ;;
106
                -5)     SET_5=1   # Amber25 core (default is Amber23 core)
107
                        shift ;;
108
                -g)     SET_G=1   # Bring up GUI
109
                        shift ;;
110
                -l)     SET_L=1   # Create wave dump file
111
                        shift ;;
112
                -*)
113
                        echo "Unrecognized argument $1"
114
                        shift ;;
115
            esac ;;
116
        * ) AMBER_TEST_NAME=$1
117
            shift ;;
118
 
119
    esac
120
done
121
 
122
 
123
if [ $SET_5 == 1 ]; then
124
    AMBER_CORE="+define+AMBER_A25_CORE"
125
else
126
    AMBER_CORE=" "
127
fi
128
 
129
 
130
 
131
#--------------------------------------------------------
132
# Compile the test
133
#--------------------------------------------------------
134
 
135
# First check if its an assembly test
136
if [ -f ../tests/${AMBER_TEST_NAME}.S ]; then
137
    # hw-test
138
    TEST_TYPE=1
139
elif [ ${AMBER_TEST_NAME} == vmlinux ]; then
140
    TEST_TYPE=3
141
elif [ -d ../../sw/${AMBER_TEST_NAME} ]; then
142
    # Does this test type need the boot-loader ?
143
    if [ -e ../../sw/${AMBER_TEST_NAME}/sections.lds ]; then
144
        grep 8000 ../../sw/${AMBER_TEST_NAME}/sections.lds > /dev/null
145
        if [ $? == 0 ]; then
146
            # Needs boot loader, starts at 0x8000
147
            TEST_TYPE=4
148
        else
149
            TEST_TYPE=2
150
        fi
151
    else
152
        TEST_TYPE=2
153
    fi
154
else
155
    echo "Test ${AMBER_TEST_NAME} not found"
156
    exit
157
fi
158
 
159
echo "Test ${AMBER_TEST_NAME}, type $TEST_TYPE"
160
 
161
# Uncompress the vmlinux.mem file
162
if [ $TEST_TYPE == 3 ]; then
163
    pushd ../../sw/${AMBER_TEST_NAME} > /dev/null
164
    if [ ! -e vmlinux.mem ]; then
165
        bzip2 -dk vmlinux.mem.bz2
166
        bzip2 -dk vmlinux.dis.bz2
167
    fi
168
    popd > /dev/null
169
fi
170
 
171
 
172
# Now compile the test
173
if [ $TEST_TYPE == 1 ]; then
174
    # hw assembly test
175
    echo "Compile ../tests/${AMBER_TEST_NAME}.S"
176
    pushd ../tests > /dev/null
177
    make --quiet TEST=${AMBER_TEST_NAME}
178
    MAKE_STATUS=$?
179
 
180
    popd > /dev/null
181
    BOOT_MEM_FILE="../tests/${AMBER_TEST_NAME}.mem"
182
 
183
    if [ $SET_5 == 1 ]; then
184
        BOOT_MEM_PARAMS_FILE="../tests/${AMBER_TEST_NAME}_memparams128.v"
185
    else
186
        BOOT_MEM_PARAMS_FILE="../tests/${AMBER_TEST_NAME}_memparams32.v"
187
    fi
188
 
189
elif [ $TEST_TYPE == 2 ]; then
190
    # sw Stand-alone C test
191
    pushd ../../sw/${AMBER_TEST_NAME} > /dev/null
192
    make CPPFLAGS=-DSIM_MODE
193
    MAKE_STATUS=$?
194
    popd > /dev/null
195
    BOOT_MEM_FILE="../../sw/${AMBER_TEST_NAME}/${AMBER_TEST_NAME}.mem"
196
    if [ $SET_5 == 1 ]; then
197
        BOOT_MEM_PARAMS_FILE="../../sw/${AMBER_TEST_NAME}/${AMBER_TEST_NAME}_memparams128.v"
198
    else
199
        BOOT_MEM_PARAMS_FILE="../../sw/${AMBER_TEST_NAME}/${AMBER_TEST_NAME}_memparams32.v"
200
    fi
201
 
202
elif [ $TEST_TYPE == 3 ] || [ $TEST_TYPE == 4 ]; then
203
    # sw test using boot loader
204
    pushd ../../sw/boot-loader > /dev/null
205
    make
206
    MAKE_STATUS=$?
207
    popd > /dev/null
208
    if [ $MAKE_STATUS != 0 ]; then
209
        echo "Error compiling boot-loader"
210
        exit 1
211
    fi
212
 
213
    pushd ../../sw/${AMBER_TEST_NAME} > /dev/null
214
    if [ -e Makefile ]; then
215
        make
216
    fi
217
    MAKE_STATUS=$?
218
    popd > /dev/null
219
 
220
    BOOT_MEM_FILE="../../sw/boot-loader/boot-loader.mem"
221
    if [ $SET_5 == 1 ]; then
222
        BOOT_MEM_PARAMS_FILE="../../sw/boot-loader/boot-loader_memparams128.v"
223
    else
224
        BOOT_MEM_PARAMS_FILE="../../sw/boot-loader/boot-loader_memparams32.v"
225
    fi
226
    MAIN_MEM_FILE="../../sw/${AMBER_TEST_NAME}/${AMBER_TEST_NAME}.mem"
227
    AMBER_LOAD_MAIN_MEM="-d AMBER_LOAD_MAIN_MEM"
228
 
229
else
230
    echo "Error unrecognized test type"
231
fi
232
 
233
if [ $MAKE_STATUS != 0 ]; then
234
    echo "Failed " $AMBER_TEST_NAME " compile error" >> $AMBER_LOG_FILE
235
    exit
236
fi
237
 
238
 
239
 
240
#--------------------------------------------------------
241
# ISIM
242
#--------------------------------------------------------
243
fuse tb -o amber-test.exe -prj amber-isim.prj \
244
  -d BOOT_MEM_FILE=\"$BOOT_MEM_FILE\" \
245
  -d BOOT_MEM_PARAMS_FILE=\"$BOOT_MEM_PARAMS_FILE\" \
246
  -d MAIN_MEM_FILE=\"$MAIN_MEM_FILE\" \
247
  -d AMBER_LOG_FILE=\"$AMBER_LOG_FILE\" \
248
  -d AMBER_TEST_NAME=\"$AMBER_TEST_NAME\" \
249
  -d AMBER_SIM_CTRL=$TEST_TYPE \
250
  -d AMBER_TIMEOUT=$AMBER_TIMEOUT \
251
  $AMBER_LOAD_MAIN_MEM \
252
  -incremental \
253
  -i ../vlog/lib \
254
  -i ../vlog/system \
255
  -i ../vlog/amber23 \
256
  -i ../vlog/amber25 \
257
  -i ../vlog/tb
258
 
259
if [ $? != 0 ]; then exit; fi
260
 
261
if [ $SET_G == 1 ]; then
262
        ./amber-test.exe -tclbatch run.do -gui
263
else
264
        ./amber-test.exe -tclbatch run.do
265
fi
266
 
267
 
268
# Set a timeout value for the test if it passed
269
if [ $TEST_TYPE == 1 ]; then
270
    tail -1 < ${AMBER_LOG_FILE} | grep Passed > /dev/null
271
    if [ $? == 0 ]; then
272
        TICKS=`tail -1 < ${AMBER_LOG_FILE} | awk '{print $3}'`
273
        TOTICKS=$(( $TICKS * 4 + 1000 ))
274
        ../tools/set_timeout.sh ${AMBER_TEST_NAME} $TOTICKS
275
    fi
276
fi
277
 

powered by: WebSVN 2.1.0

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