Commit f405b074 authored by julien.delange's avatar julien.delange

update MAST in order to generate shared resource when a port is used



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@1402 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 974a1b68
......@@ -78,6 +78,10 @@ package body Ocarina.Backends.MAST.Main is
function Map_Driver_Scheduling_Server_Name (The_Device : Node_Id)
return Name_Id;
function Map_Scheduler_Name (The_Processor : Node_Id) return Name_Id;
function Map_Port_Shared_Resource_Name (The_Port : Node_Id)
return Name_Id;
function Map_Port_Shared_Resource_Operation_Name (The_Port : Node_Id)
return Name_Id;
function Make_Driver_Wrapper (The_Device : Node_Id) return Node_Id;
function Map_Operation_Message_Transmission_Name
......@@ -119,6 +123,48 @@ package body Ocarina.Backends.MAST.Main is
return N;
end Map_Operation_Message_Transmission_Name;
-----------------------------------
-- Map_Port_Shared_Resource_Name --
-----------------------------------
function Map_Port_Shared_Resource_Name
(The_Port : Node_Id)
return Name_Id
is
Port_Name : Name_Id;
N : Name_Id;
begin
Set_Str_To_Name_Buffer ("");
Port_Name :=
(Normalize_Name (Name (Identifier (The_Port))));
Set_Str_To_Name_Buffer ("");
Get_Name_String (Port_Name);
Add_Str_To_Name_Buffer ("_shared_resource");
N := Name_Find;
return N;
end Map_Port_Shared_Resource_Name;
---------------------------------------------
-- Map_Port_Shared_Resource_Operation_Name --
---------------------------------------------
function Map_Port_Shared_Resource_Operation_Name
(The_Port : Node_Id)
return Name_Id
is
Port_Name : Name_Id;
N : Name_Id;
begin
Set_Str_To_Name_Buffer ("");
Port_Name :=
(Normalize_Name (Name (Identifier (The_Port))));
Set_Str_To_Name_Buffer ("");
Get_Name_String (Port_Name);
Add_Str_To_Name_Buffer ("_shared_resource_operation");
N := Name_Find;
return N;
end Map_Port_Shared_Resource_Operation_Name;
-----------------------------
-- Map_Port_Operation_Name --
-----------------------------
......@@ -513,7 +559,10 @@ package body Ocarina.Backends.MAST.Main is
Prio : Unsigned_Long_Long;
Exec_Time : constant Time_Array := Get_Execution_Time (E);
The_Feature : Node_Id;
Port_Operation : Node_Id;
Port_Operation : Node_Id;
Port_Shared_Resource : Node_Id;
Port_Shared_Resource_Op : Node_Id;
Port_Shared_Resource_Op_List : List_Id;
begin
Set_Str_To_Name_Buffer ("");
Get_Name_String (Normalize_Name (Name (Identifier (E))));
......@@ -656,8 +705,45 @@ package body Ocarina.Backends.MAST.Main is
Is_In (The_Feature) then
Append_Node_To_List
(Make_Defining_Identifier
(Map_Port_Operation_Name (E, The_Feature)),
(Map_Port_Shared_Resource_Operation_Name
(The_Feature)),
Operations_List);
Port_Shared_Resource := Make_Shared_Resource
(Immediate_Ceiling,
Map_Port_Shared_Resource_Name (The_Feature));
Append_Node_To_List
(Port_Shared_Resource, MTN.Declarations (MAST_File));
Port_Shared_Resource_Op_List := New_List (MTN.K_List_Id);
Append_Node_To_List
(Make_Defining_Identifier
(Map_Port_Shared_Resource_Name (The_Feature)),
Port_Shared_Resource_Op_List);
Port_Shared_Resource_Op := Make_Operation
(Map_Port_Shared_Resource_Operation_Name (The_Feature),
Simple,
No_List);
MTN.Set_Shared_Resources_List
(Port_Shared_Resource_Op,
Port_Shared_Resource_Op_List);
MTN.Set_Best_Case_Execution_Time
(Port_Shared_Resource_Op,
Make_Literal
(New_Numeric_Value
(1, 1, 10)));
MTN.Set_Worst_Case_Execution_Time
(Port_Shared_Resource_Op,
Make_Literal
(New_Numeric_Value
(10, 1, 10)));
Append_Node_To_List
(Port_Shared_Resource_Op, MTN.Declarations (MAST_File));
end if;
The_Feature := Next_Node (The_Feature);
end loop;
......@@ -691,10 +777,23 @@ package body Ocarina.Backends.MAST.Main is
while Present (The_Feature) loop
if Kind (The_Feature) = K_Port_Spec_Instance and then
Is_Out (The_Feature) then
Append_Node_To_List
(Make_Defining_Identifier
(Map_Port_Operation_Name (E, The_Feature)),
Operations_List);
declare
Dest_Ports : constant List_Id
:= Get_Destination_Ports (The_Feature);
Dest_Port : Node_Id;
begin
if not AINU.Is_Empty (Dest_Ports) then
Dest_Port := AIN.First_Node (Dest_Ports);
while Present (Dest_Port) loop
Append_Node_To_List
(Make_Defining_Identifier
(Map_Port_Shared_Resource_Operation_Name
(Item (Dest_Port))),
Operations_List);
Dest_Port := AIN.Next_Node (Dest_Port);
end loop;
end if;
end;
end if;
The_Feature := Next_Node (The_Feature);
end loop;
......
......@@ -834,6 +834,7 @@ package body Ocarina.Backends.MAST_Tree.Generator is
Write_Name (Node_Name (N));
Write (Tok_Right_Paren);
Write (Tok_Semicolon);
Write_Eol;
end Generate_Shared_Resource;
------------------------
......@@ -842,6 +843,7 @@ package body Ocarina.Backends.MAST_Tree.Generator is
procedure Generate_Operation (N : Node_Id) is
Op : Node_Id;
Sr : Node_Id;
begin
Write_Line ("Operation (");
Increment_Indentation;
......@@ -948,6 +950,29 @@ package body Ocarina.Backends.MAST_Tree.Generator is
Write (Tok_Right_Paren);
end if;
if not Is_Empty (Shared_Resources_List (N)) then
Write (Tok_Colon);
Write_Eol;
Write_Indentation (-1);
Write (Tok_Shared_Resources_List);
Write_Space;
Write (Tok_Assign);
Write_Space;
Write (Tok_Left_Paren);
Sr := First_Node (Shared_Resources_List (N));
while Present (Sr) loop
Generate (Sr);
if Next_Node (Sr) /= No_Node then
Write (Tok_Colon);
end if;
Sr := Next_Node (Sr);
end loop;
Write (Tok_Right_Paren);
end if;
Write_Line (");");
Decrement_Indentation;
Write_Eol;
......
......@@ -107,6 +107,7 @@ module Ocarina::Backends::MAST_Tree::Nodes {
boolean Is_Message_Transmission;
boolean Is_Composite;
List_Id Operations;
List_Id Shared_Resources_List;
Node_Id Worst_Case_Execution_Time;
Node_Id Best_Case_Execution_Time;
Node_Id Avg_Case_Execution_Time;
......
......@@ -708,6 +708,8 @@ package body Ocarina.Backends.MAST_Tree.Nutils is
MTN.Set_Operations (N, Op_List);
end if;
MTN.Set_Shared_Resources_List (N, No_List);
MTN.Set_Is_Enclosing (N, False);
MTN.Set_Is_Composite (N, False);
MTN.Set_Is_Simple (N, False);
......
......@@ -106,6 +106,7 @@ package Ocarina.Backends.MAST_Tree.Nutils is
Tok_Scheduling_Server,
Tok_Server_Processing_Resource,
Tok_Server_Sched_Parameters,
Tok_Shared_Resources_List,
Tok_Simplex,
Tok_Speed_Factor,
Tok_Shared_Resource,
......
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