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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [bin/] [msp430sim_c] - Diff between revs 76 and 98

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 76 Rev 98
#!/bin/bash
#!/bin/bash
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Copyright (C) 2001 Authors
# Copyright (C) 2001 Authors
#
#
# This source file may be used and distributed without restriction provided
# This source file may be used and distributed without restriction provided
# that this copyright statement is not removed from the file and that any
# that this copyright statement is not removed from the file and that any
# derivative work contains the original copyright notice and the associated
# derivative work contains the original copyright notice and the associated
# disclaimer.
# disclaimer.
#
#
# This source file is free software; you can redistribute it and/or modify
# This source file is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This source is distributed in the hope that it will be useful, but WITHOUT
# This source is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
# License for more details.
#
#
# You should have received a copy of the GNU Lesser General Public License
# You should have received a copy of the GNU Lesser General Public License
# along with this source; if not, write to the Free Software Foundation,
# along with this source; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#
#
# File Name: msp430sim_c
# File Name: msp430sim_c
#
#
# Author(s):
# Author(s):
#             - Olivier Girard,    olgirard@gmail.com
#             - Olivier Girard,    olgirard@gmail.com
#
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# $Rev: 73 $
# $Rev: 73 $
# $LastChangedBy: olivier.girard $
# $LastChangedBy: olivier.girard $
# $LastChangedDate: 2010-08-03 21:26:39 +0200 (Tue, 03 Aug 2010) $
# $LastChangedDate: 2010-08-03 21:26:39 +0200 (Tue, 03 Aug 2010) $
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
###############################################################################
###############################################################################
#                            Parameter Check                                  #
#                            Parameter Check                                  #
###############################################################################
###############################################################################
EXPECTED_ARGS=1
EXPECTED_ARGS=1
if [ $# -ne $EXPECTED_ARGS ]; then
if [ $# -ne $EXPECTED_ARGS ]; then
  echo "ERROR    : wrong number of arguments"
  echo "ERROR    : wrong number of arguments"
  echo "USAGE    : msp430sim_c "
  echo "USAGE    : msp430sim_c "
  echo "Example  : msp430sim_c sandbox"
  echo "Example  : msp430sim_c sandbox"
 
  echo ""
 
  echo "In order to switch the verilog simulator, the MYVLOG environment"
 
  echo "variable can be set to the following values:"
 
  echo ""
 
  echo "                  - iverilog  : Icarus Verilog  (default)"
 
  echo "                  - cver      : CVer"
 
  echo "                  - verilog   : Verilog-XL"
 
  echo "                  - ncverilog : NC-Verilog"
 
  echo "                  - vcs       : VCS"
 
  echo "                  - vsim      : Modelsim"
 
  echo ""
  exit 1
  exit 1
fi
fi
###############################################################################
###############################################################################
#                     Check if the required files exist                       #
#                     Check if the required files exist                       #
###############################################################################
###############################################################################
softdir=../src-c/$1;
softdir=../src-c/$1;
elffile=../src-c/$1/$1.elf;
elffile=../src-c/$1/$1.elf;
verfile=../src-c/$1/$1.v;
verfile=../src-c/$1/$1.v;
submitfile=../src/submit.f;
submitfile=../src/submit.f;
incfile=../../../rtl/verilog/openMSP430_defines.v;
incfile=../../../rtl/verilog/openMSP430_defines.v;
if [ ! -e $softdir ]; then
if [ ! -e $softdir ]; then
    echo "Software directory doesn't exist: $softdir"
    echo "Software directory doesn't exist: $softdir"
    exit 1
    exit 1
fi
fi
if [ ! -e $verfile ]; then
if [ ! -e $verfile ]; then
    echo "Verilog stimulus file $verfile doesn't exist: $verfile"
    echo "Verilog stimulus file $verfile doesn't exist: $verfile"
    exit 1
    exit 1
fi
fi
if [ ! -e $submitfile ]; then
if [ ! -e $submitfile ]; then
    echo "Verilog submit file $submitfile doesn't exist: $submitfile"
    echo "Verilog submit file $submitfile doesn't exist: $submitfile"
    exit 1
    exit 1
fi
fi
###############################################################################
###############################################################################
#                               Cleanup                                       #
#                               Cleanup                                       #
###############################################################################
###############################################################################
echo "Cleanup..."
echo "Cleanup..."
 
rm -rf *.vcd
 
rm -rf *.vpd
 
rm -rf *.trn
 
rm -rf *.dsn
rm -rf pmem.*
rm -rf pmem.*
rm -rf stimulus.v
rm -rf stimulus.v
###############################################################################
###############################################################################
#                              Run simulation                                 #
#                              Run simulation                                 #
###############################################################################
###############################################################################
echo " ======================================================="
echo " ======================================================="
echo "| Start simulation:             $1"
echo "| Start simulation:             $1"
echo " ======================================================="
echo " ======================================================="
# Make local copy of the openMSP403 configuration file and remove comments
# Make local copy of the openMSP403 configuration file and remove comments
cp  $incfile  ./pmem.inc
cp  $incfile  ./pmem.inc
sed -i "/^\/\// s,.*,," pmem.inc
sed -i "/^\/\// s,.*,," pmem.inc
# Get Program memory size
# Get Program memory size
pmemunit=`grep PMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f4`
pmemunit=`grep PMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f4`
pmemsize=`grep PMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f3`
pmemsize=`grep PMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f3`
pmemsize=${pmemsize/p/.}
pmemsize=${pmemsize/p/.}
if [ $pmemunit == "KB" ]
if [ $pmemunit == "KB" ]
  then
  then
    pmemsize=`echo "pmemsize=$pmemsize * 1024; pmemsize /= 1; pmemsize" | bc`
    pmemsize=`echo "pmemsize=$pmemsize * 1024; pmemsize /= 1; pmemsize" | bc`
fi
fi
# Get Data Memory size
# Get Data Memory size
dmemunit=`grep DMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f4`
dmemunit=`grep DMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f4`
dmemsize=`grep DMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f3`
dmemsize=`grep DMEM_SIZE_ pmem.inc | grep -v ifdef | grep -v "//" | cut -d'_' -f3`
dmemsize=${dmemsize/p/.}
dmemsize=${dmemsize/p/.}
if [ $dmemunit == "KB" ]
if [ $dmemunit == "KB" ]
  then
  then
    dmemsize=`echo "dmemsize=$dmemsize * 1024; dmemsize /= 1; dmemsize" | bc`
    dmemsize=`echo "dmemsize=$dmemsize * 1024; dmemsize /= 1; dmemsize" | bc`
fi
fi
# Make C program
# Make C program
echo "Compile, link & generate IHEX file (Program Memory: $pmemsize B, Data Memory: $dmemsize B)..."
echo "Compile, link & generate IHEX file (Program Memory: $pmemsize B, Data Memory: $dmemsize B)..."
cd $softdir
cd $softdir
make clean
make clean
make
make
cd ../../run/
cd ../../run/
# Create links
# Create links
ln -s $elffile pmem.elf
ln -s $elffile pmem.elf
ln -s $verfile stimulus.v
ln -s $verfile stimulus.v
# Create IHEX file from ELF
# Create IHEX file from ELF
echo "Convert ELF file to IHEX format..."
echo "Convert ELF file to IHEX format..."
msp430-objcopy -O ihex  pmem.elf pmem.ihex
msp430-objcopy -O ihex  pmem.elf pmem.ihex
# Generate Program memory file
# Generate Program memory file
echo "Convert IHEX file to Verilog MEMH format..."
echo "Convert IHEX file to Verilog MEMH format..."
../bin/ihex2mem.tcl -ihex pmem.ihex -out pmem.mem -mem_size $pmemsize
../bin/ihex2mem.tcl -ihex pmem.ihex -out pmem.mem -mem_size $pmemsize
# Start verilog simulation
# Start verilog simulation
echo "Start Verilog simulation..."
echo "Start Verilog simulation..."
../bin/rtlsim.sh    stimulus.v pmem.mem $submitfile
../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.