Commit 093d03aa authored by julien.delange's avatar julien.delange
Browse files

begin to map thread for MAST


git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@1350 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 42146292
......@@ -31,14 +31,14 @@
-- --
------------------------------------------------------------------------------
with Namet; use Namet;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
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.Properties;
with Ocarina.Backends.Properties;
with Ocarina.Backends.Utils;
package body Ocarina.Backends.MAST.Main is
......@@ -46,7 +46,8 @@ package body Ocarina.Backends.MAST.Main is
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.Backends.MAST_Tree.Nutils;
-- use Ocarina.Backends.Properties;
use Ocarina.Backends.Utils;
use Ocarina.Backends.Properties;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package MTN renames Ocarina.Backends.MAST_Tree.Nodes;
......@@ -55,6 +56,8 @@ package body Ocarina.Backends.MAST.Main is
procedure Visit_Component (E : Node_Id);
procedure Visit_System (E : Node_Id);
procedure Visit_Processor (E : Node_Id);
procedure Visit_Process (E : Node_Id);
procedure Visit_Thread (E : Node_Id);
procedure Visit_Bus (E : Node_Id);
procedure Visit_Virtual_Processor (E : Node_Id);
......@@ -94,6 +97,12 @@ package body Ocarina.Backends.MAST.Main is
when CC_Processor =>
Visit_Processor (E);
when CC_Process =>
Visit_Process (E);
when CC_Thread =>
Visit_Thread (E);
when CC_Bus =>
Visit_Bus (E);
......@@ -134,7 +143,8 @@ package body Ocarina.Backends.MAST.Main is
N : Node_Id;
begin
N := MTU.Make_Processing_Resource
(Get_String_Name ("test"), Get_String_Name ("test"));
(Normalize_Name (Name (Identifier (E))),
PR_Regular_Processor);
MTU.Append_Node_To_List (N, MTN.Declarations (MAST_File));
......@@ -150,6 +160,51 @@ package body Ocarina.Backends.MAST.Main is
end if;
end Visit_Processor;
-------------------
-- Visit_Process --
-------------------
procedure Visit_Process (E : Node_Id) is
S : Node_Id;
begin
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
end Visit_Process;
------------------
-- Visit_Thread --
------------------
procedure Visit_Thread (E : Node_Id) is
S : Node_Id;
N : Node_Id;
begin
N := Make_Scheduling_Server
(Normalize_Name (Name (Identifier (E))),
Normalize_Name (Name (Identifier (Get_Bound_Processor
(Parent_Component (Parent_Subcomponent (E)))))));
Append_Node_To_List (N, MTN.Declarations (MAST_File));
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
end Visit_Thread;
------------------
-- Visit_System --
------------------
......
......@@ -51,10 +51,13 @@ package body Ocarina.Backends.MAST_Tree.Generator is
use Ocarina.Backends.MAST_Values;
use Ocarina.Backends.Messages;
package MTN renames Ocarina.Backends.MAST_Tree.Nodes;
procedure Generate_Defining_Identifier (N : Node_Id);
procedure Generate_Literal (N : Node_Id);
procedure Generate_MAST_File (N : Node_Id);
procedure Generate_Processing_Resource (N : Node_Id);
procedure Generate_Scheduling_Server (N : Node_Id);
procedure Write (T : Token_Type);
procedure Write_Line (T : Token_Type);
......@@ -156,6 +159,9 @@ package body Ocarina.Backends.MAST_Tree.Generator is
when K_Processing_Resource =>
Generate_Processing_Resource (N);
when K_Scheduling_Server =>
Generate_Scheduling_Server (N);
when others =>
Display_Error ("other element in generator", Fatal => False);
null;
......@@ -211,7 +217,6 @@ package body Ocarina.Backends.MAST_Tree.Generator is
return;
end if;
Fd := Set_Output (N);
Write_Line (Tok_Semicolon);
if not Is_Empty (Declarations (N)) then
F := First_Node (Declarations (N));
while Present (F) loop
......@@ -233,17 +238,97 @@ package body Ocarina.Backends.MAST_Tree.Generator is
Increment_Indentation;
Write_Indentation (-1);
Write_Str ("Type =>");
Write_Name (Node_Type (N));
Write_Line (",");
if Regular_Processor (N) then
Write_Line ("Type => Regular_Processor,");
else
Write_Line ("Type => Packet_Based_Network,");
end if;
Write_Indentation (-1);
Write_Str ("Name =>");
Write_Str ("Name => ");
Write_Name (Node_Name (N));
Write_Line (Tok_Colon);
Write_Indentation (-1);
Write (Tok_Avg_ISR_Switch);
Write_Space;
Write (Tok_Assign);
if Avg_ISR_Switch (N) /= No_Node then
Generate (Avg_ISR_Switch (N));
else
Write_Str ("0.00");
end if;
Write_Line (Tok_Colon);
Write_Indentation (-1);
Write (Tok_Best_ISR_Switch);
Write_Space;
Write (Tok_Assign);
if Best_ISR_Switch (N) /= No_Node then
Generate (Best_ISR_Switch (N));
else
Write_Str ("0.00");
end if;
Write_Line (Tok_Colon);
Write_Indentation (-1);
Write (Tok_Worst_ISR_Switch);
Write_Space;
Write (Tok_Assign);
if Worst_ISR_Switch (N) /= No_Node then
Generate (Worst_ISR_Switch (N));
else
Write_Str ("0.00");
end if;
Write_Line (Tok_Colon);
Decrement_Indentation;
Write_Indentation (-1);
Write_Line (");");
end Generate_Processing_Resource;
--------------------------------
-- Generate_Scheduling_Server --
--------------------------------
procedure Generate_Scheduling_Server (N : Node_Id) is
begin
Write_Line ("Scheduling_Server (");
Increment_Indentation;
Write_Indentation (-1);
if Is_Regular (N) then
Write_Line ("Type => Regular,");
else
Write_Str ("Type => ");
Write_Name (Associated_Scheduler (N));
Write_Line (Tok_Colon);
end if;
Write_Indentation (-1);
Write_Str ("Name => ");
Write_Name (Node_Name (N));
Write_Line (Tok_Colon);
if Parameters (N) /= No_Node then
Write_Indentation (-1);
Write (Tok_Parameters);
Write_Space;
Write (Tok_Assign);
Write_Space;
Write (Tok_Left_Paren);
Generate (Parameters (N));
Write (Tok_Right_Paren);
Write_Line (Tok_Colon);
end if;
Write_Indentation (-1);
Write (Tok_Server_Processing_Resource);
Write_Space;
Write (Tok_Assign);
Write_Space;
Write_Name (MTN.Server_Processing_Resource (N));
Write_Line (");");
end Generate_Scheduling_Server;
end Ocarina.Backends.MAST_Tree.Generator;
......@@ -33,6 +33,30 @@ module Ocarina::Backends::MAST_Tree::Nodes {
Node_Id Avg_ISR_Switch;
Node_Id Best_ISR_Switch;
Node_Id Speed_Factor;
boolean Regular_Processor;
boolean Packet_Based_Network;
};
interface Scheduling_Server : MAST_Node {
Name_Id Associated_Scheduler;
Node_Id Parameters;
boolean Is_Regular;
Name_Id Server_Processing_Resource;
};
interface Scheduling_Server_Parameters : Node_Id {
Node_Id Sched_Type;
Node_Id Priority;
boolean Is_Preassigned;
};
interface Operation : MAST_Node {
boolean Is_Simple;
boolean Is_Enclosing;
boolean Is_Composite;
Node_Id Worst_Case_Execution_Time;
Node_Id Best_Case_Execution_Time;
Node_Id Avg_Case_Execution_Time;
};
interface Scheduler : MAST_Node
......@@ -46,8 +70,8 @@ module Ocarina::Backends::MAST_Tree::Nodes {
Node_Id Worst_Context_Switch;
Node_Id Avg_Context_Switch;
Node_Id Best_Context_Switch;
Node_Id Max_Priority;
Node_Id Min_Priority;
Node_Id Max_Interrupt_Priority;
Node_Id Min_Interrupt_Priority;
};
interface Literal : Node_Id {
......@@ -59,6 +83,13 @@ module Ocarina::Backends::MAST_Tree::Nodes {
Node_Id Last_Node;
};
interface Transaction : MAST_Node {
boolean Is_Regular;
List_Id External_Events;
List_Id Internal_Events;
List_Id Events_Handlers;
};
interface Defining_Identifier : Node_Id {
Name_Id Name;
Node_Id Corresponding_Node;
......
......@@ -233,6 +233,7 @@ package body Ocarina.Backends.MAST_Tree.Nutils is
New_Token (Tok_Left_Paren, "(");
New_Token (Tok_Right_Paren, ")");
New_Token (Tok_Semicolon, ";");
New_Token (Tok_Colon, ",");
end Initialize;
......@@ -526,14 +527,40 @@ package body Ocarina.Backends.MAST_Tree.Nutils is
-- Make_Processing_Resource --
------------------------------
function Make_Processing_Resource (PR_Name : Name_Id; PR_Type : Name_Id)
function Make_Processing_Resource
(PR_Name : Name_Id; PR_Type : Processing_Resource_Kind)
return Node_Id is
N : Node_Id;
begin
N := New_Node (MTN.K_Processing_Resource);
MTN.Set_Node_Name (N, PR_Name);
MTN.Set_Node_Type (N, PR_Type);
if PR_Type = PR_Regular_Processor then
MTN.Set_Regular_Processor (N, True);
MTN.Set_Packet_Based_Network (N, False);
else
MTN.Set_Regular_Processor (N, False);
MTN.Set_Packet_Based_Network (N, True);
end if;
return N;
end Make_Processing_Resource;
------------------------------
-- Make_Scheduling_Server --
------------------------------
function Make_Scheduling_Server
(Server_Name : Name_Id;
Associated_Processor : Name_Id)
return Node_Id is
N : Node_Id;
begin
N := New_Node (MTN.K_Scheduling_Server);
MTN.Set_Node_Name (N, Server_Name);
MTN.Set_Server_Processing_Resource (N, Associated_Processor);
MTN.Set_Is_Regular (N, False);
MTN.Set_Associated_Scheduler (N, Get_String_Name ("Fixed_Priority"));
MTN.Set_Parameters (N, No_Node);
return N;
end Make_Scheduling_Server;
end Ocarina.Backends.MAST_Tree.Nutils;
......@@ -52,32 +52,39 @@ package Ocarina.Backends.MAST_Tree.Nutils is
Tok_First_Keyword,
Tok_Avg_Case_Execution_Time,
Tok_Avg_Context_Switch,
Tok_Avg_ISR_Switch,
Tok_Best_Case_Execution_time,
Tok_Best_Context_Switch,
Tok_Best_ISR_Switch,
Tok_Host,
Tok_List_Of_Drivers,
Tok_Max_Blocking,
Tok_Max_Packet_Size,
Tok_Max_Priority,
Tok_Max_ISR_Switch,
Tok_Min_Packet_Size,
Tok_Min_Priority,
Tok_Name,
Tok_Packet_Server,
Tok_Packet_Send_Operation,
Tok_Packet_Receive_Operation,
Tok_Parameters,
Tok_Processing_Resource,
Tok_RTA_Overhead_Model,
Tok_Scheduler,
Tok_Scheduling_Server,
Tok_Server_Processing_Resource,
Tok_Server_Sched_Parameters,
Tok_Speed_Factor,
Tok_Throughput,
Tok_Type,
Tok_Worst_Case_Execution_Time,
Tok_Worst_Context_Switch,
Tok_Worst_ISR_Switch,
Tok_Last_Keyword,
Tok_Assign, -- =>
Tok_Colon,
Tok_Left_Paren, -- (
Tok_Right_Paren, -- )
Tok_Semicolon); -- ;
......@@ -167,7 +174,19 @@ package Ocarina.Backends.MAST_Tree.Nutils is
function Make_Container (Content : Node_Id) return Node_Id;
function Make_Processing_Resource (PR_Name : Name_Id; PR_Type : Name_Id)
type Processing_Resource_Kind is
(
PR_Regular_Processor,
PR_Packet_Based_Network
);
function Make_Processing_Resource
(PR_Name : Name_Id; PR_Type : Processing_Resource_Kind)
return Node_Id;
function Make_Scheduling_Server
(Server_Name : Name_Id;
Associated_Processor : 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