Commit 0997dedb authored by julien.delange's avatar julien.delange

map subprograms

map thread timing requirements



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@1355 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 097e3ee6
......@@ -39,6 +39,7 @@ with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Backends.MAST_Tree.Nodes;
with Ocarina.Backends.MAST_Tree.Nutils;
with Ocarina.Backends.MAST_Values;
with Ocarina.Backends.Properties;
with Ocarina.Backends.Utils;
......@@ -50,7 +51,9 @@ package body Ocarina.Backends.MAST.Main is
use Ocarina.Backends.MAST_Tree.Nutils;
use Ocarina.Backends.Utils;
use Ocarina.Backends.Properties;
use Ocarina.Backends.MAST_Values;
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package MTN renames Ocarina.Backends.MAST_Tree.Nodes;
package MTU renames Ocarina.Backends.MAST_Tree.Nutils;
......@@ -60,6 +63,7 @@ package body Ocarina.Backends.MAST.Main is
procedure Visit_Processor (E : Node_Id);
procedure Visit_Process (E : Node_Id);
procedure Visit_Thread (E : Node_Id);
procedure Visit_Subprogram (E : Node_Id);
procedure Visit_Bus (E : Node_Id);
procedure Visit_Virtual_Processor (E : Node_Id);
......@@ -99,6 +103,9 @@ package body Ocarina.Backends.MAST.Main is
when CC_Processor =>
Visit_Processor (E);
when CC_Subprogram =>
Visit_Subprogram (E);
when CC_Process =>
Visit_Process (E);
......@@ -188,6 +195,9 @@ package body Ocarina.Backends.MAST.Main is
procedure Visit_Thread (E : Node_Id) is
S : Node_Id;
N : Node_Id;
Call : Node_Id;
Spg_Call : Node_Id;
Spg : Node_Id;
Activation_Event : Node_Id;
Activation_Kind : Event_Kind := Regular;
Activation_Event_Name : Name_Id;
......@@ -197,6 +207,9 @@ package body Ocarina.Backends.MAST.Main is
Server_Sched_Name : Name_Id;
Operation_Name : Name_Id;
Operation : Node_Id;
Operations_List : constant List_Id
:= MTU.New_List (MTN.K_List_Id);
Output_Event_Req : Node_Id := No_Node;
begin
Set_Str_To_Name_Buffer ("");
Get_Name_String (Normalize_Name (Name (Identifier (E))));
......@@ -225,6 +238,12 @@ package body Ocarina.Backends.MAST.Main is
if Get_Thread_Dispatch_Protocol (E) = Thread_Periodic then
Activation_Kind := Periodic;
Output_Event_Req
:= Make_Event_Timing_Requirement
(Hard_Deadline,
To_Milliseconds (Get_Thread_Deadline (E)),
Activation_Event_Name);
elsif Get_Thread_Dispatch_Protocol (E) = Thread_Sporadic then
Activation_Kind := Sporadic;
else
......@@ -233,6 +252,16 @@ package body Ocarina.Backends.MAST.Main is
Activation_Event := Make_Event (Activation_Event_Name, Activation_Kind);
if Get_Thread_Dispatch_Protocol (E) = Thread_Periodic then
MTN.Set_Period
(Activation_Event,
Make_Literal
(New_Numeric_Value
(To_Milliseconds (Get_Thread_Period (E)), 1, 10)));
else
MTN.Set_Period (Activation_Event, No_Node);
end if;
Append_Node_To_List
(Activation_Event, MTN.External_Events (N));
......@@ -243,6 +272,8 @@ package body Ocarina.Backends.MAST.Main is
Output_Event := Make_Event (Output_Event_Name, Regular);
MTN.Set_Timing_Requirements (Output_Event, Output_Event_Req);
Append_Node_To_List
(Output_Event, MTN.Internal_Events (N));
......@@ -257,8 +288,32 @@ package body Ocarina.Backends.MAST.Main is
(Event_Handler, MTN.Event_Handlers (N));
Operation := Make_Operation (Operation_Name, Enclosing);
MTN.Set_Operations (Operation, Operations_List);
Append_Node_To_List (Operation, MTN.Declarations (MAST_File));
if not AINU.Is_Empty (Calls (E)) then
Call := AIN.First_Node (Calls (E));
while Present (Call) loop
if not AINU.Is_Empty (Subprogram_Calls (Call)) then
Spg_Call := AIN.First_Node
(AIN.Subprogram_Calls (Call));
while Present (Spg_Call) loop
Spg := AIN.Corresponding_Instance (Spg_Call);
Append_Node_To_List
(Make_Defining_Identifier
(Name (Identifier (Spg))),
Operations_List);
Visit (Spg);
Spg_Call := AIN.Next_Node (Spg_Call);
end loop;
end if;
Call := AIN.Next_Node (Call);
end loop;
end if;
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
......@@ -271,6 +326,23 @@ package body Ocarina.Backends.MAST.Main is
end if;
end Visit_Thread;
----------------------
-- Visit_Subprogram --
----------------------
procedure Visit_Subprogram (E : Node_Id) is
Operation : Node_Id;
Operation_Name : Name_Id;
Operations_List : constant List_Id
:= MTU.New_List (MTN.K_List_Id);
begin
Operation_Name := Name (Identifier (E));
Operation := Make_Operation (Operation_Name, Simple);
MTN.Set_Operations (Operation, Operations_List);
Append_Node_To_List (Operation, MTN.Declarations (MAST_File));
end Visit_Subprogram;
------------------
-- Visit_System --
------------------
......
......@@ -62,6 +62,7 @@ package body Ocarina.Backends.MAST_Tree.Generator is
procedure Generate_Event (N : Node_Id);
procedure Generate_Event_Handler (N : Node_Id);
procedure Generate_Operation (N : Node_Id);
procedure Generate_Event_Timing_Requirements (N : Node_Id);
procedure Write (T : Token_Type);
procedure Write_Line (T : Token_Type);
......@@ -178,6 +179,9 @@ package body Ocarina.Backends.MAST_Tree.Generator is
when K_Operation =>
Generate_Operation (N);
when K_Event_Timing_Requirements =>
Generate_Event_Timing_Requirements (N);
when others =>
Display_Error ("other element in generator", Fatal => False);
null;
......@@ -468,14 +472,29 @@ package body Ocarina.Backends.MAST_Tree.Generator is
end if;
Write_Line (Tok_Colon);
if MTN.Period (N) /= No_Node then
Write_Indentation (-1);
Write (Tok_Period);
Write_Space;
Write (Tok_Assign);
Write_Space;
Generate (Period (N));
Write_Line (Tok_Colon);
end if;
if Timing_Requirements (N) /= No_Node then
Write_Indentation (-1);
Write (Tok_Timing_Requirements);
Write_Space;
Write (Tok_Assign);
Write_Space;
Write_Eol;
Increment_Indentation;
Write_Indentation (-1);
Write (Tok_Left_Paren);
Generate (Timing_Requirements (N));
Write (Tok_Right_Paren);
Write_Line (Tok_Colon);
Decrement_Indentation;
end if;
Write_Indentation (-1);
......@@ -487,6 +506,41 @@ package body Ocarina.Backends.MAST_Tree.Generator is
Write (Tok_Right_Paren);
end Generate_Event;
----------------------------------------
-- Generate_Event_Timing_Requirements --
----------------------------------------
procedure Generate_Event_Timing_Requirements (N : Node_Id) is
begin
Write (Tok_Type);
Write_Space;
Write (Tok_Assign);
Write_Space;
if Is_Hard_Deadline (N) then
Write (Tok_Hard_Global_Deadline);
else
Write_Str ("unknown");
end if;
Write (Tok_Colon);
Write_Eol;
Write_Indentation (-1);
Write (Tok_Deadline);
Write_Space;
Write (Tok_Assign);
Write_Space;
Generate (Deadline (N));
Write (Tok_Colon);
Write_Eol;
Write_Indentation (-1);
Write (Tok_Referenced_Event);
Write_Space;
Write (Tok_Assign);
Write_Space;
Write_Name (Referenced_Event (N));
end Generate_Event_Timing_Requirements;
----------------------------
-- Generate_Event_Handler --
----------------------------
......@@ -543,6 +597,7 @@ package body Ocarina.Backends.MAST_Tree.Generator is
------------------------
procedure Generate_Operation (N : Node_Id) is
Op : Node_Id;
begin
Write_Line ("Operation (");
Increment_Indentation;
......@@ -592,6 +647,28 @@ package body Ocarina.Backends.MAST_Tree.Generator is
Write_Line (Tok_Colon);
end if;
if not Is_Empty (Operations (N)) then
Write_Indentation (-1);
Write (Tok_Composite_Operation_List);
Write_Space;
Write (Tok_Assign);
Write_Space;
Write (Tok_Left_Paren);
Op := First_Node (Operations (N));
while Present (Op) loop
Generate (Op);
if Next_Node (Op) /= No_Node then
Write (Tok_Colon);
end if;
Op := Next_Node (Op);
end loop;
Write (Tok_Right_Paren);
Write (Tok_Colon);
Write_Eol;
end if;
Write_Indentation (-1);
Write_Str ("Name => ");
Write_Name (Node_Name (N));
......
......@@ -98,6 +98,7 @@ module Ocarina::Backends::MAST_Tree::Nodes {
boolean Is_Periodic;
Node_Id Timing_Requirements;
Node_Id Min_Interarrival;
Node_Id Period;
};
interface Event_Timing_Requirements : Node_Id {
......
......@@ -36,11 +36,13 @@ with GNAT.Table;
with Charset; use Charset;
with Locations; use Locations;
with Namet; use Namet;
with Ocarina.Backends.MAST_Values;
-- with Utils; use Utils;
-- with Ocarina.Backends.Utils;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
use Ocarina.ME_AADL.AADL_Tree.Nodes;
use Ocarina.Backends.MAST_Values;
-- use Ocarina.Backends.Utils;
package body Ocarina.Backends.MAST_Tree.Nutils is
......@@ -675,4 +677,29 @@ package body Ocarina.Backends.MAST_Tree.Nutils is
return N;
end Make_Operation;
-----------------------------------
-- Make_Event_Timing_Requirement --
-----------------------------------
function Make_Event_Timing_Requirement
(Req_Kind : Event_Timing_Requirement_Kind;
Deadline : Unsigned_Long_Long;
Ref_Event : Name_Id)
return Node_Id is
N : Node_Id;
begin
N := New_Node (MTN.K_Event_Timing_Requirements);
if Req_Kind = Hard_Deadline then
MTN.Set_Is_Hard_Deadline (N, True);
end if;
MTN.Set_Deadline
(N, Make_Literal
(New_Numeric_Value (Deadline, 1, 10)));
MTN.Set_Referenced_Event (N, Ref_Event);
return N;
end Make_Event_Timing_Requirement;
end Ocarina.Backends.MAST_Tree.Nutils;
......@@ -58,8 +58,11 @@ package Ocarina.Backends.MAST_Tree.Nutils is
Tok_Best_Case_Execution_time,
Tok_Best_Context_Switch,
Tok_Best_ISR_Switch,
Tok_Composite_Operation_List,
Tok_Deadline,
Tok_Event_Handlers,
Tok_External_Events,
Tok_Hard_Global_Deadline,
Tok_Host,
Tok_Internal_Events,
Tok_Input_Event,
......@@ -76,8 +79,10 @@ package Ocarina.Backends.MAST_Tree.Nutils is
Tok_Packet_Send_Operation,
Tok_Packet_Receive_Operation,
Tok_Parameters,
Tok_Period,
Tok_Processing_Resource,
Tok_RTA_Overhead_Model,
Tok_Referenced_Event,
Tok_Scheduler,
Tok_Scheduling_Server,
Tok_Server_Processing_Resource,
......@@ -231,4 +236,13 @@ package Ocarina.Backends.MAST_Tree.Nutils is
Op_List : List_Id := No_List)
return Node_Id;
type Event_Timing_Requirement_Kind is
(Hard_Deadline);
function Make_Event_Timing_Requirement
(Req_Kind : Event_Timing_Requirement_Kind;
Deadline : Unsigned_Long_Long;
Ref_Event : Name_Id)
return Node_Id;
end Ocarina.Backends.MAST_Tree.Nutils;
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