source: trunk/IPs/systemC/processor/Morpheo/Script/range.sh @ 82

Last change on this file since 82 was 82, checked in by rosiere, 16 years ago
  • support locale (now must "just" translate)
  • update all component with new test format
  • update all component with usage
  • New component : decod queue and prediction_unit
  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1#!/bin/sh
2#-----------------------------------------------------------
3# $Id: range.sh 82 2008-05-01 16:48:45Z rosiere $
4#-----------------------------------------------------------
5
6#-----[ usage ]---------------------------------------------
7function usage ()
8{
9    echo "Usage     : ${0} min max [step [iter]]";
10    echo "Arguments : ";
11    echo " * min  : value minimal";
12    echo " * max  : value maximal";
13    echo " * step : step between two value. If no present, step = \"+1\"";
14    echo " * iter : choose the Nième value";
15    exit;
16}
17
18#-----[ range ]---------------------------------------------
19function range ()
20{
21    declare a=${1};
22    declare b=${2};
23    declare step=${3};
24
25    while test ${a} -lt ${b}; do
26        echo ${a};
27        a=$((${a} ${step}));
28    done
29
30    if test ${a} -eq ${b}; then
31        echo ${a};
32    fi;
33}
34
35#-----[ range_max ]-----------------------------------------
36function range_max ()
37{
38    declare a=${1};
39    declare b=${2};
40    declare step=${3};
41    declare iter=${4};
42
43    while test ${a} -lt ${b} -a ${iter} -gt 1; do
44        a=$((${a} ${step}));
45        iter=$((${iter}-1));
46    done;
47
48    if test ${a} -eq ${b}; then
49        echo ${a};
50    fi;
51
52    if test ${iter} -eq 1; then
53        echo ${a};
54    fi;
55}
56
57#-----[ main ]----------------------------------------------
58function main ()
59{
60    # create operande
61    case ${#} in
62        2) range ${*} "+1";;
63        3) range ${*}     ;;
64        4) range_max ${*} ;;
65        *) usage ${*}
66    esac
67}
68
69#-----[ Corps ]---------------------------------------------
70main ${*}
Note: See TracBrowser for help on using the repository browser.