Commit be963637 authored by Maurice's avatar Maurice
Browse files

Added Calculator components

parent 717ebb9a
Pipeline #99152 passed with stages
in 4 minutes and 46 seconds
component Calculator{
ports in Z(0:999) number1,
in Z(0:999) number2,
out Z(0:1998) result;
implementation Math{
result = number1 + number2;
}
}
component Number{
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;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment