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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [bin/] [msp430sim] - Blame information for rev 202

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 73 olivier.gi
#!/bin/bash
2 2 olivier.gi
#------------------------------------------------------------------------------
3
# Copyright (C) 2001 Authors
4
#
5
# This source file may be used and distributed without restriction provided
6
# that this copyright statement is not removed from the file and that any
7
# derivative work contains the original copyright notice and the associated
8
# disclaimer.
9
#
10
# This source file is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU Lesser General Public License as published
12
# by the Free Software Foundation; either version 2.1 of the License, or
13
# (at your option) any later version.
14
#
15
# This source is distributed in the hope that it will be useful, but WITHOUT
16
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18
# License for more details.
19
#
20
# You should have received a copy of the GNU Lesser General Public License
21
# along with this source; if not, write to the Free Software Foundation,
22
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
#
24
#------------------------------------------------------------------------------
25 200 olivier.gi
#
26 2 olivier.gi
# File Name: msp430sim
27 200 olivier.gi
#
28 17 olivier.gi
# Author(s):
29
#             - Olivier Girard,    olgirard@gmail.com
30
#
31 2 olivier.gi
#------------------------------------------------------------------------------
32 17 olivier.gi
# $Rev: 202 $
33
# $LastChangedBy: olivier.girard $
34
# $LastChangedDate: 2015-07-01 23:13:32 +0200 (Wed, 01 Jul 2015) $
35
#------------------------------------------------------------------------------
36 2 olivier.gi
 
37
###############################################################################
38 202 olivier.gi
#                            Parse arguments                                  #
39
###############################################################################
40
testname=""
41
seed=""
42
dma_verif="DMA_VERIF"
43
while [[ $# > 0 ]]; do
44
    key="$1"
45
    shift
46
    case $key in
47
        -seed)
48
            seed="$1"
49
            shift
50
            ;;
51
        -no_dma)
52
            dma_verif="NO_DMA_VERIF"
53
            ;;
54
        *)
55
            testname="$key"
56
            ;;
57
    esac
58
done
59
 
60
###############################################################################
61 2 olivier.gi
#                            Parameter Check                                  #
62
###############################################################################
63 202 olivier.gi
if [ "$testname" == "" ]; then
64
  echo "ERROR    : missing argument"
65
  echo "USAGE    : msp430sim  [-seed ] [-no_dma]"
66
  echo "Example  : msp430sim c-jump_jge"
67 98 olivier.gi
  echo ""
68 122 olivier.gi
  echo "In order to switch the verilog simulator, the OMSP_SIMULATOR environment"
69 98 olivier.gi
  echo "variable can be set to the following values:"
70
  echo ""
71 202 olivier.gi
  echo "                  - iverilog  : Icarus Verilog  (default)"
72
  echo "                  - cver      : CVer"
73
  echo "                  - verilog   : Verilog-XL"
74
  echo "                  - ncverilog : NC-Verilog"
75
  echo "                  - vcs       : VCS"
76
  echo "                  - vsim      : Modelsim"
77
  echo "                  - isim      : Xilinx simulator"
78 98 olivier.gi
  echo ""
79 2 olivier.gi
  exit 1
80
fi
81
 
82 202 olivier.gi
# Generate random seed if not specified
83
if [ "$seed" == "" ]; then
84
    seed=`od -A n -t d -N 4 /dev/urandom`
85
fi
86 2 olivier.gi
 
87
###############################################################################
88
#                     Check if the required files exist                       #
89
###############################################################################
90 202 olivier.gi
asmfile=../src/$testname.s43;
91
verfile=../src/$testname.v;
92 23 olivier.gi
incfile=../../../rtl/verilog/openMSP430_defines.v;
93 134 olivier.gi
linkfile=../bin/template.x;
94 141 olivier.gi
headfile=../bin/template_defs.asm;
95 122 olivier.gi
submitfile=../src/submit.f;
96 202 olivier.gi
if [ "$OMSP_SIMULATOR" == "isim" ]; then
97 122 olivier.gi
    submitfile=../src/submit.prj;
98
fi
99 2 olivier.gi
 
100
if [ ! -e $asmfile ]; then
101
    echo "Assembler file $asmfile doesn't exist: $asmfile"
102
    exit 1
103
fi
104
if [ ! -e $verfile ]; then
105
    echo "Verilog stimulus file $verfile doesn't exist: $verfile"
106
    exit 1
107
fi
108
if [ ! -e $submitfile ]; then
109
    echo "Verilog submit file $submitfile doesn't exist: $submitfile"
110
    exit 1
111
fi
112 134 olivier.gi
if [ ! -e $linkfile ]; then
113
    echo "Linker definition file template doesn't exist: $linkfile"
114 2 olivier.gi
    exit 1
115
fi
116 141 olivier.gi
if [ ! -e $headfile ]; then
117
    echo "Assembler definition file template doesn't exist: $headfile"
118
    exit 1
119
fi
120 2 olivier.gi
 
121
 
122
###############################################################################
123
#                               Cleanup                                       #
124
###############################################################################
125
echo "Cleanup..."
126 65 olivier.gi
rm -rf *.vcd
127 98 olivier.gi
rm -rf *.vpd
128
rm -rf *.trn
129
rm -rf *.dsn
130 141 olivier.gi
rm -rf pmem*
131 2 olivier.gi
rm -rf stimulus.v
132
 
133
 
134
###############################################################################
135
#                              Run simulation                                 #
136
###############################################################################
137
echo " ======================================================="
138 202 olivier.gi
echo "| Start simulation:             $testname"
139 2 olivier.gi
echo " ======================================================="
140 202 olivier.gi
echo ""
141
echo " Seed: $seed"
142
echo ""
143 2 olivier.gi
 
144
# Create links
145 138 olivier.gi
if [ `uname -o` = "Cygwin" ]
146
then
147
    cp $asmfile pmem.s43
148
    cp $verfile stimulus.v
149
else
150
    ln -s $asmfile pmem.s43
151
    ln -s $verfile stimulus.v
152
fi
153 2 olivier.gi
 
154 151 olivier.gi
# Make local copy of the openMSP403 configuration file
155
# and prepare it for MSPGCC preprocessing
156
cp  $incfile  ./pmem.h
157 200 olivier.gi
sed -i 's/`ifdef/#ifdef/g'         ./pmem.h
158
sed -i 's/`else/#else/g'           ./pmem.h
159
sed -i 's/`endif/#endif/g'         ./pmem.h
160
sed -i 's/`define/#define/g'       ./pmem.h
161
sed -i 's/`include/\/\/#include/g' ./pmem.h
162 202 olivier.gi
sed -i 's/`//g'                    ./pmem.h
163
sed -i "s/'//g"                    ./pmem.h
164 2 olivier.gi
 
165 151 olivier.gi
# Use MSPGCC preprocessor to extract the Program, Data
166
# and Peripheral memory sizes
167 202 olivier.gi
if command -v msp430-elf-gcc >/dev/null; then
168 200 olivier.gi
    msp430-elf-gcc -E -P -x c ../bin/omsp_config.sh > pmem.sh
169
else
170
    msp430-gcc     -E -P -x c ../bin/omsp_config.sh > pmem.sh
171
fi
172 2 olivier.gi
 
173 151 olivier.gi
# Source the extracted configuration file
174
source pmem.sh
175 2 olivier.gi
 
176
# Compile assembler code
177 111 olivier.gi
echo "Compile, link & generate IHEX file (Program Memory: $pmemsize B, Data Memory: $dmemsize B, Peripheral Space: $persize B)..."
178 141 olivier.gi
../bin/asm2ihex.sh  pmem pmem.s43 $linkfile $headfile $pmemsize $dmemsize $persize
179 2 olivier.gi
 
180 33 olivier.gi
# Generate Program memory file
181 2 olivier.gi
echo "Convert IHEX file to Verilog MEMH format..."
182 33 olivier.gi
../bin/ihex2mem.tcl -ihex pmem.ihex -out pmem.mem -mem_size $pmemsize
183 2 olivier.gi
 
184
# Start verilog simulation
185
echo "Start Verilog simulation..."
186 202 olivier.gi
../bin/rtlsim.sh    stimulus.v pmem.mem $submitfile $seed $dma_verif

powered by: WebSVN 2.1.0

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