1 |
4748b215
|
hbourbou
|
-- This file has been generated by CoCoSim2.
|
2 |
|
|
|
3 |
|
|
-- Compiler: Lustre compiler 2 (ToLustre.m)
|
4 |
|
|
-- Time: 03-Dec-2018 22:51:43
|
5 |
|
|
node abs_int(x : int;)
|
6 |
|
|
returns(y : int;);
|
7 |
|
|
let
|
8 |
|
|
y = if (x >= 0) then
|
9 |
|
|
x
|
10 |
|
|
else (- x);
|
11 |
|
|
tel
|
12 |
|
|
|
13 |
|
|
node rem_int_int(x : int;
|
14 |
|
|
y : int;)
|
15 |
|
|
returns(z : int;);
|
16 |
|
|
let
|
17 |
|
|
z = if ((y = 0) or (x = 0)) then
|
18 |
|
|
0
|
19 |
|
|
else ((x mod y) - (if (((x mod y) <> 0) and (x <= 0)) then abs_int(y) else 0));
|
20 |
|
|
tel
|
21 |
|
|
|
22 |
|
|
node int_to_int8(x : int;)
|
23 |
|
|
returns(y : int;);
|
24 |
|
|
let
|
25 |
|
|
y = if (x > 127) then
|
26 |
|
|
(-128 + rem_int_int(( x - 127 - 1 ), 256))
|
27 |
|
|
else if (x < -128) then
|
28 |
|
|
(127 + rem_int_int(( x + 128 + 1 ), 256))
|
29 |
|
|
else x;
|
30 |
|
|
tel
|
31 |
|
|
|
32 |
|
|
(*
|
33 |
|
|
Rounds positive and negative numbers toward positive infinity
|
34 |
|
|
*)
|
35 |
|
|
node int_div_Ceiling(x : int;
|
36 |
|
|
y : int;)
|
37 |
|
|
returns(z : int;);
|
38 |
|
|
let
|
39 |
|
|
z = if (y = 0) then
|
40 |
|
|
(if (x > 0) then 2147483647 else -2147483648)
|
41 |
|
|
else if ((x mod y) = 0) then
|
42 |
|
|
(x / y)
|
43 |
|
|
else if ((abs_int(y) > abs_int(x)) and ((x * y) > 0)) then
|
44 |
|
|
1
|
45 |
|
|
else if ((abs_int(y) > abs_int(x)) and ((x * y) < 0)) then
|
46 |
|
|
0
|
47 |
|
|
else if ((x > 0) and (y < 0)) then
|
48 |
|
|
(x / y)
|
49 |
|
|
else if ((x < 0) and (y > 0)) then
|
50 |
|
|
((- x) / (- y))
|
51 |
|
|
else if ((x < 0) and (y < 0)) then
|
52 |
|
|
(((- x) / (- y)) + 1)
|
53 |
|
|
else ((x / y) + 1);
|
54 |
|
|
tel
|
55 |
|
|
|
56 |
|
|
(*
|
57 |
|
|
Rounds positive and negative numbers toward negative infinity
|
58 |
|
|
*)
|
59 |
|
|
node int_div_Floor(x : int;
|
60 |
|
|
y : int;)
|
61 |
|
|
returns(z : int;);
|
62 |
|
|
let
|
63 |
|
|
z = if (y = 0) then
|
64 |
|
|
(if (x > 0) then 2147483647 else -2147483648)
|
65 |
|
|
else if ((x mod y) = 0) then
|
66 |
|
|
(x / y)
|
67 |
|
|
else if ((abs_int(y) > abs_int(x)) and ((x * y) > 0)) then
|
68 |
|
|
0
|
69 |
|
|
else if ((abs_int(y) > abs_int(x)) and ((x * y) < 0)) then
|
70 |
|
|
-1
|
71 |
|
|
else if ((x > 0) and (y < 0)) then
|
72 |
|
|
((x / y) - 1)
|
73 |
|
|
else if ((x < 0) and (y > 0)) then
|
74 |
|
|
(((- x) / (- y)) - 1)
|
75 |
|
|
else if ((x < 0) and (y < 0)) then
|
76 |
|
|
((- x) / (- y))
|
77 |
|
|
else (x / y);
|
78 |
|
|
tel
|
79 |
|
|
|
80 |
|
|
(*
|
81 |
|
|
Rounds number to the nearest representable value. If a tie occurs, rounds toward positive infinity
|
82 |
|
|
*)
|
83 |
|
|
node int_div_Nearest(x : int;
|
84 |
|
|
y : int;)
|
85 |
|
|
returns(z : int;);
|
86 |
|
|
let
|
87 |
|
|
z = if (y = 0) then
|
88 |
|
|
(if (x > 0) then 2147483647 else -2147483648)
|
89 |
|
|
else if ((x mod y) = 0) then
|
90 |
|
|
(x / y)
|
91 |
|
|
else if (((x mod y) * 2) = y) then
|
92 |
|
|
int_div_Ceiling(x, y)
|
93 |
|
|
else if ((y > 0) and (((x mod y) * 2) > y)) then
|
94 |
|
|
((x / y) + 1)
|
95 |
|
|
else if ((y < 0) and (((x mod y) * 2) > (- y))) then
|
96 |
|
|
((x / y) - 1)
|
97 |
|
|
else (x / y);
|
98 |
|
|
tel
|
99 |
|
|
|
100 |
|
|
(*
|
101 |
|
|
Rounds positive and negative numbers toward positive infinity
|
102 |
|
|
*)
|
103 |
|
|
node int_div_Zero(x : int;
|
104 |
|
|
y : int;)
|
105 |
|
|
returns(z : int;);
|
106 |
|
|
let
|
107 |
|
|
z = if (y = 0) then
|
108 |
|
|
(if (x > 0) then 2147483647 else -2147483648)
|
109 |
|
|
else if ((x mod y) = 0) then
|
110 |
|
|
(x / y)
|
111 |
|
|
else if (abs_int(y) > abs_int(x)) then
|
112 |
|
|
0
|
113 |
|
|
else if (x > 0) then
|
114 |
|
|
(x / y)
|
115 |
|
|
else ((- x) / (- y));
|
116 |
|
|
tel
|
117 |
|
|
|
118 |
|
|
(*
|
119 |
|
|
Original block name: Divide_Integer_PP
|
120 |
|
|
*)
|
121 |
|
|
node Divide_Integer_PP(In1_1 : int;
|
122 |
|
|
In2_1 : int;)
|
123 |
|
|
returns(Ceil_1 : int;
|
124 |
|
|
floor_1 : int;
|
125 |
|
|
nearest_1 : int;
|
126 |
|
|
zero_1 : int;);
|
127 |
|
|
var Ceiling_1 : int;
|
128 |
|
|
Constant_1 : int;
|
129 |
|
|
Floor_1 : int;
|
130 |
|
|
Nearest_1 : int;
|
131 |
|
|
Switch_1 : int;
|
132 |
|
|
Zero_1 : int;
|
133 |
|
|
__time_step : real;
|
134 |
|
|
__nb_step : int;
|
135 |
|
|
let
|
136 |
|
|
Ceiling_1 = int_to_int8(int_div_Ceiling(1 * In1_1, Switch_1));
|
137 |
|
|
Constant_1 = 1;
|
138 |
|
|
Floor_1 = int_to_int8(int_div_Floor(1 * In1_1, Switch_1));
|
139 |
|
|
Nearest_1 = int_to_int8(int_div_Nearest(1 * In1_1, Switch_1));
|
140 |
|
|
Switch_1 = if (In2_1 <> 0) then
|
141 |
|
|
In2_1
|
142 |
|
|
else Constant_1;
|
143 |
|
|
Zero_1 = int_to_int8(int_div_Zero(1 * In1_1, Switch_1));
|
144 |
|
|
Ceil_1 = Ceiling_1;
|
145 |
|
|
floor_1 = Floor_1;
|
146 |
|
|
nearest_1 = Nearest_1;
|
147 |
|
|
zero_1 = Zero_1;
|
148 |
|
|
__time_step = (0.0 -> ((pre __time_step) + 0.200000000000000));
|
149 |
|
|
__nb_step = (0 -> ((pre __nb_step) + 1));
|
150 |
|
|
tel
|