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