Commit 15aede27 authored by hana's avatar hana

update:

port connections generation: generic construction are included to be copied while transformation.
processor and main: multiple event port connections are considered with non-periodic threads.

new:
main generation: connection identifiers are now considered in gate naming rule.
parent 9350c78e
...@@ -421,6 +421,7 @@ AC_OUTPUT([ ...@@ -421,6 +421,7 @@ AC_OUTPUT([
resources/runtime/aadl_xml/Makefile resources/runtime/aadl_xml/Makefile
resources/runtime/alloy/Makefile resources/runtime/alloy/Makefile
resources/runtime/cheddar/Makefile resources/runtime/cheddar/Makefile
resources/runtime/lnt/Makefile
resources/runtime/python/Makefile resources/runtime/python/Makefile
projects/ocarina.gpr projects/ocarina.gpr
src/main/Makefile src/main/Makefile
......
SUBDIRS = cheddar aadl_xml python alloy SUBDIRS = cheddar aadl_xml python alloy lnt
@DEBUG_FALSE@DEBUG_FLAG = --disable-debug @DEBUG_FALSE@DEBUG_FLAG = --disable-debug
@DEBUG_TRUE@DEBUG_FLAG = --enable-debug @DEBUG_TRUE@DEBUG_FLAG = --enable-debug
......
module LNT_Generic_Process_For_Port_Connections (Types) is
-- No Behavior Annex
-- data port --
process Data_Port [
Input: LNT_Channel_Port,
Output: LNT_Channel_Port]
is
var Data : LNT_Type_Data in
Data := EMPTY;
loop
select
Input (?Data)
[]
Output (Data)
end select
end loop
end var
end process
-- 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
Data : LNT_Type_Data,
FIFO : LNT_Type_Data_FIFO,
Is_New : bool
in
FIFO := {};
Data := EMPTY;
Is_New := false;
loop
select
Input (?Data);
Is_New := true;
if length (FIFO) >= Queue_Size then
FIFO := tail (FIFO)
end if;
FIFO := append (Data, FIFO)
[]
if (FIFO != {}) then
Output (Head (FIFO));
FIFO := tail (FIFO)
else
Output (EMPTY)
end if
[]
if (Is_New) then
Notify (Incoming_Event);
Is_New := false
else
Notify (No_Event)
end if
end select
end loop
end var
end process
-- for periodic threads
process Event_Port_For_Periodic [
Input: LNT_Channel_Port,
Output: LNT_Channel_Port](
Queue_Size: Nat)
is
var
Data : LNT_Type_Data,
FIFO : LNT_Type_Data_FIFO,
Is_New : bool
in
FIFO := {};
Data := EMPTY;
Is_New := false;
loop
select
Input (?Data);
Is_New := true;
if length (FIFO) >= Queue_Size then
FIFO := tail (FIFO)
end if;
FIFO := append (Data, FIFO)
[]
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 LNT_Generic_Process_For_Port_Connections_BA (BA_Types) is -- With Behavior Annex
-- data port --
process Data_Port [
Input: LNT_Channel_Data_Port,
Output: LNT_Channel_Data_Port]
is
var Data : LNT_Type_Data in
Data := DATA_INIT;
loop
select
Input (?Data)
[]
Output (Data)
end select
end loop
end var
end process
-- event port --
-- for no periodic threads --
process Event_Port [
Input: LNT_Channel_Event_Port,
Output: LNT_Channel_Event_Port,
Notify: LNT_Channel_Event](
Queue_Size: Nat)
is
var
Nb_Events : Nat,
Is_New : bool
in
Nb_Events := 0;
Is_New := false;
loop
select
Input (true);
Is_New := true;
if (Nb_Events < Queue_Size) then
Nb_Events := Nb_Events + 1
end if
[]
if (Nb_Events > 0) then
Output (true);
Nb_Events := Nb_Events - 1
else
Output (false)
end if
[]
if (Is_New) then
Notify (Incoming_Event);
Is_New := false
else
Notify (No_Event)
end if
end select
end loop
end var
end process
-- for periodic threads --
process Event_Port_For_Periodic [
Input: LNT_Channel_Event_Port,
Output: LNT_Channel_Event_Port](
Queue_Size: Nat)
is
var
Nb_Events : Nat
in
Nb_Events := 0;
loop
select
Input (true);
if (Nb_Events < Queue_Size) then
Nb_Events := Nb_Events + 1
end if
[]
if (Nb_Events > 0) then
Output (true);
Nb_Events := Nb_Events - 1
else
Output (false)
end if
end select
end loop
end var
end process
-- event data port
-- for no periodic threads --
process Event_Data_Port_Sporadic [
Input: LNT_Channel_Event_Data_Port,
Output: LNT_Channel_Event_Data_Port,
Notify: LNT_Channel_Event](
Queue_Size: Nat)
is
var
FIFO : LNT_Type_Data_FIFO,
Is_New : bool,
D : LNT_Type_Data
in
FIFO := {};
D := DATA_INIT;
Is_New := false;
loop
select
Input (?D, true);
Is_New := true;
if length (FIFO) >= Queue_Size then
FIFO := tail (FIFO)
end if;
FIFO := append (D, FIFO)
[]
if (Is_New) then
Notify (Incoming_Event);
Is_New := false
else
Notify (No_Event)
end if
[]
if (FIFO != {}) then
Output (Head (FIFO), true);
FIFO := tail (FIFO)
else
Output (D,false)
end if
end select
end loop
end var
end process
-- for periodic threads --
process Event_Data_Port_For_Periodic [
Input: LNT_Channel_Event_Data_Port,
Output: LNT_Channel_Event_Data_Port](
Queue_Size: Nat)
is
var
FIFO : LNT_Type_Data_FIFO,
D : LNT_Type_Data
in
FIFO := {};
D := DATA_INIT;
loop
select
Input (?D, true);
if length (FIFO) >= Queue_Size then
FIFO := tail (FIFO)
end if;
FIFO := append (D, FIFO)
[]
if (FIFO != {}) then
Output (Head (FIFO), true);
FIFO := tail (FIFO)
else
Output (D,false)
end if
end select
end loop
end var
end process
end module
AUTOMAKE_OPTIONS = no-dependencies
LNT_FILES = $(srcdir)/LNT_Generic_Process_For_Port_Connections.lnt \
$(srcdir)/LNT_Generic_Process_For_Port_Connections_BA.lnt
EXTRA_DIST = $(LNT_FILES)
lnt_generic = ${shell $(CYGPATH_U) '$(includedir)/ocarina/runtime/lnt'}
install-data-local:
$(INSTALL) -d $(DESTDIR)$(lnt_generic)
for f in $(LNT_FILES); do $(INSTALL) -m 444 $$f $(DESTDIR)$(lnt_generic) ; done
...@@ -74,36 +74,13 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -74,36 +74,13 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
procedure Visit_Thread_Instance (E : Node_Id); procedure Visit_Thread_Instance (E : Node_Id);
procedure Visit_Device_Instance (E : Node_Id); procedure Visit_Device_Instance (E : Node_Id);
function Build_Name_From_Path (Path : List_Id) return Name_Id;
procedure Find_Instance_By_Name (Key : Name_Id; Target : List_Id; procedure Find_Instance_By_Name (Key : Name_Id; Target : List_Id;
Instance : out Node_Id; Index : out Natural; Instance : out Node_Id; Index : out Natural;
Is_Not_Periodic : out boolean); Is_Not_Periodic : out boolean);
function Is_Not_Periodic (Index : Natural; Target : List_Id)
return boolean;
procedure Make_Process_Main; procedure Make_Process_Main;
function Make_Gate_Identifier (S : Node_Id) return Name_Id; function Make_Gate_Identifier (S : Node_Id) return Name_Id;
function Build_Name_From_Path (Path : List_Id) return Name_Id
is
N : Node_Id := AIN.First_Node (Path);
First : Boolean := True;
begin
Set_Str_To_Name_Buffer ("");
while Present (N) loop
if First then
First := False;
else
Add_Str_To_Name_Buffer ("_");
end if;
Get_Name_String_And_Append (AIN.Name (AIN.Identifier (AIN.Item (N))));
N := AIN.Next_Node (N);
end loop;
return Name_Find;
end Build_Name_From_Path;
function Make_Gate_Identifier (S : Node_Id) return Name_Id is function Make_Gate_Identifier (S : Node_Id) return Name_Id is
N_Connection : Node_Id; N_Connection : Node_Id;
L : List_Id; L : List_Id;
...@@ -113,48 +90,41 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -113,48 +90,41 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
-- port_in thread -- port_in thread
L := Sources (S); L := Sources (S);
-- port_out thread, first connection 1-1 -- port_out thread, first connection 1-1
N_Connection := AIN.Item (AIN.First_Node (L)); if Present (AIN.First_Node (L)) then
while (AIN.Is_In (N_Connection)) loop
L := Sources (N_Connection);
N_Connection := AIN.Item (AIN.First_Node (L)); N_Connection := AIN.Item (AIN.First_Node (L));
end loop; while (AIN.Is_In (N_Connection)) loop
N_Connection := AIN.Extra_Item (AIN.First_Node (L)); L := Sources (N_Connection);
if Present (AIN.First_Node (L)) then
-- connection Path system N_Connection := AIN.Item (AIN.First_Node (L));
Connection := Add_Prefix_To_Name ("RECEIVE_", end if;
Build_Name_From_Path (Path (Source (N_Connection)))); end loop;
N_Connection := AIN.Extra_Item (AIN.First_Node (L));
Connection := Add_Suffix_To_Name ("__", Connection); -- connection identifier at system level
Connection := Add_Prefix_To_Name
Connection := Add_Suffix_To_Name (Get_Name_String ( ("RECEIVE_", AIN.Display_Name (
Build_Name_From_Path (Path (Destination (N_Connection)))), AIN.Identifier (N_Connection)));
Connection); end if;
elsif (AIN.Is_Out (S)) then elsif (AIN.Is_Out (S)) then
-- port_in thread -- port_in thread
L := Destinations (S); L := Destinations (S);
-- port_out thread, first connection 1-1 -- port_out thread, first connection 1-1
N_Connection := AIN.Item (AIN.First_Node (L)); if Present (AIN.First_Node (L)) then
while (AIN.Is_Out (N_Connection)) loop
-- port_out process
L := Destinations (N_Connection);
N_Connection := AIN.Item (AIN.First_Node (L)); N_Connection := AIN.Item (AIN.First_Node (L));
end loop;
-- connection instance system/process
N_Connection := AIN.Extra_Item (AIN.First_Node (L));
Connection := Add_Prefix_To_Name ("SEND_",
Build_Name_From_Path (Path (Source (N_Connection))));
Connection := Add_Suffix_To_Name ("__", Connection);
Connection := Add_Suffix_To_Name (Get_Name_String (
Build_Name_From_Path (Path (Destination (N_Connection)))),
Connection);
while (AIN.Is_Out (N_Connection)) loop
-- port_out process
L := Destinations (N_Connection);
if Present (AIN.First_Node (L)) then
N_Connection := AIN.Item (AIN.First_Node (L));
end if;
end loop;
-- connection instance system/process
N_Connection := AIN.Extra_Item (AIN.First_Node (L));
Connection := Add_Prefix_To_Name
("SEND_", AIN.Display_Name (
AIN.Identifier (N_Connection)));
end if;
end if; end if;
-- Put_Line (Image (Connection));
return Connection; return Connection;
end Make_Gate_Identifier; end Make_Gate_Identifier;
...@@ -167,6 +137,8 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -167,6 +137,8 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
-- Main_Hide_Declaration_List : List_Id := No_List; -- Main_Hide_Declaration_List : List_Id := No_List;
Main_Gate_Declaration_List : List_Id := No_List; Main_Gate_Declaration_List : List_Id := No_List;
Processor_Gates_List : List_Id := No_List; Processor_Gates_List : List_Id := No_List;
Processor_Event_Gates_List : List_Id := No_List;
Processor_Event_Gate_Declaration_List : List_Id := No_List;
Main_Interface_Synchronisation_List : List_Id := No_List; Main_Interface_Synchronisation_List : List_Id := No_List;
function Generate_LNT_Main (AADL_Tree : Node_Id) function Generate_LNT_Main (AADL_Tree : Node_Id)
...@@ -176,6 +148,9 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -176,6 +148,9 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
Processor_Gates_List := New_List; Processor_Gates_List := New_List;
Main_Gate_Declaration_List := New_List; Main_Gate_Declaration_List := New_List;
Main_Interface_Synchronisation_List := New_List; Main_Interface_Synchronisation_List := New_List;
Processor_Event_Gate_Declaration_List := New_List;
Processor_Event_Gates_List := New_List;
LNT_Processor_Gate_Declaration_List := New_List;
Visit (AADL_Tree); Visit (AADL_Tree);
return Module_Node; return Module_Node;
end Generate_LNT_Main; end Generate_LNT_Main;
...@@ -214,18 +189,24 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -214,18 +189,24 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
end if; end if;
Definitions_List := New_List; Definitions_List := New_List;
Modules_List := New_List ( Modules_List := New_List (
New_Identifier ( Make_Identifier ("Types"),
Get_String_Name ("_Types"),
Get_Name_String (System_Name)),
New_Identifier ( New_Identifier (
Get_String_Name ("_Processor"), Get_String_Name ("_Processor"),
Get_Name_String (System_Name)), Get_Name_String (System_Name)),
New_Identifier ( New_Identifier (
Get_String_Name ("_Threads"), Get_String_Name ("_Threads"),
Get_Name_String (System_Name)),
New_Identifier (
Get_String_Name ("_Ports"),
Get_Name_String (System_Name))); Get_Name_String (System_Name)));
if BLNu.Is_Empty (LNT_States_List) then
BLNu.Append_Node_To_List (
Make_Identifier (
"LNT_Generic_Process_For_Port_Connections"),
Modules_List);
else
BLNu.Append_Node_To_List (
Make_Identifier (
"LNT_Generic_Process_For_Port_Connections_BA"),
Modules_List);
end if;
Predefined_Functions_List := New_List; Predefined_Functions_List := New_List;
Visit (N); Visit (N);
...@@ -272,13 +253,6 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -272,13 +253,6 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
S := AIN.Next_Node (S); S := AIN.Next_Node (S);
end loop; end loop;
end if; end if;
if not AINU.Is_Empty (Connections (E)) then
S := AIN.First_Node (Connections (E));
while Present (S) loop
-- Put_Line (Image (AIN.Display_Name (AIN.Identifier (S))));
S := AIN.Next_Node (S);
end loop;
end if;
end Visit_System_Instance; end Visit_System_Instance;
---------------------------- ----------------------------
...@@ -359,8 +333,8 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -359,8 +333,8 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
-- port -- port
Port_Gates_List := New_List ( Port_Gates_List := New_List (
Aux_N_Port_2, -- RECEIVE_ Make_Identifier (N_SEND), -- SEND_
Make_Identifier (N_SEND)); -- SEND_ Aux_N_Port_2); -- RECEIVE_
N_Port := Make_Process_Instantiation_Statement N_Port := Make_Process_Instantiation_Statement
(Make_Identifier ("Data_Port"), (Make_Identifier ("Data_Port"),
...@@ -446,17 +420,20 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -446,17 +420,20 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
S : Node_Id; S : Node_Id;
Ni : Node_Id; Ni : Node_Id;
P : Node_Id; P : Node_Id;
Event_Number : Natural := 0;
Index : Natural; Index : Natural;
Queue_Size : Natural := 3; Queue_Size : Natural := 3;
-- Overflow : Name_Id; -- Overflow : Name_Id;
N_Activation : Node_Id; N_Activation : Node_Id;
Aux_N_Activation_1 : Node_Id; Aux_N_Activation_1 : Node_Id;
Aux_N_Activation_2 : Node_Id; Aux_N_Activation_2 : Node_Id;
N_Event_Declaration : Node_Id;
Aux_N_Event_Declaration : Node_Id;
N_Event : Node_Id; N_Event : Node_Id;
N_Event_Name : Name_Id;
Aux_N_Event : Node_Id; Aux_N_Event : Node_Id;
Aux_N_Event_1 : Node_Id; Aux_N_Event_1 : Node_Id;
Aux_N_Event_2 : Node_Id;
N_Port : Node_Id; N_Port : Node_Id;
Aux_N_Port_1 : Node_Id; Aux_N_Port_1 : Node_Id;
Aux_N_Port_2 : Node_Id; Aux_N_Port_2 : Node_Id;
...@@ -492,14 +469,10 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -492,14 +469,10 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
Make_Identifier ("LNT_Channel_Dispatch"), Make_Identifier ("LNT_Channel_Dispatch"),
Aux_N_Activation_2)); Aux_N_Activation_2));
if Is_Not_Periodic then if Is_Not_Periodic then
N_Event := New_Identifier ( N_Event_Name := New_Identifier (
Remove_Prefix_From_Name ( Remove_Prefix_From_Name (
" ", Get_String_Name (Integer'Image (Index))), " ", Get_String_Name (Integer'Image (Index))),
"INCOMING_EVENT_"); "INCOMING_EVENT_");
BLNu.Append_Node_To_List (
Make_Gate_Declaration (
Make_Identifier ("LNT_Channel_Event"),
N_Event), L_Gates_Declaration);
end if; end if;
if not AINU.Is_Empty (Features (E)) then if not AINU.Is_Empty (Features (E)) then
S := AIN.First_Node (Features (E)); S := AIN.First_Node (Features (E));
...@@ -549,8 +522,9 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -549,8 +522,9 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
if ((AIN.Is_Data (S)) and then (not AIN.Is_Event (S))) then if ((AIN.Is_Data (S)) and then (not AIN.Is_Event (S))) then
-- data port -- data port
Port_Gates_List := New_List ( Port_Gates_List := New_List (
Aux_N_Port_2, -- RECEIVE_ Make_Identifier (N_SEND), -- SEND_
Make_Identifier (N_SEND)); -- SEND_ Aux_N_Port_2 -- RECEIVE_
);
N_Port := Make_Process_Instantiation_Statement N_Port := Make_Process_Instantiation_Statement
(Make_Identifier ("Data_Port"), (Make_Identifier ("Data_Port"),
...@@ -559,15 +533,39 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -559,15 +533,39 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
elsif AIN.Is_Event (S) then elsif AIN.Is_Event (S) then
-- event port -- event port
if Is_Not_Periodic then if Is_Not_Periodic then
if (Event_Number > 0) then
N_Event := New_Identifier (
Remove_Prefix_From_Name (
" ", Get_String_Name (
Integer'Image (Event_Number))),
Get_Name_String (N_Event_Name));
else
N_Event := Make_Identifier (N_Event_Name);
end if;
Aux_N_Event := BLNu.Make_Node_Container (N_Event); Aux_N_Event := BLNu.Make_Node_Container (N_Event);
Aux_N_Event_1 := BLNu.Make_Node_Container (N_Event); Aux_N_Event_1 := BLNu.Make_Node_Container (N_Event);
Aux_N_Event_2 := BLNu.Make_Node_Container (N_Event);
-- add to the Processor event gate list
BLNu.Append_Node_To_List (N_Event,
Processor_Event_Gates_List);
-- for processor and main generation
N_Event_Declaration := Make_Gate_Declaration (
Make_Identifier ("LNT_Channel_Event"),
Aux_N_Event);
Aux_N_Event_Declaration :=