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

Subversion Repositories openmsp430

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

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
#
26
# File Name: msp430sim
27
#
28 17 olivier.gi
# Author(s):
29
#             - Olivier Girard,    olgirard@gmail.com
30
#
31 2 olivier.gi
#------------------------------------------------------------------------------
32 17 olivier.gi
# $Rev: 141 $
33
# $LastChangedBy: olivier.girard $
34
# $LastChangedDate: 2012-05-05 23:22:06 +0200 (Sat, 05 May 2012) $
35
#------------------------------------------------------------------------------
36 2 olivier.gi
 
37
###############################################################################
38
#                            Parameter Check                                  #
39
###############################################################################
40
EXPECTED_ARGS=1
41
if [ $# -ne $EXPECTED_ARGS ]; then
42
  echo "ERROR    : wrong number of arguments"
43
  echo "USAGE    : msp430sim "
44
  echo "Example  : msp430sim c-jump_jge"
45 98 olivier.gi
  echo ""
46 122 olivier.gi
  echo "In order to switch the verilog simulator, the OMSP_SIMULATOR environment"
47 98 olivier.gi
  echo "variable can be set to the following values:"
48
  echo ""
49
  echo "                  - iverilog  : Icarus Verilog  (default)"
50
  echo "                  - cver      : CVer"
51
  echo "                  - verilog   : Verilog-XL"
52
  echo "                  - ncverilog : NC-Verilog"
53
  echo "                  - vcs       : VCS"
54
  echo "                  - vsim      : Modelsim"
55 122 olivier.gi
  echo "                  - isim      : Xilinx simulator"
56 98 olivier.gi
  echo ""
57 2 olivier.gi
  exit 1
58
fi
59
 
60
 
61
###############################################################################
62
#                     Check if the required files exist                       #
63
###############################################################################
64
asmfile=../src/$1.s43;
65
verfile=../src/$1.v;
66 23 olivier.gi
incfile=../../../rtl/verilog/openMSP430_defines.v;
67 134 olivier.gi
linkfile=../bin/template.x;
68 141 olivier.gi
headfile=../bin/template_defs.asm;
69 122 olivier.gi
submitfile=../src/submit.f;
70
if [ $OMSP_SIMULATOR == "isim" ]; then
71
    submitfile=../src/submit.prj;
72
fi
73 2 olivier.gi
 
74
if [ ! -e $asmfile ]; then
75
    echo "Assembler file $asmfile doesn't exist: $asmfile"
76
    exit 1
77
fi
78
if [ ! -e $verfile ]; then
79
    echo "Verilog stimulus file $verfile doesn't exist: $verfile"
80
    exit 1
81
fi
82
if [ ! -e $submitfile ]; then
83
    echo "Verilog submit file $submitfile doesn't exist: $submitfile"
84
    exit 1
85
fi
86 134 olivier.gi
if [ ! -e $linkfile ]; then
87
    echo "Linker definition file template doesn't exist: $linkfile"
88 2 olivier.gi
    exit 1
89
fi
90 141 olivier.gi
if [ ! -e $headfile ]; then
91
    echo "Assembler definition file template doesn't exist: $headfile"
92
    exit 1
93
fi
94 2 olivier.gi
 
95
 
96
###############################################################################
97
#                               Cleanup                                       #
98
###############################################################################
99
echo "Cleanup..."
100 65 olivier.gi
rm -rf *.vcd
101 98 olivier.gi
rm -rf *.vpd
102
rm -rf *.trn
103
rm -rf *.dsn
104 141 olivier.gi
rm -rf pmem*
105 2 olivier.gi
rm -rf stimulus.v
106
 
107
 
108
###############################################################################
109
#                              Run simulation                                 #
110
###############################################################################
111
echo " ======================================================="
112
echo "| Start simulation:             $1"
113
echo " ======================================================="
114
 
115
# Create links
116 138 olivier.gi
if [ `uname -o` = "Cygwin" ]
117
then
118
    cp $asmfile pmem.s43
119
    cp $verfile stimulus.v
120
else
121
    ln -s $asmfile pmem.s43
122
    ln -s $verfile stimulus.v
123
fi
124 2 olivier.gi
 
125
# Make local copy of the openMSP403 configuration file and remove comments
126 33 olivier.gi
cp  $incfile  ./pmem.inc
127
sed -i "/^\/\// s,.*,," pmem.inc
128 2 olivier.gi
 
129 33 olivier.gi
# Get Program Memory size
130 72 olivier.gi
pmemunit=`grep PMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f4`
131
pmemsize=`grep PMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f3`
132
pmemsize=${pmemsize/p/.}
133
if [ $pmemunit == "KB" ]
134
  then
135
    pmemsize=`echo "pmemsize=$pmemsize * 1024; pmemsize /= 1; pmemsize" | bc`
136
fi
137 2 olivier.gi
 
138 33 olivier.gi
# Get Data Memory size
139 72 olivier.gi
dmemunit=`grep DMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f4`
140
dmemsize=`grep DMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f3`
141
dmemsize=${dmemsize/p/.}
142
if [ $dmemunit == "KB" ]
143
  then
144
    dmemsize=`echo "dmemsize=$dmemsize * 1024; dmemsize /= 1; dmemsize" | bc`
145
fi
146 2 olivier.gi
 
147 111 olivier.gi
# Get Peripheral Address space size
148
perunit=`grep PER_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f4`
149
persize=`grep PER_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f3`
150
persize=${persize/p/.}
151
if [ $perunit == "KB" ]
152
  then
153
    persize=`echo "persize=$persize * 1024; persize /= 1; persize" | bc`
154
fi
155 72 olivier.gi
 
156 2 olivier.gi
# Compile assembler code
157 111 olivier.gi
echo "Compile, link & generate IHEX file (Program Memory: $pmemsize B, Data Memory: $dmemsize B, Peripheral Space: $persize B)..."
158 141 olivier.gi
../bin/asm2ihex.sh  pmem pmem.s43 $linkfile $headfile $pmemsize $dmemsize $persize
159 2 olivier.gi
 
160 33 olivier.gi
# Generate Program memory file
161 2 olivier.gi
echo "Convert IHEX file to Verilog MEMH format..."
162 33 olivier.gi
../bin/ihex2mem.tcl -ihex pmem.ihex -out pmem.mem -mem_size $pmemsize
163 2 olivier.gi
 
164
# Start verilog simulation
165
echo "Start Verilog simulation..."
166 33 olivier.gi
../bin/rtlsim.sh    stimulus.v pmem.mem $submitfile

powered by: WebSVN 2.1.0

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