Commit 89ae492c authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files
parents 56f8884e b57d0d6f
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- 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 -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -332,17 +332,13 @@ package body Ocarina.Backends.C_Values is ...@@ -332,17 +332,13 @@ package body Ocarina.Backends.C_Values is
if V.Sign < 0 then if V.Sign < 0 then
Add_Char_To_Name_Buffer ('-'); Add_Char_To_Name_Buffer ('-');
elsif V.Base = 16 then elsif V.Base = 16 then
Add_Str_To_Name_Buffer ("16#"); Add_Str_To_Name_Buffer ("0x");
elsif V.Base = 8 then elsif V.Base = 8 then
Add_Str_To_Name_Buffer ("8#"); Add_Str_To_Name_Buffer ("0");
end if; end if;
Add_ULL_To_Name_Buffer (V.IVal, ULL (V.Base)); 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 => when K_Float =>
Add_Str_To_Name_Buffer (Long_Double'Image (V.FVal)); Add_Str_To_Name_Buffer (Long_Double'Image (V.FVal));
declare declare
......
...@@ -1493,7 +1493,7 @@ package body Ocarina.Backends.Build_Utils is ...@@ -1493,7 +1493,7 @@ package body Ocarina.Backends.Build_Utils is
Write_Line Write_Line
("###################################################"); ("###################################################");
Write_Eol; Write_Eol;
Write_Str Write_Line
("SUBDIRS = " & ("SUBDIRS = " &
"$(filter-out Makefile polyorb-hi-c, $(wildcard *))"); "$(filter-out Makefile polyorb-hi-c, $(wildcard *))");
Write_Eol; Write_Eol;
...@@ -1502,6 +1502,25 @@ package body Ocarina.Backends.Build_Utils is ...@@ -1502,6 +1502,25 @@ package body Ocarina.Backends.Build_Utils is
(ASCII.HT & (ASCII.HT &
"set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d ; done"); "set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d ; done");
Write_Eol; 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 ("clean:");
Write_Line Write_Line
(ASCII.HT & (ASCII.HT &
......
...@@ -280,7 +280,7 @@ package body Ocarina.Backends.PO_HI_Ada is ...@@ -280,7 +280,7 @@ package body Ocarina.Backends.PO_HI_Ada is
Write_Char (ASCII.HT); Write_Char (ASCII.HT);
Write_Str Write_Str
(" $(GNATMAKE) -x -p -P$(PROJECT_FILE) -XTARGET=$(TARGET)" & (" $(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 -- If there are C source or C libraries, there will be more
-- options. -- options.
...@@ -290,7 +290,7 @@ package body Ocarina.Backends.PO_HI_Ada is ...@@ -290,7 +290,7 @@ package body Ocarina.Backends.PO_HI_Ada is
Write_Eol; 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 -- unused and recompile the application with Eliminate
-- pragmas. Note: gnatelim is available in GNAT GPL/Pro, -- pragmas. Note: gnatelim is available in GNAT GPL/Pro,
-- but not GCC -- but not GCC
......
...@@ -1947,16 +1947,9 @@ package body Ocarina.Backends.PO_HI_C.Activity is ...@@ -1947,16 +1947,9 @@ package body Ocarina.Backends.PO_HI_C.Activity is
Make_Defining_Identifier Make_Defining_Identifier
(Map_C_Variable_Name (S, Port_Queue => True)), (Map_C_Variable_Name (S, Port_Queue => True)),
Array_Size => Array_Size =>
Make_Expression Make_Literal
(Left_Expr => (CV.New_Int_Value (Fifo_Size, 0, 10))),
Make_Literal Used_Type => RE (RE_Request_T));
(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));
Append_Node_To_List (N, CTN.Declarations (Current_File)); Append_Node_To_List (N, CTN.Declarations (Current_File));
N := N :=
......
...@@ -1649,13 +1649,11 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -1649,13 +1649,11 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
or else No or else No
(CTN.Global_Port_Node (Backend_Node (Identifier (F)))) (CTN.Global_Port_Node (Backend_Node (Identifier (F))))
then then
N := (Make_Literal (CV.New_Int_Value (1, -1, 10)));
N := (Make_Literal (CV.New_Int_Value (-1, 0, 10)));
Used_Bus := Get_Associated_Bus (F); Used_Bus := Get_Associated_Bus (F);
if Used_Bus /= No_Node then if Used_Bus /= No_Node then
if AAU.Is_Virtual_Bus (Used_Bus) then if AAU.Is_Virtual_Bus (Used_Bus) then
Used_Bus := Used_Bus :=
Parent_Component (Parent_Subcomponent (Used_Bus)); Parent_Component (Parent_Subcomponent (Used_Bus));
......
This diff is collapsed.
...@@ -2,145 +2,68 @@ ...@@ -2,145 +2,68 @@
---------- Ocarina LNT Generator --------- ---------- 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 Processor
Begin Types Begin Types
Begin Port
Begin Main Begin Main
producer_consumer.aadl:53:05 "Main.bcg"= divbranching reduction of "PRODUCER_CONSUMER_Main.lnt"; 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.
property PROPERTY_Deadlock is Begin Port
deadlock of "Main.bcg"; module LNT_Generic_Process_For_Port_Connections (Types) is
expected FALSE; -- No Behavior Annex
end property; -- data port --
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
process Data_Port [ process Data_Port [
Input: LNT_Channel_Data, Input: LNT_Channel_Port,
Output: LNT_Channel_Data] Output: LNT_Channel_Port]
is
loop
select
Input (AADLDATA)
[]
Output (AADLDATA)
end select
end loop
end process
process Event_Port_Periodic [
Input: LNT_Channel_Data,
Output: LNT_Channel_Data](
Queue_Size: Nat)
is is
var var Data : LNT_Type_Data in
Nb_Input : Nat Data := EMPTY;
in
Nb_Input := 0;
loop loop
select select
Input (AADLDATA); Input (?Data)
if (Nb_Input < Queue_Size) []
then Output (Data)
Nb_Input := Nb_Input + 1
end if
[]
if (Nb_Input > 0)
then
Output (AADLDATA);
Nb_Input := Nb_Input - 1
end if
end select end select
end loop end loop
end var end var
end process end process
process Event_Port_Sporadic [ -- event port --
Input: LNT_Channel_Data, -- for no periodic threads --
Output: LNT_Channel_Data, process Event_Port [
Input: LNT_Channel_Port,
Output: LNT_Channel_Port,
Notify: LNT_Channel_Event]( Notify: LNT_Channel_Event](
Queue_Size: Nat) Queue_Size: Nat)
is is
var var
Nb_Input : Nat, Data : LNT_Type_Data,
FIFO : LNT_Type_Data_FIFO,
Is_New : bool Is_New : bool
in in
Nb_Input := 0; FIFO := {};
Data := EMPTY;
Is_New := false; Is_New := false;
loop loop
select select
Input (AADLDATA); Input (?Data);
if (Nb_Input < Queue_Size) Is_New := true;
then if length (FIFO) >= Queue_Size then
Nb_Input := Nb_Input + 1 FIFO := tail (FIFO)
end if; end if;
Is_New := true FIFO := append (Data, FIFO)
[] []
if (Nb_Input > 0) if (FIFO != {}) then
then Output (Head (FIFO));
Output (AADLDATA); FIFO := tail (FIFO)
Nb_Input := Nb_Input - 1 else
Output (EMPTY)
end if end if
[] []
if (Is_New) if (Is_New) then
then
Notify (Incoming_Event); Notify (Incoming_Event);
Is_New := false Is_New := false
else else
...@@ -149,293 +72,39 @@ module PRODUCER_CONSUMER_Ports (PRODUCER_CONSUMER_Types) is ...@@ -149,293 +72,39 @@ module PRODUCER_CONSUMER_Ports (PRODUCER_CONSUMER_Types) is
end select end select
end loop end loop
end var end var
end process end process
end module -- for periodic threads
module PRODUCER_CONSUMER_Types process Event_Port_For_Periodic [
with "==", "eq" , "<", "lt" , "<=", "le" , ">", "gt" , ">=", "ge" is Input: LNT_Channel_Port,
type LNT_Type_Data is Output: LNT_Channel_Port](
AADLDATA Queue_Size: Nat)
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]
is is
var var
Threads : LNT_Type_Thread_Array, Data : LNT_Type_Data,
Counter : LNT_Type_Time_Constraint, FIFO : LNT_Type_Data_FIFO,
I : Nat, Is_New : bool
k : Nat,
Is_Activated : bool,
Preempt : bool,
TODO : LNT_Type_Time_Constraint,
Nb_Active_Thread : Nat
in in
Counter := LNT_Type_Time_Constraint (0); FIFO := {};
Threads := LNT_Type_Thread_Array (LNT_Type_Thread (LNT_Type_Time_Constraint (0))); Data := EMPTY;
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)); Is_New := false;
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));
loop loop
select select
if (Counter < PPCM_THREAD) Input (?Data);
then Is_New := true;
Nb_Active_Thread := 0; if length (FIFO) >= Queue_Size then
K := 1; FIFO := tail (FIFO)
while (K <= Thread_Number) loop end if;
if ((Counter >= Threads[K][4]) and (Counter >= Threads[K][5]) ) FIFO := append (Data, FIFO)
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