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([
resources/runtime/aadl_xml/Makefile
resources/runtime/alloy/Makefile
resources/runtime/cheddar/Makefile
resources/runtime/lnt/Makefile
resources/runtime/python/Makefile
projects/ocarina.gpr
src/main/Makefile
......
SUBDIRS = cheddar aadl_xml python alloy
SUBDIRS = cheddar aadl_xml python alloy lnt
@DEBUG_FALSE@DEBUG_FLAG = --disable-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
......@@ -28,262 +28,41 @@
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
with Ocarina.Namet; use Ocarina.Namet;
with Ocarina.Backends;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Ocarina.Backends.Build_Utils;
use Ocarina.Backends.Build_Utils;
with Ocarina.Backends.Messages;
use Ocarina.Backends.Messages;
with Ocarina.Namet; use Ocarina.Namet;
with Ocarina.Backends.LNT.Nutils;
with Ocarina.Backends.LNT.Nodes;
with Ocarina.Backends.LNT.Components;
use Ocarina.Backends.LNT.Components;
use Ocarina.Backends.LNT.Nutils;
with Ada.Text_IO; use Ada.Text_IO;
package body Ocarina.Backends.LNT.Tree_Generator_Port is
package BLN renames Ocarina.Backends.LNT.Nodes;
package BLNu renames Ocarina.Backends.LNT.Nutils;
use BLN;
use BLNu;
procedure Add_LNT_Data_Port (L_Ports : List_Id);
procedure Add_LNT_Event_Port (L_Ports : List_Id; Is_Sporadic : boolean);
function Make_Loop_Select (In_Select : List_Id)
return Node_Id;
function Make_Loop_Select (In_Select : List_Id)
return Node_Id is
N : Node_Id;
procedure Generate_LNT_Port is
Is_Done : Boolean := False;
begin
N := Make_Loop_Statement
(New_List (Make_Select_Statement (In_Select)));
return N;
end Make_Loop_Select;
procedure Add_LNT_Data_Port (L_Ports : List_Id) is
N : Node_Id;
In_Select : List_Id;
begin
In_Select := New_List (
Make_Select_Statement_Alternative
(New_List (Make_Communication_Statement
(Make_Identifier ("Input"),
New_List (Make_Offer_Statement
(No_Node,
Make_Identifier ("AADLDATA"),
false)),
false,
No_Node))),
Make_Select_Statement_Alternative
(New_List (Make_Communication_Statement
(Make_Identifier ("Output"),
New_List (Make_Offer_Statement
(No_Node,
Make_Identifier ("AADLDATA"),
false)),
false,
No_Node)))
);
N := Make_Process_Definition
(No_Node, Make_Identifier ("Data_Port"),
No_List,
New_List (
Make_Gate_Declaration
(Make_Identifier ("LNT_Channel_Port"),
Make_Identifier ("Input")),
Make_Gate_Declaration
(Make_Identifier ("LNT_Channel_Port"),
Make_Identifier ("Output"))),
No_List,
No_List,
New_List (Make_Loop_Select (In_Select)));
BLNu.Append_Node_To_List (N, L_Ports);
end Add_LNT_Data_Port;
procedure Add_LNT_Event_Port (L_Ports : List_Id;
Is_Sporadic : boolean) is
N : Node_Id;
N_Port : Node_Id;
Notify : Node_Id;
L_Parameters : List_Id;
L_Gates : List_Id;
Var_Dec : List_Id;
Out_Loop : List_Id;
In_Select : List_Id;
In_Select_1 : List_Id;
begin
L_Parameters := New_List;
BLNu.Append_Node_To_List (
Make_Parameter_Specification (
Make_Identifier ("Queue_Size"),
Make_Identifier ("Nat")),
L_Parameters);
Var_Dec := New_List (
Make_Var_Declaration (
Make_Identifier ("Nb_Input"),
Make_Identifier ("Nat")));
if (Is_Sporadic) then
BLNu.Append_Node_To_List (
Make_Var_Declaration (
Make_Identifier ("Is_New"),
Make_Identifier ("bool")),
Var_Dec);
end if;
Out_Loop := New_List (
Make_Assignment_Statement (
Make_Identifier ("Nb_Input"),
Make_Identifier ("0"))
);
if (Is_Sporadic) then
BLNu.Append_Node_To_List (
Make_Assignment_Statement (
Make_Identifier ("Is_New"),
Make_Identifier ("false")),
Out_Loop);
end if;
In_Select_1 := New_List (
Make_Communication_Statement (
Make_Identifier ("Input"),
New_List (Make_Identifier ("AADLDATA"))),
Make_If_Statement (
Make_Infix_Function_Call_Expression (
Make_Predefined_Function (
K_Less_Than, false),
Make_Identifier ("Nb_Input"),
Make_Identifier ("Queue_Size")),
New_List (
Make_Assignment_Statement (
Make_Identifier ("Nb_Input"),
Make_Infix_Function_Call_Expression (
Make_IDentifier ("+"),
Make_Identifier ("Nb_Input"),
Make_Nat (1)))),
No_List,
No_List));
if (Is_Sporadic) then
BLNu.Append_Node_To_List (
Make_Assignment_Statement (
Make_Identifier ("Is_New"),
Make_Identifier ("true")),
In_Select_1);
end if;
In_Select := New_List (
Make_Select_Statement_Alternative (In_Select_1),
Make_Select_Statement_Alternative (
New_List (
Make_If_Statement (
Make_Infix_Function_Call_Expression (
Make_Predefined_Function (
K_Greater_Than, false),
Make_Identifier ("Nb_Input"),
Make_Identifier ("0")),
New_List (
Make_Communication_Statement (
Make_Identifier ("Output"),
New_List (Make_Identifier ("AADLDATA"))),
Make_Assignment_Statement (
Make_Identifier ("Nb_Input"),
Make_Infix_Function_Call_Expression (
Make_IDentifier ("-"),
Make_Identifier ("Nb_Input"),
Make_Nat (1)))),
No_List,
No_List)))
);
if (Is_Sporadic) then
Notify := Make_Select_Statement_Alternative (
New_List (
Make_If_Statement (
Make_Identifier ("Is_New"),
New_List (
Make_Communication_Statement (
Make_Identifier ("Notify"),
New_List (Make_Identifier ("Incoming_Event"))),
Make_Assignment_Statement (
Make_Identifier ("Is_New"),
Make_Identifier ("false"))),
No_List,
New_List (
Make_Communication_Statement (
Make_Identifier ("Notify"),
New_List (Make_Identifier ("No_Event"))))
)));
BLNu.Append_Node_To_List (Notify, In_Select);
end if;
L_Gates := New_List (
Make_Gate_Declaration
(Make_Identifier ("LNT_Channel_Data"),
Make_Identifier ("Input")),
Make_Gate_Declaration
(Make_Identifier ("LNT_Channel_Data"),
Make_Identifier ("Output")));
if (Is_Sporadic) then
BLNu.Append_Node_To_List (
Make_Gate_Declaration
(Make_Identifier ("LNT_Channel_Event"),
Make_Identifier ("Notify")),
L_Gates);
end if;
Put_Line ("Begin Port");
if (Is_Sporadic) then
N_Port := Make_Identifier ("Event_Port_Sporadic");
if Is_Empty (LNT_States_List) then
Set_Str_To_Name_Buffer (Get_Runtime_Path ("lnt") &
Directory_Separator &
"LNT_Generic_Process_For_Port_Connections.lnt");
Copy_File (Get_Name_String (Name_Find),
Get_Name_String (Generated_Sources_Directory), Is_Done, Overwrite);
else
N_Port := Make_Identifier ("Event_Port_Periodic");
Set_Str_To_Name_Buffer (Get_Runtime_Path ("lnt") &
Directory_Separator &
"LNT_Generic_Process_For_Port_Connections_BA.lnt");
Copy_File (Get_Name_String (Name_Find),
Get_Name_String (Generated_Sources_Directory), Is_Done, Overwrite);
end if;
N := Make_Process_Definition
(No_Node, N_Port,
L_Parameters,
L_Gates,
No_List,
No_List,
New_List (Make_Var_Loop_Select (Var_Dec, Out_Loop, In_Select)));
BLNu.Append_Node_To_List (N, L_Ports);
end Add_LNT_Event_Port;
Module_Node : Node_Id := No_Node;
Definitions_List : List_Id := No_List;
Modules_List : List_Id := No_List;
Predefined_Functions_List : List_Id := No_List;
-- Module_Pragma : List_Id := No_List;
function Generate_LNT_Port
return Node_Id is
begin
Put_Line ("Begin Port");
Module_Node := Make_Module_Definition
(New_Identifier (Get_String_Name ("_Ports"),
Get_Name_String (System_Name)));
Definitions_List := New_List;
Add_LNT_Data_Port (Definitions_List);
Add_LNT_Event_Port (Definitions_List, false);
if (Not_Periodic_Thread_Number > 0) then
Add_LNT_Event_Port (Definitions_List, true);
if not Is_Done then
Display_Error ("Problem in LNT Port_Connections module generation !",
Fatal => False,
Warning => True);
end if;
Modules_List := New_List (New_Identifier (
Get_String_Name ("_Types"),
Get_Name_String (System_Name)));
Predefined_Functions_List := New_List;
Set_Definitions (Module_Node, Definitions_List);
Set_Modules (Module_Node, Modules_List);
Set_Predefined_Functions (Module_Node, Predefined_Functions_List);
return Module_Node;
end Generate_LNT_Port;
end Ocarina.Backends.LNT.Tree_Generator_Port;
......@@ -31,6 +31,6 @@
package Ocarina.Backends.LNT.Tree_Generator_Port is
-- Additional LNT process for communication
function Generate_LNT_Port return Node_Id; -- LNT Port process
procedure Generate_LNT_Port; -- LNT Port process
end Ocarina.Backends.LNT.Tree_Generator_Port;
......@@ -123,9 +123,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Thread is
(New_Identifier (Get_String_Name ("_Threads"),
Get_Name_String (System_Name)));
Definitions_List := New_List;
Modules_List := New_List (New_Identifier (
Get_String_Name ("_Types"),
Get_Name_String (System_Name)));
Modules_List := New_List (Make_Identifier ("Types"));
Predefined_Functions_List := New_List;
Visit (N);
Set_Definitions (Module_Node, Definitions_List);
......
......@@ -29,8 +29,6 @@
-- --
------------------------------------------------------------------------------
with Ocarina.Namet; use Ocarina.Namet;
with Ocarina.Backends;
with Ocarina.Backends.LNT.Nutils;
with Ocarina.Backends.LNT.Nodes;
......@@ -362,8 +360,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Types is
begin
Put_Line ("Begin Types");
Module_Node := Make_Module_Definition
(New_Identifier (Get_String_Name ("_Types"),
Get_Name_String (System_Name)));
(Make_Identifier ("Types"));
Definitions_List := New_List;
-- Data generic type
N := Make_Type_Def
......
......@@ -103,7 +103,6 @@ package body Ocarina.Backends.LNT is
LNT_Threads := Generate_LNT_Thread (Instance_Root);
LNT_Processor := Generate_LNT_Processor (Instance_Root);
LNT_Types := Generate_LNT_Types;
LNT_Port := Generate_LNT_Port;
LNT_Main := Generate_LNT_Main (Instance_Root);
end if;
if No (LNT_Threads) then
......@@ -112,11 +111,11 @@ package body Ocarina.Backends.LNT is
Enter_Directory (Generated_Sources_Directory);
-- Print_LNT_Generated (SVL);
Make_Svl_File;
Generate_LNT_Port;
Print_LNT_Generated (LNT_Threads);
Print_LNT_Generated (LNT_Port);
Print_LNT_Generated (LNT_Types);
Print_LNT_Generated (LNT_Processor);
Print_LNT_Generated (LNT_Main);
Print_LNT_Generated (LNT_Processor);
end Generate;
----------
......
......@@ -46,8 +46,9 @@ package Ocarina.Backends.LNT is
type Thread is record
Identifier : Name_Id;
Period : Natural;
Capacity : Natural;
Period : Natural := 0;
Capacity : Natural := 0;
Event_Port_Number : Natural := 0;
Dispatch_Protocol : Properties.Supported_Thread_Dispatch_Protocol;
end record;
......@@ -55,10 +56,12 @@ package Ocarina.Backends.LNT is
type Period_Array is array (Natural range <>) of Natural;
System_Name : Name_Id;
The_Processor : Node_Id;
Thread_Number : Natural := 0;
Not_Periodic_Thread_Number : Natural := 0;
Hyperperiod : Integer := 0;
LNT_Thread_Instance_List : List_Id := No_List;
LNT_Processor_Gate_Declaration_List : List_Id := No_List;
LNT_States_List : List_Id := No_List;
private
Separator : Types.Name_Id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment