Project

General

Profile

Bug #66 » SampleTime2_PP.lus

Hamza Bourbouh, 05/31/2018 11:31 AM

 
1
-- This file has been generated by CoCoSim2.
2

    
3
-- Compiler: Lustre compiler 2 (ToLustre.m)
4
-- Time: 31-May-2018 11:14:50
5
--external libraries
6
node _make_clock(per: int; ph: int)
7
returns( clk: bool );
8
var cnt: int;
9
let
10
	cnt   = ((per - ph) -> (pre(cnt) + 1)) mod per ;
11
	clk = if (cnt = 0) then true else false ;
12
tel
13
node int_to_int8 (x: int)
14
returns(y:int);
15
let
16
	y= if x > 127 then -128 + rem_int_int((x - 127 - 1),256) 
17
	else if x < -128 then 127 + rem_int_int((x - (-128) + 1),256) 
18
	else x;
19
tel
20

    
21
node rem_int_int (x, y: int)
22
returns(z:int);
23
let
24
	z = if y=0 then 0
25
		else
26
		 (x mod y) - (if (x mod y <> 0 and x <= 0) then (if y > 0 then y else -y) else 0);
27
tel
28

    
29
--Simulink code
30

    
31

    
32

    
33

    
34
-- Original block name: SampleTime2_PP/Subsystem1
35
node Subsystem1_9_006 (In1_1: int;__time_step:real;_clk_2_0:bool clock;)
36
 returns (Out1_1: int;);
37
-- Contract In progress
38
var RateTransition1_1: int;RateTransition2_1: int;Sum_1: int;UnitDelay_1: int;
39
let
40
	RateTransition1_1 = Sum_1 when _clk_2_0;
41
	RateTransition2_1 = merge _clk_2_0
42
	 (true -> (0 -> pre UnitDelay_1))
43
	 (false -> (0 -> pre RateTransition2_1) when false(_clk_2_0));
44
	Sum_1 = int_to_int8(0 + In1_1 + RateTransition2_1);
45
	UnitDelay_1 =  int_to_int8(0) -> pre( RateTransition1_1 ) ;
46
	Out1_1 = UnitDelay_1;
47
	
48
tel
49

    
50

    
51
-- Original block name: SampleTime2_PP
52
node SampleTime2_PP (_virtual:bool;)
53
 returns (Out1_1: int;);
54
-- Contract In progress
55
var Constant_1: int;RateTransition_1: int;Subsystem1_1: int;
56
	__time_step:real;
57
	_clk_2_0:bool clock;
58
let
59
	_clk_2_0 = _make_clock(2, 0);
60
	__time_step = 0.0 -> pre __time_step + 1.000000000000000;
61
	Constant_1 = 1;
62
	RateTransition_1 = merge _clk_2_0
63
	 (true -> (0 -> pre Subsystem1_1))
64
	 (false -> (0 -> pre RateTransition_1) when false(_clk_2_0));
65
	(Subsystem1_1) = Subsystem1_9_006(Constant_1,
66
		__time_step, _clk_2_0);
67
	Out1_1 = RateTransition_1;
68
	
69
tel
(1-1/3)