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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [bin/] [msp430sim_c] - Blame information for rev 87

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

Line No. Rev Author Line
1 76 olivier.gi
#!/bin/bash
2
#------------------------------------------------------------------------------
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_c
27
#
28
# Author(s):
29
#             - Olivier Girard,    olgirard@gmail.com
30
#
31
#------------------------------------------------------------------------------
32
# $Rev: 73 $
33
# $LastChangedBy: olivier.girard $
34
# $LastChangedDate: 2010-08-03 21:26:39 +0200 (Tue, 03 Aug 2010) $
35
#------------------------------------------------------------------------------
36
 
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_c "
44
  echo "Example  : msp430sim_c sandbox"
45
  exit 1
46
fi
47
 
48
 
49
###############################################################################
50
#                     Check if the required files exist                       #
51
###############################################################################
52
softdir=../src-c/$1;
53
elffile=../src-c/$1/$1.elf;
54
verfile=../src-c/$1/$1.v;
55
submitfile=../src/submit.f;
56
incfile=../../../rtl/verilog/openMSP430_defines.v;
57
 
58
if [ ! -e $softdir ]; then
59
    echo "Software directory doesn't exist: $softdir"
60
    exit 1
61
fi
62
if [ ! -e $verfile ]; then
63
    echo "Verilog stimulus file $verfile doesn't exist: $verfile"
64
    exit 1
65
fi
66
if [ ! -e $submitfile ]; then
67
    echo "Verilog submit file $submitfile doesn't exist: $submitfile"
68
    exit 1
69
fi
70
 
71
 
72
###############################################################################
73
#                               Cleanup                                       #
74
###############################################################################
75
echo "Cleanup..."
76
rm -rf pmem.*
77
rm -rf stimulus.v
78
 
79
 
80
###############################################################################
81
#                              Run simulation                                 #
82
###############################################################################
83
echo " ======================================================="
84
echo "| Start simulation:             $1"
85
echo " ======================================================="
86
 
87
# Make local copy of the openMSP403 configuration file and remove comments
88
cp  $incfile  ./pmem.inc
89
sed -i "/^\/\// s,.*,," pmem.inc
90
 
91
# Get Program memory size
92
pmemunit=`grep PMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f4`
93
pmemsize=`grep PMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f3`
94
pmemsize=${pmemsize/p/.}
95
if [ $pmemunit == "KB" ]
96
  then
97
    pmemsize=`echo "pmemsize=$pmemsize * 1024; pmemsize /= 1; pmemsize" | bc`
98
fi
99
 
100
# Get Data Memory size
101
dmemunit=`grep DMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f4`
102
dmemsize=`grep DMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f3`
103
dmemsize=${dmemsize/p/.}
104
if [ $dmemunit == "KB" ]
105
  then
106
    dmemsize=`echo "dmemsize=$dmemsize * 1024; dmemsize /= 1; dmemsize" | bc`
107
fi
108
 
109
# Make C program
110
echo "Compile, link & generate IHEX file (Program Memory: $pmemsize B, Data Memory: $dmemsize B)..."
111
cd $softdir
112
make clean
113
make
114
cd ../../run/
115
 
116
# Create links
117
ln -s $elffile pmem.elf
118
ln -s $verfile stimulus.v
119
 
120
# Create IHEX file from ELF
121
echo "Convert ELF file to IHEX format..."
122
msp430-objcopy -O ihex  pmem.elf pmem.ihex
123
 
124
# Generate Program memory file
125
echo "Convert IHEX file to Verilog MEMH format..."
126
../bin/ihex2mem.tcl -ihex pmem.ihex -out pmem.mem -mem_size $pmemsize
127
 
128
# Start verilog simulation
129
echo "Start Verilog simulation..."
130
../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.