Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec-tests / regression_tests / lustre_files / success / Simulink / src_many_files / Sum5_PP.LUSTREC.lus @ cd1faebc

History | View | Annotate | Download (1.38 KB)

1 4748b215 hbourbou
-- This file has been generated by CoCoSim2.
2
3
-- Compiler: Lustre compiler 2 (ToLustre.m)
4
-- Time: 03-Dec-2018 23:05:53
5
#open <conv>
6
#open <lustrec_math>
7
node  abs_int(x : int;)
8
returns(y : int;);
9
let
10
	y = if (x >= 0) then
11
		x
12
	    else (- x);
13
tel
14
15
16
node  rem_int_int(x : int;
17
	y : int;)
18
returns(z : int;);
19
let
20
	z = if ((y = 0) or (x = 0)) then
21
		0
22
	    else ((x mod y) - (if (((x mod y) <> 0) and (x <= 0)) then abs_int(y) else 0));
23
tel
24
25
(*
26
--Rounds number to the nearest representable value.
27
*)
28
node  _Convergent(x : real;)
29
returns(y : int;);
30
let
31
	y = if (x > 0.5) then
32
		if (fmod(x, 2.0) = 0.5) then
33
		_Floor(x)
34
	    else _Floor((x + 0.5))
35
	    else if (x >= (- 0.5)) then
36
		0
37
	    else if (fmod(x, 2.0) = (- 0.5)) then
38
		_Ceiling(x)
39
	    else _Ceiling((x - 0.5));
40
tel
41
42
node  int_to_int32(x : int;)
43
returns(y : int;);
44
let
45
	y = if (x > 2147483647) then
46
		(-2147483648 + rem_int_int(( x - 2147483647 - 1 ), 4294967296))
47
	    else if (x < -2147483648) then
48
		(2147483647 + rem_int_int(( x + 2147483648 + 1 ), 4294967296))
49
	    else x;
50
tel
51
52
(*
53
Original block name: Sum5_PP
54
*)
55
node  Sum5_PP(In13_1 : real;
56
	In14_1 : int;)
57
returns(Out9_1 : int;);
58
var Add8_1 : int;
59
	__time_step : real;
60
	__nb_step : int;
61
let
62
	Add8_1 = int_to_int32(0 + int_to_int32(_Convergent(In13_1)) + In14_1);
63
	Out9_1 = Add8_1;
64
	__time_step = (0.0 -> ((pre __time_step) + 0.200000000000000));
65
	__nb_step = (0 -> ((pre __nb_step) + 1));
66
tel