Commit 23c99ceb authored by hana's avatar hana

Update of LNT processor generation.

parent f4386e25
...@@ -756,7 +756,7 @@ package body Ocarina.Backends.Lnt.Components is ...@@ -756,7 +756,7 @@ package body Ocarina.Backends.Lnt.Components is
(Defining_Identifier : Node_Id; (Defining_Identifier : Node_Id;
Actual_Gates : List_Id := No_List; Actual_Gates : List_Id := No_List;
Actual_Parameters : List_Id := No_List; Actual_Parameters : List_Id := No_List;
Is_Sporadic : boolean := false) Is_Not_Periodic : Boolean := false)
return Node_Id return Node_Id
is is
pragma Assert (Defining_Identifier /= No_Node); pragma Assert (Defining_Identifier /= No_Node);
...@@ -766,7 +766,7 @@ package body Ocarina.Backends.Lnt.Components is ...@@ -766,7 +766,7 @@ package body Ocarina.Backends.Lnt.Components is
Set_Identifier (N, Defining_Identifier); Set_Identifier (N, Defining_Identifier);
Set_Actual_Gates (N, Actual_Gates); Set_Actual_Gates (N, Actual_Gates);
Set_Actual_Parameters (N, Actual_Parameters); Set_Actual_Parameters (N, Actual_Parameters);
Set_Is_Sporadic (N, Is_Sporadic); Set_Is_Not_Periodic (N, Is_Not_Periodic);
return N; return N;
end Make_Process_Instantiation_Statement; end Make_Process_Instantiation_Statement;
...@@ -899,17 +899,21 @@ package body Ocarina.Backends.Lnt.Components is ...@@ -899,17 +899,21 @@ package body Ocarina.Backends.Lnt.Components is
--------------------------- ---------------------------
function Make_Var_Loop_Select (Var_Dec : List_Id; function Make_Var_Loop_Select (Var_Dec : List_Id;
Out_Loop : List_Id; Out_Loop : List_Id;
In_Select : List_Id) In_Select : List_Id;
With_Select : Boolean := true)
return Node_Id is return Node_Id is
N : Node_Id; N : Node_Id;
N_Loop : Node_Id; N_Loop : Node_Id;
L_Var : List_Id; L_Var : List_Id;
begin begin
L_Var := Out_Loop; L_Var := Out_Loop;
if With_Select then
N_Loop := Make_Loop_Statement N_Loop := Make_Loop_Statement
(New_List (Make_Select_Statement (In_Select))); (New_List (Make_Select_Statement (In_Select)));
else
N_Loop := Make_Loop_Statement (In_Select);
end if;
Append_Node_To_List (N_Loop, L_Var); Append_Node_To_List (N_Loop, L_Var);
N := Make_Var_Statement (Var_Dec, L_Var); N := Make_Var_Statement (Var_Dec, L_Var);
return N; return N;
end Make_Var_Loop_Select; end Make_Var_Loop_Select;
......
...@@ -244,7 +244,7 @@ package Ocarina.Backends.Lnt.Components is ...@@ -244,7 +244,7 @@ package Ocarina.Backends.Lnt.Components is
(Defining_Identifier : Node_Id; (Defining_Identifier : Node_Id;
Actual_Gates : List_Id := No_List; Actual_Gates : List_Id := No_List;
Actual_Parameters : List_Id := No_List; Actual_Parameters : List_Id := No_List;
Is_Sporadic : boolean := false) Is_Not_Periodic : Boolean := false)
return Node_Id; return Node_Id;
function Make_Communication_Statement function Make_Communication_Statement
...@@ -290,6 +290,7 @@ package Ocarina.Backends.Lnt.Components is ...@@ -290,6 +290,7 @@ package Ocarina.Backends.Lnt.Components is
function Make_Var_Loop_Select (Var_Dec : List_Id; function Make_Var_Loop_Select (Var_Dec : List_Id;
Out_Loop : List_Id; Out_Loop : List_Id;
In_Select : List_Id) In_Select : List_Id;
With_Select : Boolean := true)
return Node_Id; return Node_Id;
end Ocarina.Backends.Lnt.Components; end Ocarina.Backends.Lnt.Components;
...@@ -50,7 +50,7 @@ package body Ocarina.Backends.LNT.Tree_Generator is ...@@ -50,7 +50,7 @@ package body Ocarina.Backends.LNT.Tree_Generator is
procedure Get_N_Thread (Sys : Node_Id; procedure Get_N_Thread (Sys : Node_Id;
Thread_Number : in out Natural; Thread_Number : in out Natural;
Sporadic_Thread_Number : in out Natural) is Not_Periodic_Thread_Number : in out Natural) is
Sys_N : Node_Id; Sys_N : Node_Id;
Proc : Node_Id; Proc : Node_Id;
Proc_N : Node_Id; Proc_N : Node_Id;
...@@ -64,7 +64,7 @@ package body Ocarina.Backends.LNT.Tree_Generator is ...@@ -64,7 +64,7 @@ package body Ocarina.Backends.LNT.Tree_Generator is
if Get_Category_Of_Component (Proc) = CC_System then if Get_Category_Of_Component (Proc) = CC_System then
Get_N_Thread (Proc, Get_N_Thread (Proc,
Thread_Number, Thread_Number,
Sporadic_Thread_Number); Not_Periodic_Thread_Number);
end if; end if;
if Get_Category_Of_Component (Proc) = CC_Process then if Get_Category_Of_Component (Proc) = CC_Process then
if not AINU.Is_Empty (Subcomponents (Proc)) then if not AINU.Is_Empty (Subcomponents (Proc)) then
...@@ -73,11 +73,11 @@ package body Ocarina.Backends.LNT.Tree_Generator is ...@@ -73,11 +73,11 @@ package body Ocarina.Backends.LNT.Tree_Generator is
Thr := Corresponding_Instance (Proc_N); Thr := Corresponding_Instance (Proc_N);
if Get_Category_Of_Component (Thr) = CC_Thread then if Get_Category_Of_Component (Thr) = CC_Thread then
Thread_Number := Thread_Number + 1; Thread_Number := Thread_Number + 1;
if (Get_Thread_Dispatch_Protocol (Thr) = if (Get_Thread_Dispatch_Protocol (Thr)
Thread_Sporadic) /= Thread_Periodic)
then then
Sporadic_Thread_Number := Not_Periodic_Thread_Number :=
Sporadic_Thread_Number + 1; Not_Periodic_Thread_Number + 1;
end if; end if;
end if; end if;
Proc_N := AIN.Next_Node (Proc_N); Proc_N := AIN.Next_Node (Proc_N);
......
...@@ -33,6 +33,6 @@ package Ocarina.Backends.LNT.Tree_Generator is ...@@ -33,6 +33,6 @@ package Ocarina.Backends.LNT.Tree_Generator is
procedure Get_N_Thread (Sys : Node_Id; procedure Get_N_Thread (Sys : Node_Id;
Thread_Number : in out Natural; Thread_Number : in out Natural;
Sporadic_Thread_Number : in out Natural); Not_Periodic_Thread_Number : in out Natural);
end Ocarina.Backends.LNT.Tree_Generator; end Ocarina.Backends.LNT.Tree_Generator;
...@@ -78,8 +78,8 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -78,8 +78,8 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
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_Sporadic : out boolean); Is_Not_Periodic : out boolean);
function Is_Sporadic (Index : Natural; Target : List_Id) function Is_Not_Periodic (Index : Natural; Target : List_Id)
return boolean; return boolean;
procedure Make_Process_Main; procedure Make_Process_Main;
...@@ -114,7 +114,6 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -114,7 +114,6 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
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)); N_Connection := AIN.Item (AIN.First_Node (L));
while (AIN.Is_In (N_Connection)) loop while (AIN.Is_In (N_Connection)) loop
L := Sources (N_Connection); L := Sources (N_Connection);
N_Connection := AIN.Item (AIN.First_Node (L)); N_Connection := AIN.Item (AIN.First_Node (L));
...@@ -155,6 +154,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -155,6 +154,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
Connection); Connection);
end if; end if;
-- Put_Line (Image (Connection));
return Connection; return Connection;
end Make_Gate_Identifier; end Make_Gate_Identifier;
...@@ -272,7 +272,13 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -272,7 +272,13 @@ 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;
---------------------------- ----------------------------
...@@ -457,7 +463,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -457,7 +463,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
Aux_N_Port_4 : Node_Id; Aux_N_Port_4 : Node_Id;
N_Send : Name_Id; N_Send : Name_Id;
Connection : Name_Id; Connection : Name_Id;
Is_Sporadic : boolean := false; Is_Not_Periodic : boolean := false;
Thread_Identifier : constant Name_Id Thread_Identifier : constant Name_Id
:= New_Identifier (AIN.Display_Name := New_Identifier (AIN.Display_Name
(AIN.Identifier (E)), "Thread_"); (AIN.Identifier (E)), "Thread_");
...@@ -468,7 +474,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -468,7 +474,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
LNT_Thread_Instance_List, LNT_Thread_Instance_List,
Thread_Instance, Thread_Instance,
Index, Index,
Is_Sporadic); Is_Not_Periodic);
N_Activation := New_Identifier ( N_Activation := New_Identifier (
Remove_Prefix_From_Name ( Remove_Prefix_From_Name (
...@@ -484,7 +490,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -484,7 +490,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
Make_Gate_Declaration ( Make_Gate_Declaration (
Make_Identifier ("LNT_Channel_Dispatch"), Make_Identifier ("LNT_Channel_Dispatch"),
Aux_N_Activation_2)); Aux_N_Activation_2));
if Is_Sporadic then if Is_Not_Periodic then
N_Event := New_Identifier ( N_Event := New_Identifier (
Remove_Prefix_From_Name ( Remove_Prefix_From_Name (
" ", Get_String_Name (Integer'Image (Index))), " ", Get_String_Name (Integer'Image (Index))),
...@@ -551,7 +557,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -551,7 +557,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
No_List); No_List);
elsif AIN.Is_Event (S) then elsif AIN.Is_Event (S) then
-- event port -- event port
if Is_Sporadic then if Is_Not_Periodic then
Aux_N_Event := BLNu.Make_Node_Container (N_Event); Aux_N_Event := BLNu.Make_Node_Container (N_Event);
Port_Gates_List := New_List ( Port_Gates_List := New_List (
Make_Identifier (N_SEND), -- SEND_ Make_Identifier (N_SEND), -- SEND_
...@@ -635,7 +641,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -635,7 +641,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
" ", Get_String_Name (Integer'Image (I))), " ", Get_String_Name (Integer'Image (I))),
"ACTIVATION_"); "ACTIVATION_");
BLNu.Append_Node_To_List (N_Activation, Processor_Gates_List); BLNu.Append_Node_To_List (N_Activation, Processor_Gates_List);
if (Is_Sporadic (I, LNT_Thread_Instance_List)) then if (Is_Not_Periodic (I, LNT_Thread_Instance_List)) then
N_Activation := New_Identifier ( N_Activation := New_Identifier (
Remove_Prefix_From_Name ( Remove_Prefix_From_Name (
" ", Get_String_Name (Integer'Image (I))), " ", Get_String_Name (Integer'Image (I))),
...@@ -668,7 +674,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -668,7 +674,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
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; Instance : out Node_Id;
Index : out Natural; Index : out Natural;
Is_Sporadic : out boolean) Is_Not_Periodic : out boolean)
is is
N : Node_Id; N : Node_Id;
Counter : Natural := 1; Counter : Natural := 1;
...@@ -682,7 +688,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -682,7 +688,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
if ((BLN.Name (BLN.Identifier (N)) = Key and then if ((BLN.Name (BLN.Identifier (N)) = Key and then
BLNu.Is_Empty (Actual_Gates (N)))) BLNu.Is_Empty (Actual_Gates (N))))
then then
Is_Sporadic := BLN.Is_Sporadic (N); Is_Not_Periodic := BLN.Is_Not_Periodic (N);
Instance := N; Instance := N;
Index := Counter; Index := Counter;
exit; exit;
...@@ -693,7 +699,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -693,7 +699,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
end if; end if;
end Find_Instance_By_Name; end Find_Instance_By_Name;
function Is_Sporadic (Index : Natural; Target : List_Id) function Is_Not_Periodic (Index : Natural; Target : List_Id)
return boolean is return boolean is
N : Node_Id; N : Node_Id;
Counter : Natural := 1; Counter : Natural := 1;
...@@ -705,13 +711,13 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is ...@@ -705,13 +711,13 @@ package body Ocarina.Backends.LNT.Tree_Generator_Main is
while Present (N) loop while Present (N) loop
if (Counter = Index) then if (Counter = Index) then
return BLN.Is_Sporadic (N); return BLN.Is_Not_Periodic (N);
end if; end if;
N := BLN.Next_Node (N); N := BLN.Next_Node (N);
Counter := Counter + 1; Counter := Counter + 1;
end loop; end loop;
end if; end if;
return false; return false;
end Is_Sporadic; end Is_Not_Periodic;
end Ocarina.Backends.LNT.Tree_Generator_Main; end Ocarina.Backends.LNT.Tree_Generator_Main;
...@@ -271,7 +271,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Port is ...@@ -271,7 +271,7 @@ package body Ocarina.Backends.LNT.Tree_Generator_Port is
Definitions_List := New_List; Definitions_List := New_List;
Add_LNT_Data_Port (Definitions_List); Add_LNT_Data_Port (Definitions_List);
Add_LNT_Event_Port (Definitions_List, false); Add_LNT_Event_Port (Definitions_List, false);
if (Sporadic_Thread_Number > 0) then if (Not_Periodic_Thread_Number > 0) then
Add_LNT_Event_Port (Definitions_List, true); Add_LNT_Event_Port (Definitions_List, true);
end if; end if;
......
...@@ -98,7 +98,7 @@ package body Ocarina.Backends.LNT is ...@@ -98,7 +98,7 @@ package body Ocarina.Backends.LNT is
Get_N_Thread (Root_System (Instance_Root), Get_N_Thread (Root_System (Instance_Root),
Thread_Number, Thread_Number,
Sporadic_Thread_Number); Not_Periodic_Thread_Number);
LNT_Thread_Instance_List := New_List; LNT_Thread_Instance_List := New_List;
LNT_Threads := Generate_LNT_Thread (Instance_Root); LNT_Threads := Generate_LNT_Thread (Instance_Root);
LNT_Processor := Generate_LNT_Processor (Instance_Root); LNT_Processor := Generate_LNT_Processor (Instance_Root);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
-- This package generates a pn tree -- This package generates a pn tree
with Ocarina.Types; with Ocarina.Types;
with Ocarina.Backends.Properties;
package Ocarina.Backends.LNT is package Ocarina.Backends.LNT is
...@@ -47,7 +48,7 @@ package Ocarina.Backends.LNT is ...@@ -47,7 +48,7 @@ package Ocarina.Backends.LNT is
Identifier : Name_Id; Identifier : Name_Id;
Period : Natural; Period : Natural;
Capacity : Natural; Capacity : Natural;
Is_Sporadic : boolean := false; Dispatch_Protocol : Properties.Supported_Thread_Dispatch_Protocol;
end record; end record;
type Thread_Array is array (Natural range <>) of Thread; type Thread_Array is array (Natural range <>) of Thread;
...@@ -55,7 +56,7 @@ package Ocarina.Backends.LNT is ...@@ -55,7 +56,7 @@ package Ocarina.Backends.LNT is
System_Name : Name_Id; System_Name : Name_Id;
Thread_Number : Natural := 0; Thread_Number : Natural := 0;
Sporadic_Thread_Number : Natural := 0; Not_Periodic_Thread_Number : Natural := 0;
Hyperperiod : Integer := 0; Hyperperiod : Integer := 0;
LNT_Thread_Instance_List : List_Id := No_List; LNT_Thread_Instance_List : List_Id := No_List;
......
...@@ -550,7 +550,7 @@ module Ocarina::Backends::LNT::Nodes { ...@@ -550,7 +550,7 @@ module Ocarina::Backends::LNT::Nodes {
Node_Id Identifier; Node_Id Identifier;
List_Id Actual_Gates;// G0, ... ,Gn List_Id Actual_Gates;// G0, ... ,Gn
List_Id Actual_Parameters; // list of actual parameters List_Id Actual_Parameters; // list of actual parameters
boolean Is_Sporadic; boolean Is_Not_Periodic;
}; };
interface Communication_Statement : Node_Id { interface Communication_Statement : Node_Id {
......
...@@ -1569,6 +1569,12 @@ package body Ocarina.Backends.Properties is ...@@ -1569,6 +1569,12 @@ package body Ocarina.Backends.Properties is
return Thread_Hybrid; return Thread_Hybrid;
elsif P_Name = Thread_Timed_Name then elsif P_Name = Thread_Timed_Name then
if not Is_Defined_Integer_Property (T, Thread_Period) then
Display_Located_Error
(AIN.Loc (T),
"Timed threads must have a period",
Fatal => True);
end if;
return Thread_Timed; return Thread_Timed;
elsif P_Name = Thread_Background_Name then elsif P_Name = Thread_Background_Name then
...@@ -1723,7 +1729,8 @@ package body Ocarina.Backends.Properties is ...@@ -1723,7 +1729,8 @@ package body Ocarina.Backends.Properties is
pragma Assert (Is_Thread (T)); pragma Assert (Is_Thread (T));
case Get_Thread_Dispatch_Protocol (T) is case Get_Thread_Dispatch_Protocol (T) is
when Thread_Periodic | Thread_Sporadic | Thread_Hybrid | Thread_ISR => when Thread_Periodic | Thread_Sporadic | Thread_Hybrid |
Thread_Timed | Thread_ISR =>
-- We are sure the thread has a period -- We are sure the thread has a period
The_Period := Get_Time_Property_Value (T, Thread_Period); The_Period := Get_Time_Property_Value (T, Thread_Period);
......
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