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

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