Commit 89ae492c authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files
parents 56f8884e b57d0d6f
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2018 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -332,17 +332,13 @@ package body Ocarina.Backends.C_Values is
if V.Sign < 0 then
Add_Char_To_Name_Buffer ('-');
elsif V.Base = 16 then
Add_Str_To_Name_Buffer ("16#");
Add_Str_To_Name_Buffer ("0x");
elsif V.Base = 8 then
Add_Str_To_Name_Buffer ("8#");
Add_Str_To_Name_Buffer ("0");
end if;
Add_ULL_To_Name_Buffer (V.IVal, ULL (V.Base));
if V.Base = 16 or else V.Base = 8 then
Add_Char_To_Name_Buffer ('#');
end if;
when K_Float =>
Add_Str_To_Name_Buffer (Long_Double'Image (V.FVal));
declare
......
......@@ -1493,7 +1493,7 @@ package body Ocarina.Backends.Build_Utils is
Write_Line
("###################################################");
Write_Eol;
Write_Str
Write_Line
("SUBDIRS = " &
"$(filter-out Makefile polyorb-hi-c, $(wildcard *))");
Write_Eol;
......@@ -1502,6 +1502,25 @@ package body Ocarina.Backends.Build_Utils is
(ASCII.HT &
"set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d ; done");
Write_Eol;
Write_Line ("coverage:");
Write_Line (ASCII.HT & "-rm lcov.args");
Write_Line (ASCII.HT & "touch lcov.args");
Write_Line (ASCII.HT & "for d in $(SUBDIRS); do \");
Write_Line (ASCII.HT & ASCII.HT &
"lcov -c -i -d $$d -o coverage.$$d ;\");
Write_Line (ASCII.HT & ASCII.HT &
"lcov -c -d $$d -o coverage.$$d ;\");
Write_Line (ASCII.HT & ASCII.HT &
"echo ""-a coverage.$$d "" >> lcov.args ;\");
Write_Line (ASCII.HT & "done");
Write_Line (ASCII.HT
& "lcov `cat lcov.args` -o coverage.total");
Write_Line (ASCII.HT &
"genhtml --no-branch-coverage " &
"-o ../gcov_output coverage.total");
Write_Line (ASCII.HT & "rm lcov.args coverage.*");
Write_Eol;
Write_Line ("clean:");
Write_Line
(ASCII.HT &
......
......@@ -280,7 +280,7 @@ package body Ocarina.Backends.PO_HI_Ada is
Write_Char (ASCII.HT);
Write_Str
(" $(GNATMAKE) -x -p -P$(PROJECT_FILE) -XTARGET=$(TARGET)" &
" -XBUILD=$(BUILD) -XCGCTRL=$(CGCTRL) ${USER_CFLAGS}");
" -XBUILD=$(BUILD) -XCGCTRL=$(CGCTRL) -cargs ${USER_CFLAGS}");
-- If there are C source or C libraries, there will be more
-- options.
......@@ -290,7 +290,7 @@ package body Ocarina.Backends.PO_HI_Ada is
Write_Eol;
-- Use gnateliim to determine which portion of code is
-- Use gnatelim to determine which portion of code is
-- unused and recompile the application with Eliminate
-- pragmas. Note: gnatelim is available in GNAT GPL/Pro,
-- but not GCC
......
......@@ -1947,16 +1947,9 @@ package body Ocarina.Backends.PO_HI_C.Activity is
Make_Defining_Identifier
(Map_C_Variable_Name (S, Port_Queue => True)),
Array_Size =>
Make_Expression
(Left_Expr =>
Make_Literal
(CV.New_Int_Value (Fifo_Size, 0, 10)),
Operator => Op_Asterisk,
Right_Expr =>
Make_Call_Profile
(Make_Defining_Identifier (FN (F_Sizeof)),
Make_List_Id (RE (RE_Request_T))))),
Used_Type => RE (RE_Port_T));
(CV.New_Int_Value (Fifo_Size, 0, 10))),
Used_Type => RE (RE_Request_T));
Append_Node_To_List (N, CTN.Declarations (Current_File));
N :=
......
......@@ -1649,13 +1649,11 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
or else No
(CTN.Global_Port_Node (Backend_Node (Identifier (F))))
then
N := (Make_Literal (CV.New_Int_Value (-1, 0, 10)));
N := (Make_Literal (CV.New_Int_Value (1, -1, 10)));
Used_Bus := Get_Associated_Bus (F);
if Used_Bus /= No_Node then
if AAU.Is_Virtual_Bus (Used_Bus) then
Used_Bus :=
Parent_Component (Parent_Subcomponent (Used_Bus));
......
This diff is collapsed.
......@@ -2,145 +2,68 @@
---------- Ocarina LNT Generator ---------
------------------------------------------
producer_consumer.aadl:97:05producer_consumer.aadl:109:05Begin Thread
producer_consumer.aadl:123:05: warning: T references a component type
producer_consumer.aadl:127:05: warning: CPU references a component type
producer_consumer.aadl:128:05: warning: the_bus references a component type
ocarina: Total: 0 error and 3 warnings
Begin Thread
Begin Processor
Begin Types
Begin Port
Begin Main
producer_consumer.aadl:53:05 "Main.bcg"= divbranching reduction of "PRODUCER_CONSUMER_Main.lnt";
property PROPERTY_Deadlock is
deadlock of "Main.bcg";
expected FALSE;
end property;
property Scheduling_Test (ID) is
"Main_$ID.bcg"="Main.bcg"|=
[ true* . "ACTIVATION_$ID !T_Error" ] false;
expected TRUE;
end property;
module PRODUCER_CONSUMER_Threads (PRODUCER_CONSUMER_Types) is
process Thread_P_Impl [
ACTIVATION: LNT_Channel_Dispatch,
AADL_PORT_DATA_SOURCE: LNT_Channel_Data]
is
loop
select
select
ACTIVATION (T_Begin)
[]
ACTIVATION (T_End);
AADL_PORT_DATA_SOURCE (AADLDATA)
[]
ACTIVATION (T_All);
AADL_PORT_DATA_SOURCE (AADLDATA)
[]
ACTIVATION (T_Preempt)
end select ;
ACTIVATION (T_Ok)
[]
ACTIVATION (T_Error)
[]
ACTIVATION (T_Stop)
end select
end loop
end process
process Thread_Q_Impl [
ACTIVATION: LNT_Channel_Dispatch,
AADL_PORT_DATA_SINK: LNT_Channel_Data]
is
loop
select
select
ACTIVATION (T_Begin);
AADL_PORT_DATA_SINK (AADLDATA)
[]
ACTIVATION (T_End)
[]
ACTIVATION (T_All);
AADL_PORT_DATA_SINK (AADLDATA)
[]
ACTIVATION (T_Preempt)
end select ;
ACTIVATION (T_Ok)
[]
ACTIVATION (T_Error)
[]
ACTIVATION (T_Stop)
end select
end loop
end process
end module
module PRODUCER_CONSUMER_Ports (PRODUCER_CONSUMER_Types) is
producer_consumer.aadl:53:05 Backends: warning : LNT generation requires the definition of Queue_Size property. For this generation, the default value (Queue_Size = 3) is used.
Begin Port
module LNT_Generic_Process_For_Port_Connections (Types) is
-- No Behavior Annex
-- data port --
process Data_Port [
Input: LNT_Channel_Data,
Output: LNT_Channel_Data]
Input: LNT_Channel_Port,
Output: LNT_Channel_Port]
is
var Data : LNT_Type_Data in
Data := EMPTY;
loop
select
Input (AADLDATA)
Input (?Data)
[]
Output (AADLDATA)
end select
end loop
end process
process Event_Port_Periodic [
Input: LNT_Channel_Data,
Output: LNT_Channel_Data](
Queue_Size: Nat)
is
var
Nb_Input : Nat
in
Nb_Input := 0;
loop
select
Input (AADLDATA);
if (Nb_Input < Queue_Size)
then
Nb_Input := Nb_Input + 1
end if
[]
if (Nb_Input > 0)
then
Output (AADLDATA);
Nb_Input := Nb_Input - 1
end if
Output (Data)
end select
end loop
end var
end process
process Event_Port_Sporadic [
Input: LNT_Channel_Data,
Output: LNT_Channel_Data,
-- event port --
-- for no periodic threads --
process Event_Port [
Input: LNT_Channel_Port,
Output: LNT_Channel_Port,
Notify: LNT_Channel_Event](
Queue_Size: Nat)
is
var
Nb_Input : Nat,
Data : LNT_Type_Data,
FIFO : LNT_Type_Data_FIFO,
Is_New : bool
in
Nb_Input := 0;
FIFO := {};
Data := EMPTY;
Is_New := false;
loop
select
Input (AADLDATA);
if (Nb_Input < Queue_Size)
then
Nb_Input := Nb_Input + 1
Input (?Data);
Is_New := true;
if length (FIFO) >= Queue_Size then
FIFO := tail (FIFO)
end if;
Is_New := true
FIFO := append (Data, FIFO)
[]
if (Nb_Input > 0)
then
Output (AADLDATA);
Nb_Input := Nb_Input - 1
if (FIFO != {}) then
Output (Head (FIFO));
FIFO := tail (FIFO)
else
Output (EMPTY)
end if
[]
if (Is_New)
then
if (Is_New) then
Notify (Incoming_Event);
Is_New := false
else
......@@ -151,291 +74,37 @@ module PRODUCER_CONSUMER_Ports (PRODUCER_CONSUMER_Types) is
end var
end process
end module
module PRODUCER_CONSUMER_Types
with "==", "eq" , "<", "lt" , "<=", "le" , ">", "gt" , ">=", "ge" is
type LNT_Type_Data is
AADLDATA
end type
channel LNT_Channel_Data is
(LNT_Type_Data)
end channel
type LNT_Type_Time_Constraint is
range 0 .. 60 of Nat
end type
type LNT_Type_Thread is
array [0 .. 11 ]of LNT_Type_Time_Constraint
end type
type LNT_Type_Thread_Array is
array [1 .. 2 ]of LNT_Type_Thread
end type
type LNT_Type_Dispatch is
T_Begin, T_End, T_All, T_Preempt, T_Stop, T_Error, T_Ok
end type
type LNT_Type_Event is
Incoming_Event, No_Event
end type
channel LNT_Channel_Dispatch is
(LNT_Type_Dispatch)
end channel
channel LNT_Channel_Event is
(LNT_Type_Event)
end channel
function Thread_Number : Nat
is
return 2
end function
function PPCM_THREAD : LNT_Type_Time_Constraint
is
return LNT_Type_Time_Constraint ( 30)
end function
function _+_ (
n1: LNT_Type_Time_Constraint,
n2: LNT_Type_Time_Constraint) : LNT_Type_Time_Constraint
is
return LNT_Type_Time_Constraint (Nat (n1) + Nat (n2) mod 60)
end function
function _-_ (
n1: LNT_Type_Time_Constraint,
n2: LNT_Type_Time_Constraint) : LNT_Type_Time_Constraint
is
if (n1 < n2)
then
return LNT_Type_Time_Constraint (((60 - Nat (n2)) + Nat (n1)) mod 60)
else
return LNT_Type_Time_Constraint (Nat (n1) - Nat (n2) mod 60)
end if
end function
function _*_ (
n1: LNT_Type_Time_Constraint,
n2: LNT_Type_Time_Constraint) : LNT_Type_Time_Constraint
is
return LNT_Type_Time_Constraint (Nat (n1) * Nat (n2) mod 60)
end function
end module
module PRODUCER_CONSUMER_Processor (PRODUCER_CONSUMER_Types) is
function Assign (
in var Threads: LNT_Type_Thread_Array,
I: Nat,
K: Nat,
Val: LNT_Type_Time_Constraint) : LNT_Type_Thread_Array
is
var
P : LNT_Type_Thread
in
P := Threads[I];
P[K] := Val;
Threads[I] := P
end var;
return Threads
end function
function Update_Thread (
in var Aux_Threads: LNT_Type_Thread_Array,
I: Nat,
TODO: LNT_Type_Time_Constraint) : LNT_Type_Thread_Array
is
var
P : LNT_Type_Thread
in
P := Aux_Threads[I];
if (P[2] == LNT_Type_Time_Constraint (0))
then
P[6] := LNT_Type_Time_Constraint (1)
end if;
P[2] := P[2] + TODO;
P[8] := LNT_Type_Time_Constraint (1);
if ((P[11] == LNT_Type_Time_Constraint (1)) and (P[2] == P[0]) )
then
P[7] := LNT_Type_Time_Constraint (1);
P[2] := LNT_Type_Time_Constraint (0);
P[4] := P[5];
P[5] := PPCM_THREAD;
P[10] := LNT_Type_Time_Constraint (0)
elsif ((P[11] == LNT_Type_Time_Constraint (0)) and (P[2] == P[0]) )
then
P[7] := LNT_Type_Time_Constraint (1);
P[2] := LNT_Type_Time_Constraint (0);
P[3] := P[3] + LNT_Type_Time_Constraint (1);
P[4] := P[4] + P[1];
P[5] := P[3] * P[1]
end if;
Aux_Threads[I] := P
end var;
return Aux_Threads
end function
process Sporadic_Notif [
INCOMING_EVENT_GATE: LNT_Channel_Event](
in out Threads: LNT_Type_Thread_Array,
k: Nat,
Counter: LNT_Type_Time_Constraint,
in out Is_Activated: bool)
is
select
INCOMING_EVENT_GATE (Incoming_Event);
Threads := Assign (Threads, K, 3, (Threads[k][3] + LNT_Type_Time_Constraint (1)) )
[]
INCOMING_EVENT_GATE (No_Event)
end select ;
if ((Counter >= Threads[k][4]) and (Threads[k][3] > LNT_Type_Time_Constraint (0)) )
then
Threads := Assign (Threads, k, 4, Counter);
Threads := Assign (Threads, k, 5, (Counter + Threads[k][1]) );
Threads := Assign (Threads, k, 10, LNT_Type_Time_Constraint (1));
Threads := Assign (Threads, K, 3, (Threads[k][3] - LNT_Type_Time_Constraint (1)) );
Is_Activated := true
end if
end process
process Thread_Activation [
ACTIVATION: LNT_Channel_Dispatch](
in out Threads: LNT_Type_Thread_Array,
K: Nat)
is
if (Threads[K][8] == LNT_Type_Time_Constraint (1))
then
if ((Threads[K][6] == LNT_Type_Time_Constraint (1)) and (Threads[K][7] == LNT_Type_Time_Constraint (1)) )
then
ACTIVATION (T_All);
Threads := Assign (Threads, K, 6, LNT_Type_Time_Constraint (0));
Threads := Assign (Threads, K, 7, LNT_Type_Time_Constraint (0))
elsif (Threads[K][7] == LNT_Type_Time_Constraint (1))
then
ACTIVATION (T_End);
Threads := Assign (Threads, K, 7, LNT_Type_Time_Constraint (0))
elsif (Threads[K][6] == LNT_Type_Time_Constraint (1))
then
ACTIVATION (T_Begin);
Threads := Assign (Threads, K, 6, LNT_Type_Time_Constraint (0))
else
ACTIVATION (T_Preempt)
end if;
Threads := Assign (Threads, K, 8, LNT_Type_Time_Constraint (0));
ACTIVATION (T_Ok)
elsif (Threads[K][9] == LNT_Type_Time_Constraint (0))
then
ACTIVATION (T_ERROR)
end if
end process
process Processor [
ACTIVATION_1: LNT_Channel_Dispatch,
ACTIVATION_2: LNT_Channel_Dispatch,
INCOMING_EVENT_2: LNT_Channel_Event]
-- for periodic threads
process Event_Port_For_Periodic [
Input: LNT_Channel_Port,
Output: LNT_Channel_Port](
Queue_Size: Nat)
is
var
Threads : LNT_Type_Thread_Array,
Counter : LNT_Type_Time_Constraint,
I : Nat,
k : Nat,
Is_Activated : bool,
Preempt : bool,
TODO : LNT_Type_Time_Constraint,
Nb_Active_Thread : Nat
Data : LNT_Type_Data,
FIFO : LNT_Type_Data_FIFO,
Is_New : bool
in
Counter := LNT_Type_Time_Constraint (0);
Threads := LNT_Type_Thread_Array (LNT_Type_Thread (LNT_Type_Time_Constraint (0)));
Threads[ 1] := LNT_Type_Thread (LNT_Type_Time_Constraint (8), LNT_Type_Time_Constraint (10), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (10), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0));
Threads[ 2] := LNT_Type_Thread (LNT_Type_Time_Constraint (2), LNT_Type_Time_Constraint (15), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (15), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1), LNT_Type_Time_Constraint (0), LNT_Type_Time_Constraint (1));
FIFO := {};
Data := EMPTY;
Is_New := false;
loop
select
if (Counter < PPCM_THREAD)
then
Nb_Active_Thread := 0;
K := 1;
while (K <= Thread_Number) loop
if ((Counter >= Threads[K][4]) and (Counter >= Threads[K][5]) )
then
Threads := Assign (Threads, K, 9, LNT_Type_Time_Constraint (0))
elsif ((Threads[K][10] == LNT_Type_Time_Constraint (1)) and (Threads[K][9] == LNT_Type_Time_Constraint (1)) and (Counter >= Threads[K][4]) and (Counter < Threads[K][5]) )
then
Preempt := true;
TODO := Threads[K][0] - Threads[K][2];
I := 1;
while ((I <= (K - 1) ) and Preempt) loop
if ((Threads[I][10] == LNT_Type_Time_Constraint (1)) and (Threads[I][9] == LNT_Type_Time_Constraint (1)) and (Counter + TODO > Threads[I][4]) )
then
TODO := Threads[I][4] - Counter;
Preempt := false
else
I := I + 1
end if
end loop;
Counter := Counter + TODO;
Nb_Active_Thread := Nb_Active_Thread + 1;
Threads := Update_Thread (Threads, K, TODO);
Thread_Activation [ACTIVATION_1] (!?Threads, 1);
Thread_Activation [ACTIVATION_2] (!?Threads, 2);
Is_Activated := false;
Sporadic_Notif [INCOMING_EVENT_2] (!?Threads, 2, Counter, !?Is_Activated);
if (Is_Activated)
then
k := 1
else
k := k + 1
end if
else
k := k + 1
end if
end loop;
if (Nb_Active_Thread == 0)
then
Counter := Counter + LNT_Type_Time_Constraint (1)
end if
end if
Input (?Data);
Is_New := true;
if length (FIFO) >= Queue_Size then
FIFO := tail (FIFO)
end if;
FIFO := append (Data, FIFO)
[]
if (Counter >= PPCM_THREAD)
then
ACTIVATION_1 (T_Stop);
ACTIVATION_2 (T_Stop)
if (FIFO != {}) then
Output (Head (FIFO));
FIFO := tail (FIFO)
else
Output (EMPTY)
end if
end select
end loop
end var
end process
end module
module PRODUCER_CONSUMER_Main (PRODUCER_CONSUMER_Types, PRODUCER_CONSUMER_Processor, PRODUCER_CONSUMER_Threads, PRODUCER_CONSUMER_Ports) is
process Main [
ACTIVATION_1: LNT_Channel_Dispatch,
SEND_pr_a_alpha__pr_b_beta: LNT_Channel_Data,
ACTIVATION_2: LNT_Channel_Dispatch,
INCOMING_EVENT_2: LNT_Channel_Event,
RECEIVE_pr_a_alpha__pr_b_beta: LNT_Channel_Data]
is
par
ACTIVATION_1 , SEND_pr_a_alpha__pr_b_beta ->
Thread_P_Impl [ACTIVATION_1, SEND_pr_a_alpha__pr_b_beta]
||
ACTIVATION_2 , INCOMING_EVENT_2 , SEND_pr_a_alpha__pr_b_beta ->
par
SEND_pr_a_alpha__pr_b_beta , RECEIVE_pr_a_alpha__pr_b_beta , INCOMING_EVENT_2 ->
Event_Port_Sporadic [SEND_pr_a_alpha__pr_b_beta, RECEIVE_pr_a_alpha__pr_b_beta, INCOMING_EVENT_2] ( 3)
||
ACTIVATION_2 , RECEIVE_pr_a_alpha__pr_b_beta ->
Thread_Q_Impl [ACTIVATION_2, RECEIVE_pr_a_alpha__pr_b_beta]
end par
||
ACTIVATION_1 , ACTIVATION_2 , INCOMING_EVENT_2 ->
Processor [ACTIVATION_1, ACTIVATION_2, INCOMING_EVENT_2]
end par
end process
end module
This diff is collapsed.
This diff is collapsed.
......@@ -327,3 +327,8 @@ tests/github/issue_66/test.aadl
tests/github/issue_87/test.aadl
tests/root_system/test.aadl
tests/LNT/FCS/FCS.aadl
tests/LNT/PC/producer_consumer.aadl
tests/LNT/RADAR/radar.aadl
tests/LNT/ROBOT/robot.aadl