NumberDetector.emadl 996 Bytes
Newer Older
1
2
3
package CalculatorTest;

component NumberDetector{
Maurice's avatar
Maurice committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
    ports in Q(0:1)^10 pred_num1,
          in Q(0:1)^10 pred_num2,
          in Q(0:1)^10 pred_num3,
          out Z(0:999) number;

    implementation Math{
          for j = 1:3

            if(j == 1)
              tmp_vector = pred_num1;
            end
            if(j == 2)
              tmp_vector = pred_num2;
            end
            if(j == 3)
              tmp_vector = pred_num3;
            end

            maxIndex = 0;
            maxValue = tmp_vector(1);

            for i = 2:10
              if tmp_vector(i) > maxValue
                  maxIndex = i - 1;
                  maxValue = tmp_vector(i);
              end
            end

            if(j == 1)
              num1 = maxIndex;
            end
            if(j == 2)
              num2 = maxIndex;
            end
            if(j == 3)
              num3 = maxIndex;
            end

          end

          number = (num1*100) + (num2*10) + num3;
    }
}