taste-concurrency_view.ads 5.95 KB
Newer Older
1
2
3
4
--  ******************************* KAZOO  *******************************  --
--  (c) 2017-2021 European Space Agency - maxime.perrotin@esa.int
--  See LICENSE file
--  *********************************************************************** --
5
6
7
8
9

--  Model of the Concurrency View

with Ada.Containers.Indefinite_Ordered_Maps,
     Ada.Strings.Unbounded,
10
11
     Ada.Strings.Equal_Case_Insensitive,
     Ada.Strings.Less_Case_Insensitive,
12
     Text_IO,
13
     Templates_Parser,
14
     TASTE.Parser_Utils,
Maxime Perrotin's avatar
Maxime Perrotin committed
15
     TASTE.Interface_View,
16
17
     TASTE.Deployment_View,
     TASTE.Data_View;
18
19
20

use Ada.Containers,
    Ada.Strings.Unbounded,
21
    Text_IO,
22
    Templates_Parser,
23
    TASTE.Parser_Utils,
Maxime Perrotin's avatar
Maxime Perrotin committed
24
    TASTE.Interface_View,
25
26
    TASTE.Deployment_View,
    TASTE.Data_View;
27
28
29
30
31

package TASTE.Concurrency_View is

   Concurrency_View_Error : exception;

32
33
34
35
36
   function "="(Left, Right : Case_Insensitive_String) return Boolean
       renames Ada.Strings.Equal_Case_Insensitive;
   function "<"(Left, Right : Case_Insensitive_String) return Boolean
       renames Ada.Strings.Less_Case_Insensitive;

37
38
39
40
41
42
   type Protected_Block_PI is
      record
         Name         : Unbounded_String;
         PI           : Taste_Interface;
         Local_Caller : Boolean := True;
      end record;
43

44
45
46
   package Protected_Block_PIs is new Indefinite_Ordered_Maps
     (String, Protected_Block_PI);

Maxime Perrotin's avatar
Maxime Perrotin committed
47
   type Protected_Block is tagged
48
      record
49
50
51
         Ref_Function    : Taste_Terminal_Function;
         Block_Provided  : Protected_Block_PIs.Map;
         --  Required interfaces are defined in Ref_Function
Maxime Perrotin's avatar
Maxime Perrotin committed
52
         Calling_Threads : String_Sets.Set;
Maxime Perrotin's avatar
Maxime Perrotin committed
53
         Node            : Option_Node.Option;
54
55
      end record;

56
57
58
   --  Data model for the template backends (templates_parser)
   type Block_As_Template is
      record
Maxime Perrotin's avatar
Maxime Perrotin committed
59
60
61
62
         Header               : Translate_Set;
         Protected_Provided   : Translate_Sets.Vector;
         Unprotected_Provided : Translate_Sets.Vector;
         Required             : Translate_Sets.Vector;
63
      end record;
64
65
   function Prepare_Block_Template (B : Protected_Block)
                                    return Block_As_Template;
Maxime Perrotin's avatar
Maxime Perrotin committed
66

67
68
69
   package Protected_Blocks is new Indefinite_Ordered_Maps
     (String, Protected_Block);

70
   type Thread_Port is
71
      record
72
         Name          : Unbounded_String;
73
         Remote_Thread : Unbounded_String;
Maxime Perrotin's avatar
Maxime Perrotin committed
74
75
         Remote_PI     : Unbounded_String;  -- Remote PI name
         RI            : Taste_Interface;
76
77
      end record;

78
   package Ports is new Indefinite_Ordered_Maps (String, Thread_Port);
79

Maxime Perrotin's avatar
Maxime Perrotin committed
80
   type AADL_Thread is tagged
81
      record
82
         Name                 : Unbounded_String;
83
         Partition_Name       : Unbounded_String;
84
         RCM                  : Unbounded_String;
Maxime Perrotin's avatar
Maxime Perrotin committed
85
         Need_Mutex           : Boolean := False;
86
         Entry_Port_Name      : Unbounded_String;
87
         Ref_Protected_Block  : Protected_Block;
88
         Protected_Block_Name : Unbounded_String;
89
         Output_Ports         : Ports.Map;
Maxime Perrotin's avatar
Maxime Perrotin committed
90
         Node                 : Option_Node.Option;
91
92
         Priority,
         Dispatch_Offset_Ms,
93
         Stack_Size_In_Bytes  : Unbounded_String := Null_Unbounded_String;
94
         PI                   : Taste_Interface; --  Contains period, etc.
95
96
      end record;

Maxime Perrotin's avatar
Maxime Perrotin committed
97
98
   function To_Template (T : AADL_Thread) return Translate_Set;

99
100
   package AADL_Threads is new Indefinite_Ordered_Maps
     (Case_Insensitive_String, AADL_Thread);
101

102
   type Partition_In_Port is
103
      record
104
105
106
         Port_Name,
         Thread_Name,
         Type_Name,
107
         Encoding,
108
109
         Remote_Partition_Name : Unbounded_String;
         Queue_Size            : Unbounded_String := US ("1");
110
111
      end record;

112
   package Partition_In_Ports is
113
     new Indefinite_Ordered_Maps (Case_Insensitive_String, Partition_In_Port);
114
115
116
117
118

   --  Output ports of partitions can be connected to more than one
   --  thread output port. A vector of thread is needed to hold the list
   type Partition_Out_Port is
      record
119
         Port_Name,
120
121
         Type_Name,
         Encoding              : Unbounded_String;
122
         Connected_Threads     : String_Vectors.Vector;
123
         Remote_Partition_Name,
124
         Remote_Function_Name,
125
         Remote_Port_Name      : Unbounded_String; --  Other side
126
         Queue_Size            : Unbounded_String;
127
128
129
      end record;

   package Partition_Out_Ports is
130
     new Indefinite_Ordered_Maps (Case_Insensitive_String, Partition_Out_Port);
131

Maxime Perrotin's avatar
Maxime Perrotin committed
132
   type CV_Partition is tagged
133
      record
134
         Deployment_Partition : Taste_Partition;
135
136
         Threads              : AADL_Threads.Map;
         Blocks               : Protected_Blocks.Map;
137
138
         In_Ports             : Partition_In_Ports.Map;
         Out_Ports            : Partition_Out_Ports.Map;
139
      end record;
140

141
142
   package CV_Partitions is new Indefinite_Ordered_Maps
     (Case_Insensitive_String, CV_Partition);
143

Maxime Perrotin's avatar
Maxime Perrotin committed
144
145
146
   --  A node may contain several partitions (in case of TSP)
   type CV_Node is tagged
      record
147
         Deployment_Node : Taste_Node;
148
         Partitions      : CV_Partitions.Map;
Maxime Perrotin's avatar
Maxime Perrotin committed
149
      end record;
150

151
152
   package CV_Nodes is new Indefinite_Ordered_Maps
     (Case_Insensitive_String, CV_Node);
Maxime Perrotin's avatar
Maxime Perrotin committed
153
154
155
156
157
158
159

   --  CV is made of a list of nodes, each containing a list of partitions
   --  Partitions contain threads and passive functions as created during
   --  Vertical transformation
   --  Nodes contain drivers, and nodes are connected via busses, but this
   --  information is already in the deployment view. It is not repeated here.
   type Taste_Concurrency_View is tagged
160
      record
Maxime Perrotin's avatar
Maxime Perrotin committed
161
         Configuration      : Taste_Configuration;
Maxime Perrotin's avatar
Maxime Perrotin committed
162
         Nodes              : CV_Nodes.Map;
163
         Deployment         : Complete_Deployment_View;
164
         Data_View          : Taste_Data_View;
Maxime Perrotin's avatar
Maxime Perrotin committed
165
166
         Base_Template_Path : String_Holder;
         Base_Output_Path   : String_Holder;
167
168
      end record;

Maxime Perrotin's avatar
Maxime Perrotin committed
169
170
   procedure Debug_Dump (CV     : Taste_Concurrency_View;
                         Output : File_Type);
Maxime Perrotin's avatar
Maxime Perrotin committed
171

172
   --  Generate the concurrency view using templates
173
   procedure Generate_Code (CV : Taste_Concurrency_View);
174

175
end TASTE.Concurrency_View;