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

History | View | Annotate | Download (2.34 KB)

1 | 4748b215 | hbourbou | -- This file has been generated by CoCoSim2. |
---|---|---|---|

2 | |||

3 | -- Compiler: Lustre compiler 2 (ToLustre.m) |
||

4 | -- Time: 03-Dec-2018 22:20:07 |
||

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 | node _AND_Bitwise_Unsigned_8(x : int; |
||

33 | y : int;) |
||

34 | returns(z : int;); |
||

35 | let |
||

36 | z = ( ((x mod 2) * (y mod 2)) + ( 2 * ((x / 2) mod 2) * ((y / 2) mod 2) ) + ( 4 * ((x / 4) mod 2) * ((y / 4) mod 2) ) + ( 8 * ((x / 8) mod 2) * ((y / 8) mod 2) ) + ( 16 * ((x / 16) mod 2) * ((y / 16) mod 2) ) + ( 32 * ((x / 32) mod 2) * ((y / 32) mod 2) ) + ( 64 * ((x / 64) mod 2) * ((y / 64) mod 2) ) + ( 128 * ((x / 128) mod 2) * ((y / 128) mod 2) ) ); |
||

37 | tel |
||

38 | |||

39 | node _AND_Bitwise_Signed_8(x : int; |
||

40 | y : int;) |
||

41 | returns(z : int;); |
||

42 | var x2 : int; |
||

43 | y2 : int; |
||

44 | let |
||

45 | x2 = if (x < 0) then |
||

46 | (256 + x) |
||

47 | else x; |
||

48 | y2 = if (y < 0) then |
||

49 | (256 + y) |
||

50 | else y; |
||

51 | z = int_to_int8(_AND_Bitwise_Unsigned_8(x2, y2)); |
||

52 | tel |
||

53 | |||

54 | (* |
||

55 | Original block name: BitwiseAND_int8_PP |
||

56 | *) |
||

57 | node BitwiseAND_int8_PP(In1_1 : int; |
||

58 | In2_1 : int; |
||

59 | In3_1 : int; |
||

60 | In4_1 : int; |
||

61 | In4_2 : int; |
||

62 | In4_3 : int; |
||

63 | In5_1 : int; |
||

64 | In5_2 : int; |
||

65 | In5_3 : int;) |
||

66 | returns(Out1_1 : int; |
||

67 | Out2_1 : int; |
||

68 | Out2_2 : int; |
||

69 | Out2_3 : int; |
||

70 | Out3_1 : int; |
||

71 | Out3_2 : int; |
||

72 | Out3_3 : int;); |
||

73 | var Bitwise_1 : int; |
||

74 | Bitwise1_1 : int; |
||

75 | Bitwise1_2 : int; |
||

76 | Bitwise1_3 : int; |
||

77 | Bitwise2_1 : int; |
||

78 | Bitwise2_2 : int; |
||

79 | Bitwise2_3 : int; |
||

80 | __time_step : real; |
||

81 | __nb_step : int; |
||

82 | let |
||

83 | Bitwise_1 = _AND_Bitwise_Signed_8(In1_1, In2_1); |
||

84 | Bitwise1_1 = _AND_Bitwise_Signed_8(In3_1, In4_1); |
||

85 | Bitwise1_2 = _AND_Bitwise_Signed_8(In3_1, In4_2); |
||

86 | Bitwise1_3 = _AND_Bitwise_Signed_8(In3_1, In4_3); |
||

87 | Bitwise2_1 = _AND_Bitwise_Signed_8(In5_1, 217); |
||

88 | Bitwise2_2 = _AND_Bitwise_Signed_8(In5_2, 217); |
||

89 | Bitwise2_3 = _AND_Bitwise_Signed_8(In5_3, 217); |
||

90 | Out1_1 = Bitwise_1; |
||

91 | Out2_1 = Bitwise1_1; |
||

92 | Out2_2 = Bitwise1_2; |
||

93 | Out2_3 = Bitwise1_3; |
||

94 | Out3_1 = Bitwise2_1; |
||

95 | Out3_2 = Bitwise2_2; |
||

96 | Out3_3 = Bitwise2_3; |
||

97 | __time_step = (0.0 -> ((pre __time_step) + 0.200000000000000)); |
||

98 | __nb_step = (0 -> ((pre __nb_step) + 1)); |
||

99 | tel |