1

 This file has been generated by CoCoSim2.

2


3

 Compiler: Lustre compiler 2 (ToLustre.m)

4

 Time: 03Dec2018 22:04:52

5

#open <conv>

6

node abs_int(x : int;)

7

returns(y : int;);

8

let

9

y = if (x >= 0) then

10

x

11

else ( x);

12

tel

13


14

node rem_int_int(x : int;

15

y : int;)

16

returns(z : int;);

17

let

18

z = if ((y = 0) or (x = 0)) then

19

0

20

else ((x mod y)  (if (((x mod y) <> 0) and (x <= 0)) then abs_int(y) else 0));

21

tel

22


23

node bool_to_int(x : bool;)

24

returns(y : int;);

25

let

26

y = if x then

27

1

28

else 0;

29

tel

30


31

node int_to_int16(x : int;)

32

returns(y : int;);

33

let

34

y = if (x > 32767) then

35

(32768 + rem_int_int(( x  32767  1 ), 65536))

36

else if (x < 32768) then

37

(32767 + rem_int_int(( x + 32768 + 1 ), 65536))

38

else x;

39

tel

40


41

node int_to_uint16(x : int;)

42

returns(y : int;);

43

let

44

y = if (x > 65535) then

45

(0 + rem_int_int(( x  65535  1 ), 65536))

46

else if (x < 0) then

47

(65535 + rem_int_int(( x + 0 + 1 ), 65536))

48

else x;

49

tel

50


51

(*

52

Original block name: gain_test_uK_PP/Gain3

53

*)

54

node Gain3_63_012(u_1 : real;

55

__time_step : real;

56

__nb_step : int;)

57

returns(Out1_1 : real;

58

Out1_2 : real;);

59

var K_1 : real;

60

K_2 : real;

61

Product_1 : real;

62

Product_2 : real;

63

let

64

K_1 = 2.000000000000000;

65

K_2 = 5.000000000000000;

66

Product_1 = 0.0 + (u_1 * K_1);

67

Product_2 = 0.0 + (u_1 * K_2);

68

Out1_1 = Product_1;

69

Out1_2 = Product_2;

70

tel

71


72

(*

73

Original block name: gain_test_uK_PP/Gain4

74

*)

75

node Gain4_64_008(u_1 : int;

76

__time_step : real;

77

__nb_step : int;)

78

returns(Out1_1 : int;

79

Out1_2 : int;);

80

var K_1 : int;

81

K_2 : int;

82

Product_1 : int;

83

Product_2 : int;

84

let

85

K_1 = 2;

86

K_2 = 5;

87

Product_1 = int_to_int16(0 + (int_to_int16(u_1) * int_to_int16(K_1)));

88

Product_2 = int_to_int16(0 + (int_to_int16(u_1) * int_to_int16(K_2)));

89

Out1_1 = Product_1;

90

Out1_2 = Product_2;

91

tel

92


93

(*

94

Original block name: gain_test_uK_PP/Gain5

95

*)

96

node Gain5_65_007(u_1 : bool;

97

__time_step : real;

98

__nb_step : int;)

99

returns(Out1_1 : int;

100

Out1_2 : int;);

101

var K_1 : bool;

102

K_2 : bool;

103

Product_1 : int;

104

Product_2 : int;

105

let

106

K_1 = true;

107

K_2 = true;

108

Product_1 = int_to_uint16(0 + (bool_to_int(u_1) * bool_to_int(K_1)));

109

Product_2 = int_to_uint16(0 + (bool_to_int(u_1) * bool_to_int(K_2)));

110

Out1_1 = Product_1;

111

Out1_2 = Product_2;

112

tel

113


114

(*

115

Original block name: gain_test_uK_PP/Gain6

116

*)

117

node Gain6_66_014(u_1 : real;

118

u_2 : real;

119

u_3 : real;

120

u_4 : real;

121

__time_step : real;

122

__nb_step : int;)

123

returns(Out1_1 : real;

124

Out1_2 : real;

125

Out1_3 : real;

126

Out1_4 : real;);

127

var K_1 : real;

128

K_2 : real;

129

K_3 : real;

130

K_4 : real;

131

Product_1 : real;

132

Product_2 : real;

133

Product_3 : real;

134

Product_4 : real;

135

let

136

K_1 = 2.000000000000000;

137

K_2 = 6.000000000000000;

138

K_3 = 5.000000000000000;

139

K_4 = 8.000000000000000;

140

Product_1 = 0.0 + (u_1 * K_1) + (u_3 * K_2);

141

Product_3 = 0.0 + (u_1 * K_3) + (u_3 * K_4);

142

Product_2 = 0.0 + (u_2 * K_1) + (u_4 * K_2);

143

Product_4 = 0.0 + (u_2 * K_3) + (u_4 * K_4);

144

Out1_1 = Product_1;

145

Out1_2 = Product_2;

146

Out1_3 = Product_3;

147

Out1_4 = Product_4;

148

tel

149


150

(*

151

Original block name: gain_test_uK_PP/Gain7

152

*)

153

node Gain7_67_008(u_1 : int;

154

u_2 : int;

155

u_3 : int;

156

u_4 : int;

157

__time_step : real;

158

__nb_step : int;)

159

returns(Out1_1 : int;

160

Out1_2 : int;

161

Out1_3 : int;

162

Out1_4 : int;);

163

var K_1 : int;

164

K_2 : int;

165

K_3 : int;

166

K_4 : int;

167

Product_1 : int;

168

Product_2 : int;

169

Product_3 : int;

170

Product_4 : int;

171

let

172

K_1 = 2;

173

K_2 = 6;

174

K_3 = 5;

175

K_4 = 8;

176

Product_1 = int_to_int16(0 + (int_to_int16(u_1) * int_to_int16(K_1)) + (int_to_int16(u_3) * int_to_int16(K_2)));

177

Product_3 = int_to_int16(0 + (int_to_int16(u_1) * int_to_int16(K_3)) + (int_to_int16(u_3) * int_to_int16(K_4)));

178

Product_2 = int_to_int16(0 + (int_to_int16(u_2) * int_to_int16(K_1)) + (int_to_int16(u_4) * int_to_int16(K_2)));

179

Product_4 = int_to_int16(0 + (int_to_int16(u_2) * int_to_int16(K_3)) + (int_to_int16(u_4) * int_to_int16(K_4)));

180

Out1_1 = Product_1;

181

Out1_2 = Product_2;

182

Out1_3 = Product_3;

183

Out1_4 = Product_4;

184

tel

185


186

(*

187

Original block name: gain_test_uK_PP/Gain8

188

*)

189

node Gain8_68_007(u_1 : bool;

190

u_2 : bool;

191

u_3 : bool;

192

u_4 : bool;

193

__time_step : real;

194

__nb_step : int;)

195

returns(Out1_1 : int;

196

Out1_2 : int;

197

Out1_3 : int;

198

Out1_4 : int;);

199

var K_1 : bool;

200

K_2 : bool;

201

K_3 : bool;

202

K_4 : bool;

203

Product_1 : int;

204

Product_2 : int;

205

Product_3 : int;

206

Product_4 : int;

207

let

208

K_1 = true;

209

K_2 = true;

210

K_3 = true;

211

K_4 = true;

212

Product_1 = int_to_uint16(0 + (bool_to_int(u_1) * bool_to_int(K_1)) + (bool_to_int(u_3) * bool_to_int(K_2)));

213

Product_3 = int_to_uint16(0 + (bool_to_int(u_1) * bool_to_int(K_3)) + (bool_to_int(u_3) * bool_to_int(K_4)));

214

Product_2 = int_to_uint16(0 + (bool_to_int(u_2) * bool_to_int(K_1)) + (bool_to_int(u_4) * bool_to_int(K_2)));

215

Product_4 = int_to_uint16(0 + (bool_to_int(u_2) * bool_to_int(K_3)) + (bool_to_int(u_4) * bool_to_int(K_4)));

216

Out1_1 = Product_1;

217

Out1_2 = Product_2;

218

Out1_3 = Product_3;

219

Out1_4 = Product_4;

220

tel

221


222

(*

223

Original block name: gain_test_uK_PP

224

*)

225

node gain_test_uK_PP(In1_1 : real;

226

In2_1 : int;

227

In3_1 : bool;

228

In4_1 : real;

229

In5_1 : int;

230

In6_1 : bool;

231

In7_1 : real;

232

In7_2 : real;

233

In7_3 : real;

234

In7_4 : real;

235

In8_1 : int;

236

In8_2 : int;

237

In8_3 : int;

238

In8_4 : int;

239

In9_1 : bool;

240

In9_2 : bool;

241

In9_3 : bool;

242

In9_4 : bool;)

243

returns(Out1_1 : real;

244

Out2_1 : real;

245

Out3_1 : real;

246

Out4_1 : real;

247

Out4_2 : real;

248

Out5_1 : int;

249

Out5_2 : int;

250

Out6_1 : int;

251

Out6_2 : int;

252

Out7_1 : real;

253

Out7_2 : real;

254

Out7_3 : real;

255

Out7_4 : real;

256

Out8_1 : int;

257

Out8_2 : int;

258

Out8_3 : int;

259

Out8_4 : int;

260

Out9_1 : int;

261

Out9_2 : int;

262

Out9_3 : int;

263

Out9_4 : int;);

264

var Gain_1 : real;

265

Gain1_1 : real;

266

Gain2_1 : real;

267

Gain3_1 : real;

268

Gain3_2 : real;

269

Gain4_1 : int;

270

Gain4_2 : int;

271

Gain5_1 : int;

272

Gain5_2 : int;

273

Gain6_1 : real;

274

Gain6_2 : real;

275

Gain6_3 : real;

276

Gain6_4 : real;

277

Gain7_1 : int;

278

Gain7_2 : int;

279

Gain7_3 : int;

280

Gain7_4 : int;

281

Gain8_1 : int;

282

Gain8_2 : int;

283

Gain8_3 : int;

284

Gain8_4 : int;

285

__time_step : real;

286

__nb_step : int;

287

let

288

Gain_1 = (In1_1 * 1.000000000000000);

289

Gain1_1 = (int_to_real(In2_1) * 1.000000000000000);

290

Gain2_1 = if In3_1 then

291

1.000000000000000

292

else 0.0;

293

(Gain3_1, Gain3_2) = Gain3_63_012(In4_1, __time_step, __nb_step);

294

(Gain4_1, Gain4_2) = Gain4_64_008(In5_1, __time_step, __nb_step);

295

(Gain5_1, Gain5_2) = Gain5_65_007(In6_1, __time_step, __nb_step);

296

(Gain6_1, Gain6_2, Gain6_3, Gain6_4) = Gain6_66_014(In7_1, In7_2, In7_3, In7_4, __time_step, __nb_step);

297

(Gain7_1, Gain7_2, Gain7_3, Gain7_4) = Gain7_67_008(In8_1, In8_2, In8_3, In8_4, __time_step, __nb_step);

298

(Gain8_1, Gain8_2, Gain8_3, Gain8_4) = Gain8_68_007(In9_1, In9_2, In9_3, In9_4, __time_step, __nb_step);

299

Out1_1 = Gain_1;

300

Out2_1 = Gain1_1;

301

Out3_1 = Gain2_1;

302

Out4_1 = Gain3_1;

303

Out4_2 = Gain3_2;

304

Out5_1 = Gain4_1;

305

Out5_2 = Gain4_2;

306

Out6_1 = Gain5_1;

307

Out6_2 = Gain5_2;

308

Out7_1 = Gain6_1;

309

Out7_2 = Gain6_2;

310

Out7_3 = Gain6_3;

311

Out7_4 = Gain6_4;

312

Out8_1 = Gain7_1;

313

Out8_2 = Gain7_2;

314

Out8_3 = Gain7_3;

315

Out8_4 = Gain7_4;

316

Out9_1 = Gain8_1;

317

Out9_2 = Gain8_2;

318

Out9_3 = Gain8_3;

319

Out9_4 = Gain8_4;

320

__time_step = (0.0 > ((pre __time_step) + 0.200000000000000));

321

__nb_step = (0 > ((pre __nb_step) + 1));

322

tel

323

