1

 This file has been generated by CoCoSim2.

2


3

 Compiler: Lustre compiler 2 (ToLustre.m)

4

 Time: 17Jan2018 14:18:30

5

external libraries

6

#open <conv>

7

#open <simulink_math_fcn>

8

Round towards plus infinity.

9

node _Ceiling (x: real)

10

returns(y:int);

11

let

12

y= if x < 0.0 then real_to_int(x)

13

else real_to_int(x) + 1;

14

tel

15


16

Rounds number to the nearest representable value.

17

node _Convergent (x: real)

18

returns(y:int);

19

let

20

y = if (x > 0.5) then

21

if (fmod(x, 2.0) = 0.5) then _Floor(x)

22

else _Floor(x + 0.5)

23

else

24

if (x >= 0.5) then 0

25

else

26

if (fmod(x, 2.0) = 0.5) then _Ceiling(x)

27

else _Ceiling(x  0.5);

28

tel

29


30

Round towards minus infinity..

31

node _Floor (x: real)

32

returns(y:int);

33

let

34

y= if x < 0.0 then real_to_int(x)  1

35

else real_to_int(x);

36

tel

37


38

Rounds number to the nearest representable value.

39

If a tie occurs, rounds toward positive infinity

40

node _Nearest (x: real)

41

returns(y:int);

42

let

43

y = if (_fabs(x) >= 0.5) then _Floor(x + 0.5)

44

else 0;

45

tel

46


47

Rounds number to the nearest representable value.

48

If a tie occurs,rounds positive numbers toward positive infinity and rounds negative numbers toward negative infinity

49

node _Round (x: real)

50

returns(y:int);

51

let

52

y = if (x >= 0.5) then _Floor(x + 0.5)

53

else if (x > 0.5) then 0

54

else _Ceiling(x  0.5);

55

tel

56


57

node bool_to_real (x: bool)

58

returns(y:real);

59

let

60

y= if x then 1.0 else 0.0;

61

tel

62


63

node int_to_uint8 (x: int)

64

returns(y:int);

65

let

66

y= if x > 255 then 0 + rem_int_int((x  255  1),256)

67

else if x < 0 then 255 + rem_int_int((x  (0) + 1),256)

68

else x;

69

tel

70


71

node _fabs (x:real)

72

returns(z:real);

73

let

74

z= if (x >= 0.0) then x

75

else x;

76

tel

77


78

node rem_int_int (x, y: int)

79

returns(z:int);

80

let

81

z= if (x < 0) and (y > 0) then (x mod y)

82

else (x mod y);

83

tel

84


85

Simulink code

86


87


88

 Original block name: Add_PP

89

node Add_PP (In1_1:real;

90

In1_2:real;

91

In1_3:real;

92

In2_1:real;

93

In3_1:int;

94

In4_1:int;

95

In5_1:real;

96

In6_1:int;

97

In7_1:int;

98

In8_1:bool;

99

In9_1:real;

100

In10_1:int;

101

In11_1:real;

102

In12_1:int;

103

In13_1:real;

104

In14_1:int;

105

In15_1:real;

106

In16_1:int;

107

In17_1:real;

108

In18_1:int;

109

In19_1:real;

110

In20_1:int;

111

In21_1:real;

112

In22_1:int;)

113

returns (Out1_1:real;

114

Out1_2:real;

115

Out1_3:real;

116

Out2_1:real;

117

Out3_1:real;

118

Out4_1:int;

119

Out5_1:real;

120

Out6_1:real;

121

Out7_1:int;

122

Out8_1:int;

123

Out9_1:int;

124

Out10_1:int;

125

Out11_1:int;

126

Out12_1:int;

127

Out13_1:int;);

128

 Contract In progress

129

var Add_1:real;

130

Add_2:real;

131

Add_3:real;Add1_1:real;Add10_1:int;Add11_1:int;Add12_1:int;Add2_1:real;Add3_1:int;Add4_1:real;Add5_1:real;Add6_1:int;Add7_1:int;Add8_1:int;Add9_1:int;

132

let

133

Add_1 = 0.0 + In1_1  In2_1 + In1_1;

134

Add_2 = 0.0 + In1_2  In2_1 + In1_2;

135

Add_3 = 0.0 + In1_3  In2_1 + In1_3;

136

Add1_1 = 0.0 + In1_1 + In1_2 + In1_3;

137

Add10_1 = 0 + _Round(In17_1) + In18_1;

138

Add11_1 = 0 + real_to_int(In19_1) + In20_1;

139

Add12_1 = 0 + real_to_int(In21_1) + In22_1;

140

Add2_1 = 0.0  In1_1  In1_2  In1_3;

141

Add3_1 = int_to_uint8(0 + int_to_uint8(In3_1) + int_to_uint8(In4_1));

142

Add4_1 = 0.0 + In5_1 + int_to_real(In6_1);

143

Add5_1 = 0.0 + int_to_real(In7_1) + bool_to_real(In8_1);

144

Add6_1 = 0 + _Floor(In9_1) + In10_1;

145

Add7_1 = 0 + _Ceiling(In11_1) + In12_1;

146

Add8_1 = 0 + _Convergent(In13_1) + In14_1;

147

Add9_1 = 0 + _Nearest(In15_1) + In16_1;

148

Out1_1 = Add_1;

149

Out1_2 = Add_2;

150

Out1_3 = Add_3;

151

Out2_1 = Add1_1;

152

Out3_1 = Add2_1;

153

Out4_1 = Add3_1;

154

Out5_1 = Add4_1;

155

Out6_1 = Add5_1;

156

Out7_1 = Add6_1;

157

Out8_1 = Add7_1;

158

Out9_1 = Add8_1;

159

Out10_1 = Add9_1;

160

Out11_1 = Add10_1;

161

Out12_1 = Add11_1;

162

Out13_1 = Add12_1;

163


164

tel
