taste-concurrency_view.adb 49.1 KB
Newer Older
1
2
3
4
--  ******************************* KAZOO  *******************************  --
--  (c) 2017-2021 European Space Agency - maxime.perrotin@esa.int
--  See LICENSE file
--  *********************************************************************** --
5

Maxime Perrotin's avatar
Maxime Perrotin committed
6
7
with Ada.Directories,
     Ada.IO_Exceptions,
Maxime Perrotin's avatar
Maxime Perrotin committed
8
     Ada.Exceptions,
Maxime Perrotin's avatar
Maxime Perrotin committed
9
     Ada.Characters.Latin_1,
10
     --  Ada.Strings.Fixed,
11
     GNAT.Directory_Operations,   --  Contains Dir_Name
12
     TASTE.Backend;
Maxime Perrotin's avatar
Maxime Perrotin committed
13

14
15
use Ada.Directories,
    GNAT.Directory_Operations;
Maxime Perrotin's avatar
Maxime Perrotin committed
16

17
18
package body TASTE.Concurrency_View is

Maxime Perrotin's avatar
Maxime Perrotin committed
19
20
   Newline : Character renames Ada.Characters.Latin_1.LF;

21
   procedure Debug_Dump (CV : Taste_Concurrency_View; Output : File_Type) is
Maxime Perrotin's avatar
Maxime Perrotin committed
22
23
24
      procedure Dump_Partition (Partition : CV_Partition) is
      begin
         for Block of Partition.Blocks loop
25
26
27
            Put_Line (Output, "Protected Block : "
                      & To_String (Block.Ref_Function.Name));
            for Provided of Block.Block_Provided loop
Maxime Perrotin's avatar
Maxime Perrotin committed
28
29
               Put_Line (Output, " |_ PI : " & To_String (Provided.Name));
            end loop;
30
            for Required of Block.Ref_Function.Required loop
Maxime Perrotin's avatar
Maxime Perrotin committed
31
32
33
34
35
36
37
38
39
40
41
               Put_Line (Output, " |_ RI : " & To_String (Required.Name));
            end loop;
            for Thread of Block.Calling_Threads loop
               Put_Line (Output, " |_ Calling_Thread : " & Thread);
            end loop;
            if Block.Node.Has_Value then
               Put_Line (Output, " |_ Node : "
                         & To_String (Block.Node.Unsafe_Just.Name));
               declare
                  P : constant Taste_Partition :=
                    Block.Node.Unsafe_Just.Find_Partition
42
                      (To_String (Block.Ref_Function.Name)).Unsafe_Just;
Maxime Perrotin's avatar
Maxime Perrotin committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
               begin
                  Put_Line (Output, " |_ Partition : " & To_String (P.Name));
                  Put_Line (Output, "   |_ Coverage       : "
                            & P.Coverage'Img);
                  Put_Line (Output, "   |_ Package        : "
                            & To_String (P.Package_Name));
                  Put_Line (Output, "   |_ CPU Name       : "
                            & To_String (P.CPU_Name));
                  Put_Line (Output, "   |_ CPU Platform   : "
                            & P.CPU_Platform'Img);
                  Put_Line (Output, "   |_ CPU Classifier : "
                            & To_String (P.CPU_Classifier));
               end;
            end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
57
         end loop;
58

Maxime Perrotin's avatar
Maxime Perrotin committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
         for Thread of Partition.Threads loop
            Put_Line (Output, "Thread : " & To_String (Thread.Name));
            Put_Line (Output, " |_ Port : "
                      & To_String (Thread.Entry_Port_Name));
            Put_Line (Output, " |_ Protected Block : "
                      & To_String (Thread.Protected_Block_Name));
            Put_Line (Output, " |_ Node : "
                      & To_String (Thread.Node.Value_Or
                        (Taste_Node'(Name   => US ("(none)"),
                                     others => <>)).Name));
            for Out_Port of Thread.Output_Ports loop
               Put_Line (Output, " |_ Output port remote thread : "
                         & To_String (Out_Port.Remote_Thread));
               Put_Line (Output, " |_ Output port remote PI : "
                         & To_String (Out_Port.Remote_PI));
            end loop;
         end loop;
      end Dump_Partition;
   begin
      for Node of CV.Nodes loop
         for Partition of Node.Partitions loop
            Dump_Partition (Partition);
Maxime Perrotin's avatar
Maxime Perrotin committed
81
         end loop;
82
83
84
      end loop;
   end Debug_Dump;

85
   --  This function translates a protected block into a template
86
87
88
   function Prepare_Block_Template (B : Protected_Block)
                                    return Block_As_Template
   is
89
      Calling_Threads : Tag;
90
      Result          : Block_As_Template;
91
92
93
94
95
   begin
      for Thread of B.Calling_Threads loop
         Calling_Threads := Calling_Threads & Thread;
      end loop;

96
      for PI of B.Block_Provided loop
97
         declare
98
            Basic : constant Translate_Set := PI.PI.Interface_To_Template
99
              & Assoc ("Protected_Block_Name", To_String (PI.Name))
100
101
              & Assoc ("Caller_Is_Local", PI.Local_Caller)
              & Assoc ("Calling_Threads", Calling_Threads);
102
         begin
Maxime Perrotin's avatar
Maxime Perrotin committed
103
104
105
106
107
            if PI.PI.RCM = Protected_Operation then
               Result.Protected_Provided.Append (Basic);
            else
               Result.Unprotected_Provided.Append (Basic);
            end if;
108
109
110
         end;
      end loop;

111
      for RI of B.Ref_Function.Required loop
112
         Result.Required.Append (RI.Interface_To_Template
113
                                 & Assoc ("Calling_Threads", Calling_Threads));
114
115
      end loop;

116
      Result.Header := B.Ref_Function.Function_To_Template.Header
117
118
119
120
                       & Assoc ("Calling_Threads", Calling_Threads)
                       & Assoc ("Node_Name",       To_String (B.Node.Value_Or
                         (Taste_Node'(Name => US (""), others => <>)).Name));
      return Result;
121
   end Prepare_Block_Template;
122
123

   --  This function translates a thread definition into a template
Maxime Perrotin's avatar
Maxime Perrotin committed
124
   function To_Template (T : AADL_Thread) return Translate_Set is
125
      Remote_Thread    : Vector_Tag;
Maxime Perrotin's avatar
Maxime Perrotin committed
126
      RI_Port_Name     : Vector_Tag;  --  Name of the local RI (= port name)
127
128
129
      Remote_PI        : Vector_Tag;  --  Name of the remote PI
      Remote_PI_Sort   : Vector_Tag;  --  ASN.1 type of the parameter
      Remote_PI_Module : Vector_Tag;  --  ASN.1 module containing the type
130
131
   begin
      for Out_Port of T.Output_Ports loop
Maxime Perrotin's avatar
Maxime Perrotin committed
132
         RI_Port_Name  := RI_Port_Name & Out_Port.Name;
133
134
         Remote_Thread := Remote_Thread & To_String (Out_Port.Remote_Thread);
         Remote_PI     := Remote_PI     & To_String (Out_Port.Remote_PI);
135
136
137
138
139
140
141
142
143
144
         --  Set the Asn.1 module and type of the optional RI parameter
         if Out_Port.RI.Params.Length > 0 then
            Remote_PI_Sort := Remote_PI_Sort
              & Out_Port.RI.Params.First_Element.Sort;
            Remote_PI_Module := Remote_PI_Module
              & Out_Port.RI.Params.First_Element.ASN1_Module;
         else
            Remote_PI_Sort   := Remote_PI_Sort   & "";
            Remote_PI_Module := Remote_PI_Module & "";
         end if;
145
146
147
      end loop;

      return Result : constant Translate_Set :=
148
149
150
151
152
153
154
        T.PI.Interface_To_Template      --  PI used to create the thread
        & Assoc ("Thread_Name",         To_String (T.Name))
        & Assoc ("Partition_Name",      To_String (T.Partition_Name))
        & Assoc ("Entry_Port_Name",     To_String (T.Entry_Port_Name))
        & Assoc ("RCM",                 To_String (T.RCM))
        & Assoc ("Need_Mutex",          T.Need_Mutex)
        & Assoc ("Pro_Block_Name",      To_String (T.Protected_Block_Name))
155
156
157
        & Assoc ("Pro_Instance_Of",     To_String
            (T.Ref_Protected_Block.Ref_Function.Instance_Of.Value_Or
                (US (""))))
158
        & Assoc ("Node_Name",           To_String (T.Node.Value_Or
159
          (Taste_Node'(Name => US (""), others => <>)).Name))
160
161
162
163
164
165
166
167
        & Assoc ("Remote_Threads",      Remote_Thread)
        & Assoc ("RI_Port_Names",       RI_Port_Name)
        & Assoc ("Remote_PIs",          Remote_PI)
        & Assoc ("Remote_PI_Sorts",     Remote_PI_Sort)
        & Assoc ("Remote_PI_Modules",   Remote_PI_Module)
        & Assoc ("Priority",            To_String (T.Priority))
        & Assoc ("Dispatch_Offset_ms",  To_String (T.Dispatch_Offset_Ms))
        & Assoc ("Stack_Size_In_Bytes", To_String (T.Stack_Size_In_Bytes));
Maxime Perrotin's avatar
Maxime Perrotin committed
168
   end To_Template;
169

Maxime Perrotin's avatar
Maxime Perrotin committed
170
   --  Generate the code by iterating over template folders
171
   procedure Generate_Code (CV : Taste_Concurrency_View)
172
   is
Maxime Perrotin's avatar
Maxime Perrotin committed
173
      Prefix   : constant String := CV.Base_Template_Path.Element
Maxime Perrotin's avatar
Maxime Perrotin committed
174
175
176
177
178
179
        & "templates/concurrency_view";
      --  To iterate over template folders
      ST       : Search_Type;
      Current  : Directory_Entry_Type;
      Filter   : constant Filter_Type := (Directory => True,
                                          others    => False);
180
181
      Output_File      : File_Type;

182
      CV_Out_Dir  : constant String  :=
Maxime Perrotin's avatar
Maxime Perrotin committed
183
        CV.Base_Output_Path.Element & "/build/";
184

185
186
187
      Shared_Lib_Dir : Unbounded_String renames
        CV.Configuration.Shared_Lib_Dir;

188
189
190
191
192
      --  Tags that are built over the whole system
      --  and cleant up between each template folder:
      Threads          : Unbounded_String;
      All_Thread_Names : Tag;  --  Complete list of threads
      All_Target_Names : Tag;  --  List of all targets used (AADL packages)
Maxime Perrotin's avatar
Maxime Perrotin committed
193
      All_Block_Names,         --  List of all blocks in the system
194
      All_Block_Instance_Of,   --  If the block is an instance of a type
Maxime Perrotin's avatar
Maxime Perrotin committed
195
      All_Block_Languages : Vector_Tag;  --  and their language
196
197
      Actual_Shared    : String_Sets.Set;
      Used_Shared_Types : Tag; --  Actually used shared types (whole system)
198
   begin
199
      Put_Debug ("Concurrency View templates expected in " & Prefix);
Maxime Perrotin's avatar
Maxime Perrotin committed
200
201
202
203
204
205
206
207
208
209
210
211
212
      Start_Search (Search    => ST,
                    Pattern   => "",
                    Directory => Prefix,
                    Filter    => Filter);

      if not More_Entries (ST) then
         --  On Unix, this will never happen because "." and ".." are part
         --  of the search result. We'll only get an IO Error if the
         --  concurrency_view folder itself does not exist
         raise Concurrency_View_Error with
           "No folders with templates for concurrency view";
      end if;

213
      --  Iterate over the folders containing template files
Maxime Perrotin's avatar
Maxime Perrotin committed
214
      while More_Entries (ST) loop
215
216
217
218
         --  Clean-up system-wise tags before the next template folder:
         Threads := US ("");
         Clear (All_Thread_Names);
         Clear (All_Target_Names);
219
         Clear (All_Block_Names);
Maxime Perrotin's avatar
Maxime Perrotin committed
220
         Clear (All_Block_Languages);
221
         Clear (All_Block_Instance_Of);
222

Maxime Perrotin's avatar
Maxime Perrotin committed
223
224
225
226
227
228
229
         Get_Next_Entry (ST, Current);

         --  Ignore Unix special directories
         if Simple_Name (Current) = "." or Simple_Name (Current) = ".." then
            goto continue;
         end if;

Maxime Perrotin's avatar
Maxime Perrotin committed
230
         declare
Maxime Perrotin's avatar
Maxime Perrotin committed
231
232
            Path  : constant String  := Full_Name (Current);

233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
            --  Optional template for Busses, useful to render the bus
            --  properties.
            function Generate_Bus (Bus : Taste_Bus) return String
            is
               File_Id   : constant String := Path & "/bus.tmplt";
               Trigger   : constant Boolean := Exists (File_Id);
               Bus_Assoc : constant Translate_Set :=
                   Properties_To_Template (Bus.Properties)
                   & Assoc ("Bus_Name",     Bus.Name)
                   & Assoc ("AADL_Package", Bus.AADL_Package)
                   & Assoc ("Classifier",   Bus.Classifier);
               Result    : constant String :=
                   (if Trigger then Strip_String (Parse (File_Id, Bus_Assoc))
                   else "");
            begin
               Document_Template
                 (Templates_Concurrency_View_Sub_Bus, Bus_Assoc);
               return Result;
            end Generate_Bus;

253
254
            function Generate_Partition (Node_Name      : String;
                                         Partition_Name : String)
Maxime Perrotin's avatar
Maxime Perrotin committed
255
                                         return String
Maxime Perrotin's avatar
Maxime Perrotin committed
256
            is
Maxime Perrotin's avatar
Maxime Perrotin committed
257
258
               Partition       : constant CV_Partition :=
                 CV.Nodes (Node_Name).Partitions (Partition_Name);
259
260
               Thread_Names,
               Thread_Has_Param : Vector_Tag;
261
262
               Block_Names,
               Block_Languages,
263
               Block_Instance_Of,
264
               Block_Is_Shared_Type,
265
               Block_FPGAConf,
266
               Block_Default_Codegen : Vector_Tag;
Maxime Perrotin's avatar
Maxime Perrotin committed
267
               Blocks          : Unbounded_String;
268
               Part_Threads    : Unbounded_String;
Maxime Perrotin's avatar
Maxime Perrotin committed
269
               Partition_Assoc : Translate_Set;
270
               --  Connections between threads:
271
               Thread_Src_Name,
272
               Thread_Src_Port : Vector_Tag;
273
               Thread_Dst_Name,
274
               Thread_Dst_Port : Vector_Tag;
275
276
               Input_Port_Names,
               Input_Port_Type_Name,
277
               Input_Port_Encoding_Name,
278
               Input_Port_Queue_Size,
279
280
               Input_Port_Thread_Name  : Vector_Tag;
               Output_Port_Names,
281
               Output_Port_Type_Name,
282
               Output_Port_Encoding_Name,
283
               Output_Port_Queue_Size  : Vector_Tag;
284
285
286
               Out_Port_Remote_Partition : Vector_Tag;
               Out_Port_Remote_Function : Vector_Tag;
               Out_Port_Remote_Port_Name : Vector_Tag;
287
288
               Part_Out_Port_Names,  --  there can be multiple threads
               Connected_Threads : Vector_Tag;  -- on one partition outport
289

290
291
292
293
294
295
296
297
298
299
               --  Optionally generate partition code in separate files
               --  (if filepart.tmplt is present and contains a filename)
               File_Id         : constant String := Path & "/filepart.tmplt";
               Part_Check      : constant Boolean := Exists (File_Id);
               Part_Tag        : constant Translate_Set :=
                 +Assoc ("Partition_Name", Partition_Name);
               Part_File_Name  : constant String :=
                 (if Part_Check then Strip_String (Parse (File_Id, Part_Tag))
                  else "");
               Part_Content    : Unbounded_String;
Maxime Perrotin's avatar
Maxime Perrotin committed
300
            begin
301
302
               Document_Template
                 (Templates_Concurrency_View_Sub_File_Part, Part_Tag);
303
304
305
306
               for Each of Partition.In_Ports loop
                  Input_Port_Names := Input_Port_Names & Each.Port_Name;
                  Input_Port_Type_Name := Input_Port_Type_Name
                    & Each.Type_Name;
307
308
                  Input_Port_Encoding_Name := Input_Port_Encoding_Name
                    & Each.Encoding;
309
310
                  Input_Port_Thread_Name :=
                    Input_Port_Thread_Name & Each.Thread_Name;
311
312
                  Input_Port_Queue_Size :=
                    Input_Port_Queue_Size & Each.Queue_Size;
313
314
315
316
317
               end loop;
               for Each of Partition.Out_Ports loop
                  Output_Port_Names := Output_Port_Names & Each.Port_Name;
                  Output_Port_Type_Name := Output_Port_Type_Name
                    & Each.Type_Name;
318
319
                  Output_Port_Encoding_Name := Output_Port_Encoding_Name
                    & Each.Encoding;
320
321
322
323
324
325
                  --  Set the connection between threads and partition outports
                  for T of Each.Connected_Threads loop
                     Part_Out_Port_Names := Part_Out_Port_Names
                       & Each.Port_Name;
                     Connected_Threads := Connected_Threads & T;
                  end loop;
326
327
328
329
330
331
                  Out_Port_Remote_Partition := Out_Port_Remote_Partition
                    & Each.Remote_Partition_Name;
                  Out_Port_Remote_Port_Name := Out_Port_Remote_Port_Name
                    & Each.Remote_Port_Name;
                  Out_Port_Remote_Function := Out_Port_Remote_Function
                    & Each.Remote_Function_Name;
332
333
                  Output_Port_Queue_Size :=
                    Output_Port_Queue_Size & Each.Queue_Size;
334
335
               end loop;

336
337
338
               for T of Partition.Threads loop
                  declare
                     --  Render each thread
339
                     Name         : constant String := To_String (T.Name);
340
341
                     Thread_Assoc : constant Translate_Set :=
                       Join_Sets (T.To_Template, CV.Configuration.To_Template);
342
                     Result       : constant String :=
343
                       (Parse (Path & "/thread.tmplt", Thread_Assoc));
344
345
346
347
348
349
350
351

                     --  Optionally generate thread code in separate files
                     --  (if filethread.tmplt present and contains a filename)
                     Thread_File_Id   : constant String :=
                       Path & "/filethread.tmplt";
                     Thread_Check     : constant Boolean :=
                       Exists (Thread_File_Id);
                     Thread_Tag       : constant Translate_Set :=
352
353
                       +Assoc ("Thread_Name", Name)
                       & Assoc ("Partition_Name", Partition_Name);
354
355
356
357
                     Thread_File_Name : constant String :=
                       (if Thread_Check
                        then Strip_String (Parse (Thread_File_Id, Thread_Tag))
                        else "");
358
                  begin
359
360
361
362
363
                     Document_Template
                       (Templates_Concurrency_View_Sub_Thread, Thread_Assoc);
                     Document_Template
                       (Templates_Concurrency_View_Sub_File_Thread,
                        Thread_Tag);
364

365
                     Threads      := Threads & Newline & Result;
366
                     Part_Threads := Part_Threads & Newline & Result;
367
                     Thread_Names := Thread_Names & Name;
368
369
370
371
372
373
                     --  Set boolean to true if thread has a param
                     --  That helps backend to know if POHI has generated
                     --  the "types" package.
                     Thread_Has_Param := Thread_Has_Param &
                       (T.PI.Params.Length > 0);

374
                     All_Thread_Names := All_Thread_Names & Name;
375
                     for P of T.Output_Ports loop
376
377
378
379
380
381
382
383
384
385
386
387
388
                        for Part_Threads of Partition.Threads loop
                           --  Create partition ports only when source and
                           --  destination are in the same partition
                           if P.Remote_Thread = Part_Threads.Name then
                              Thread_Src_Name := Thread_Src_Name & Name;
                              Thread_Src_Port := Thread_Src_Port
                                & To_String (P.Name);
                              Thread_Dst_Name := Thread_Dst_Name
                                & To_String (P.Remote_Thread);
                              Thread_Dst_Port := Thread_Dst_Port
                                & To_String (P.Remote_PI);
                           end if;
                        end loop;
389
                     end loop;
390
391
392
                     --  Save the content of the thread in a file
                     --  (if required at template folder level)
                     if Thread_File_Name /= "" then
393
394
                        Create_Path (CV_Out_Dir & Node_Name & Dir_Separator
                                       & Dir_Name (Thread_File_Name));
395
396
                        Create (File => Output_File,
                                Mode => Out_File,
397
398
399
                                Name => CV_Out_Dir
                                  & Node_Name & Dir_Separator
                                  & Thread_File_Name);
400
401
402
                        Put_Line (Output_File, Result);
                        Close (Output_File);
                     end if;
403
                  end;
Maxime Perrotin's avatar
Maxime Perrotin committed
404
               end loop;
405

406
407
               for B of Partition.Blocks loop
                  declare
408
409
                     Block_Name   : constant String :=
                       To_String (B.Ref_Function.Name);
Maxime Perrotin's avatar
Maxime Perrotin committed
410
                     Tmpl         : constant Block_As_Template :=
411
                       B.Prepare_Block_Template;
Maxime Perrotin's avatar
Maxime Perrotin committed
412
413
414
415
416
                     Block_Assoc  : Translate_Set := Tmpl.Header;
                     Pro_PI_Tag   : Unbounded_String;
                     Unpro_PI_Tag : Unbounded_String;
                     RI_Tag       : Unbounded_String;
                     Result       : Unbounded_String;
417
418
419
420
421
422
423
424

                     --  Optionally generate block code in separate files
                     --  (if fileblock.tmplt present and contains a filename)
                     Block_File_Id   : constant String :=
                       Path & "/fileblock.tmplt";
                     Block_Check     : constant Boolean :=
                       Exists (Block_File_Id);
                     Block_Tag       : constant Translate_Set :=
425
                       +Assoc ("Block_Name", Block_Name);
426
427
428
429
                     Block_File_Name : constant String :=
                       (if Block_Check
                        then Strip_String (Parse (Block_File_Id, Block_Tag))
                        else "");
430
431
432
433
434
435
436
                     Parent_Is_Shared : constant Boolean :=
                       (B.Ref_Function.Instance_Of.Has_Value and then
                          CV.Configuration.Shared_Types.Contains
                            (To_String
                               (B.Ref_Function.Instance_Of.Unsafe_Just)));
                     use String_Sets;

437
                  begin
438
439
                     Document_Template
                       (Templates_Concurrency_View_Sub_File_Block, Block_Tag);
440
                     Block_Names     := Block_Names & Block_Name;
441
                     All_Block_Names := All_Block_Names & Block_Name;
442
443
                     Block_Languages := Block_Languages
                       & TASTE.Backend.Language_Spelling (B.Ref_Function);
Maxime Perrotin's avatar
Maxime Perrotin committed
444
445
                     All_Block_Languages := All_Block_Languages
                       & TASTE.Backend.Language_Spelling (B.Ref_Function);
446
447
                     Block_Instance_Of := Block_Instance_Of
                       & B.Ref_Function.Instance_Of.Value_Or (US (""));
448
449
                     All_Block_Instance_Of := All_Block_Instance_Of
                       & B.Ref_Function.Instance_Of.Value_Or (US (""));
450

451
452
                     --  Check if the function type for this instance is in the
                     --  list of shared library folders instead of in the model
453
454
455
456
457
458
459
                     Block_Is_Shared_Type :=
                       Block_Is_Shared_Type & Parent_Is_Shared;

                     if Parent_Is_Shared then
                        --  Update the list of actually used shared types
                        Actual_Shared := Actual_Shared or
                          String_Sets.To_Set
460
                            (To_String
461
462
                               (B.Ref_Function.Instance_Of.Unsafe_Just));
                     end if;
463

464
                     for TASTE_property of B.Ref_Function.User_Properties loop
465
466
467
468
469
470
                        if TASTE_property.Name =
                            "TASTE_IV_Properties::FPGA_Configurations"
                        then
                           Block_FPGAConf := Block_FPGAConf &
                                TASTE_property.Value;
                        end if;
471
472
                     end loop;

473
474
475
476
477
478
479
480
481
                     for TASTE_Property of B.Ref_Function.User_Properties loop
                        if TASTE_Property.Name =
                            "TASTE_IV_Properties::Default_CodeGen"
                        then
                           Block_Default_Codegen := Block_Default_Codegen &
                            TASTE_Property.Value;
                        end if;
                     end loop;

482
483
484
485
486
                     if Size (Block_FPGAConf) /= Size (Block_Names)
                     then
                        Block_FPGAConf := Block_FPGAConf & "";
                     end if;

487
488
489
490
491
                     if Size (Block_Default_Codegen) /= Size (Block_Names)
                     then
                        Block_Default_Codegen := Block_Default_Codegen & "";
                     end if;

Maxime Perrotin's avatar
Maxime Perrotin committed
492
                     for PI_Assoc of Tmpl.Protected_Provided loop
493
                        Document_Template
494
                          (Templates_Concurrency_View_Sub_PI,
495
                           PI_Assoc & Assoc ("Partition_Name", ""));
Maxime Perrotin's avatar
Maxime Perrotin committed
496
                        Pro_PI_Tag := Pro_PI_Tag & Newline
497
498
499
                          & String'(Parse (Path & "/pi.tmplt",
                                    PI_Assoc & Assoc
                                      ("Partition_Name", Partition_Name)));
Maxime Perrotin's avatar
Maxime Perrotin committed
500
501
502
                     end loop;
                     for PI_Assoc of Tmpl.Unprotected_Provided loop
                        Unpro_PI_Tag := Unpro_PI_Tag & Newline
503
504
505
                          & String'(Parse (Path & "/pi.tmplt",
                                    PI_Assoc & Assoc
                                      ("Partition_Name", Partition_Name)));
506
507
                     end loop;
                     for RI_Assoc of Tmpl.Required loop
508
                        Document_Template
509
                          (Templates_Concurrency_View_Sub_RI,
510
511
                           RI_Assoc & Assoc ("Partition_Name", ""));

Maxime Perrotin's avatar
Maxime Perrotin committed
512
                        RI_Tag := RI_Tag & Newline
513
514
515
                          & String'(Parse (Path & "/ri.tmplt",
                                    RI_Assoc & Assoc
                                      ("Partition_Name", Partition_Name)));
516
                     end loop;
Maxime Perrotin's avatar
Maxime Perrotin committed
517
518

                     Block_Assoc :=
519
520
521
522
523
                       Join_Sets
                         (Properties_To_Template
                            (B.Ref_Function.User_Properties),
                          Join_Sets
                            (Block_Assoc, CV.Configuration.To_Template))
524
525
                       & Assoc ("Partition_Name",
                                Partition.Deployment_Partition.Name)
Maxime Perrotin's avatar
Maxime Perrotin committed
526
527
                       & Assoc ("Protected_PIs",   Pro_PI_Tag)
                       & Assoc ("Unprotected_PIs", Unpro_PI_Tag)
528
                       & Assoc ("Is_Shared_Type",  Parent_Is_Shared)
529
                       & Assoc ("Required",        RI_Tag);
530

531
                     Result := Parse (Path & "/block.tmplt", Block_Assoc);
532
533
                     Document_Template
                       (Templates_Concurrency_View_Sub_Block, Block_Assoc);
534
535
536
537
538
539

                     Blocks := Blocks & Newline & To_String (Result);

                     --  Save the content of the block in a file
                     --  (if required at template folder level)
                     if Block_File_Name /= "" then
540
541
542
                        Create_Path (CV_Out_Dir & Node_Name
                                       & Dir_Separator
                                       & Dir_Name (Block_File_Name));
543
544
                        Create (File => Output_File,
                                Mode => Out_File,
545
546
547
                                Name => CV_Out_Dir
                                  & Node_Name & Dir_Separator
                                  & Block_File_Name);
548
549
550
                        Put_Line (Output_File, To_String (Result));
                        Close (Output_File);
                     end if;
551
                  end;
Maxime Perrotin's avatar
Maxime Perrotin committed
552
               end loop;
553
554
               --  Association includes Name, Coverage, CPU Info, etc.
               --  (see taste-deployment_view.ads for the complete list)
555
               Partition_Assoc :=
556
                 Join_Sets (CV.Configuration.To_Template,
557
558
                 Join_Sets (Partition.Deployment_Partition.To_Template,
                            Drivers_To_Template
559
                              (CV.Nodes (Node_Name).Deployment_Node.Drivers)))
560
                 & Assoc ("Threads",              Part_Threads)
561
                 & Assoc ("Thread_Names",         Thread_Names)
562
                 & Assoc ("Thread_Has_Param",     Thread_Has_Param)
563
564
565
566
                 & Assoc ("Node_Name",            Node_Name)
                 & Assoc ("Blocks",               Blocks)
                 & Assoc ("Block_Names",          Block_Names)
                 & Assoc ("Block_Languages",      Block_Languages)
567
                 & Assoc ("Block_Instance_Of",    Block_Instance_Of)
568
                 & Assoc ("Block_Is_Shared_Type", Block_Is_Shared_Type)
569
                 & Assoc ("Block_FPGAConf",       Block_FPGAConf)
570
                 & Assoc ("Block_Default_Codegen", Block_Default_Codegen)
571
572
                 & Assoc ("In_Port_Names",        Input_Port_Names)
                 & Assoc ("In_Port_Thread_Name",  Input_Port_Thread_Name)
573
                 & Assoc ("In_Port_Queue_Size",   Input_Port_Queue_Size)
574
                 & Assoc ("In_Port_Type_Name",    Input_Port_Type_Name)
575
576
                 & Assoc ("In_Port_Encoding_Name",
                          Input_Port_Encoding_Name)
577
578
                 & Assoc ("Out_Port_Names",       Output_Port_Names)
                 & Assoc ("Out_Port_Type_Name",   Output_Port_Type_Name)
579
580
                 & Assoc ("Out_Port_Encoding_Name",
                          Output_Port_Encoding_Name)
581
                 & Assoc ("Out_Port_Queue_Size",  Output_Port_Queue_Size)
582
583
584
585
586
587
                 & Assoc ("Out_Port_Remote_Partition",
                          Out_Port_Remote_Partition)
                 & Assoc ("Out_Port_Remote_Port_Name",
                          Out_Port_Remote_Port_Name)
                 & Assoc ("Out_Port_Remote_Function",
                          Out_Port_Remote_Function)
588
589
                 & Assoc ("Part_Out_Port_Name",   Part_Out_Port_Names)
                 & Assoc ("Connected_Threads",    Connected_Threads)
590
591
592
                 & Assoc ("Thread_Src_Name",      Thread_Src_Name)
                 & Assoc ("Thread_Src_Port",      Thread_Src_Port)
                 & Assoc ("Thread_Dst_Name",      Thread_Dst_Name)
593
594
                 & Assoc ("Thread_Dst_Port",      Thread_Dst_Port)
                 & Assoc ("Shared_Lib_Dir",       Shared_Lib_Dir);
595

596
597
598
               All_Target_Names := All_Target_Names
                 & String'(Get (Get (Partition_Assoc, "Package_Name")));

599
600
601
               Part_Content :=
                 Parse (Path & "/partition.tmplt", Partition_Assoc);

602
603
               Document_Template
                 (Templates_Concurrency_View_Sub_Partition, Partition_Assoc);
604

605
606
607
               --  Save the content of the partition in a file
               --  (if required at template folder level)
               if Part_File_Name /= "" then
Maxime Perrotin's avatar
Maxime Perrotin committed
608
                  Create_Path (CV_Out_Dir & Node_Name
609
                               & Dir_Separator & Dir_Name (Part_File_Name));
610
611
                  Create (File => Output_File,
                          Mode => Out_File,
612
613
                          Name => CV_Out_Dir
                             & Node_Name & Dir_Separator & Part_File_Name);
614
615
616
617
618
                  Put_Line (Output_File, To_String (Part_Content));
                  Close (Output_File);
               end if;

               return To_String (Part_Content);
Maxime Perrotin's avatar
Maxime Perrotin committed
619
            end Generate_Partition;
Maxime Perrotin's avatar
Maxime Perrotin committed
620

621
622
            --  Generate the code for one node
            function Generate_Node (Node_Name : String) return String is
623
624
625
               Partitions      : Unbounded_String;
               Partition_Names : Tag;
               Node_Assoc      : Translate_Set;
Maxime Perrotin's avatar
Maxime Perrotin committed
626
627
628
629
630
               --  Nodes may contain a list of virtual processors for TSP:
               VP_Names,
               VP_Package_Names,
               VP_Platforms,
               VP_Classifiers  : Vector_Tag;
631
632
               Block_Names,  --  All blocks of a node
               Block_Languages,
633
               Block_Is_Passive,  --  If the block only has synchronous PIs
634
               Block_Instance_Of : Vector_Tag;
635
            begin
Maxime Perrotin's avatar
Maxime Perrotin committed
636
               for Partition in CV.Nodes (Node_Name).Partitions.Iterate loop
637
638
                  Partition_Names := Partition_Names
                    & CV_Partitions.Key (Partition);
639
640
641
642
                  Partitions := Partitions & Newline
                    & Generate_Partition
                    (Partition_Name => CV_Partitions.Key (Partition),
                     Node_Name      => Node_Name);
643
644
645
646
647
                  for B of CV_Partitions.Element (Partition).Blocks loop
                     Block_Names := Block_Names &
                        To_String (B.Ref_Function.Name);
                     Block_Languages := Block_Languages
                       & TASTE.Backend.Language_Spelling (B.Ref_Function);
648
649
650
651
652
653
654
655
656
657
658
659
660
661
                     --  Flag blocks that are purely passive (no cyclic,
                     --  no sporadics, no timers). Useful for some backends.
                     declare
                        Is_Passive : Boolean := True;
                     begin
                        for PI of B.Ref_Function.Provided loop
                           if PI.RCM = Sporadic_Operation
                           or PI.RCM = Cyclic_Operation
                           then
                              Is_Passive := False;
                           end if;
                        end loop;
                        Block_Is_Passive := Block_Is_Passive & Is_Passive;
                     end;
662
663
664
                     Block_Instance_Of := Block_Instance_Of
                       & B.Ref_Function.Instance_Of.Value_Or (US (""));
                  end loop;
Maxime Perrotin's avatar
Maxime Perrotin committed
665
               end loop;
Maxime Perrotin's avatar
Maxime Perrotin committed
666
667
668
669
670
671
672
               for VP of CV.Nodes (Node_Name).Deployment_Node.Virtual_CPUs loop
                  VP_Names         := VP_Names & VP.Name;
                  VP_Package_Names := VP_Package_Names & VP.Package_Name;
                  VP_Platforms     := VP_Platforms & VP.Platform;
                  VP_Classifiers   := VP_Classifiers & VP.Classifier;
               end loop;

673
674
675
676
               Node_Assoc :=
                 Join_Sets (CV.Configuration.To_Template,
                            Drivers_To_Template (CV.Nodes (Node_Name)
                                                    .Deployment_Node.Drivers))
677
678
679
                 & Assoc ("Partitions",            Partitions)
                 & Assoc ("Partition_Names",       Partition_Names)
                 & Assoc ("Has_Memory",            Boolean'
Maxime Perrotin's avatar
Maxime Perrotin committed
680
                      (CV.Nodes (Node_Name).Deployment_Node.Memory.Name /= ""))
681
682
683
684
685
686
687
                 & Assoc ("VP_Names",              VP_Names)
                 & Assoc ("VP_Package_Names",      VP_Package_Names)
                 & Assoc ("VP_Platforms",          VP_Platforms)
                 & Assoc ("VP_Classifiers",        VP_Classifiers)
                 & Assoc ("Node_Name",             Node_Name)
                 & Assoc ("Block_Names",           Block_Names)
                 & Assoc ("Block_Languages",       Block_Languages)
688
                 & Assoc ("Block_Is_Passive",      Block_Is_Passive)
689
                 & Assoc ("Block_Instance_Of",     Block_Instance_Of)
690
                 & Assoc ("CPU_Name",
Maxime Perrotin's avatar
Maxime Perrotin committed
691
                          CV.Nodes (Node_Name).Deployment_Node.CPU_Name)
692
693
694
695
                 & Assoc ("CPU_Family",
                          CV.Nodes (Node_Name).Deployment_Node.CPU_Family)
                 & Assoc ("CPU_Instance",
                          CV.Nodes (Node_Name).Deployment_Node.CPU_Instance)
696
697
698
                 & Assoc ("CPU_Platform",
                         CV.Nodes (Node_Name).Deployment_Node.CPU_Platform'Img)
                 & Assoc ("CPU_Classifier",
Maxime Perrotin's avatar
Maxime Perrotin committed
699
700
701
                          CV.Nodes (Node_Name).Deployment_Node.CPU_Classifier)
                 & Assoc ("Package_Name",
                          CV.Nodes (Node_Name).Deployment_Node.Package_Name)
702
                 & Assoc ("Ada_Runtime",
703
                          CV.Nodes (Node_Name).Deployment_Node.Ada_Runtime);
704

705
706
               Document_Template
                 (Templates_Concurrency_View_Sub_Node, Node_Assoc);
707
708
               return Parse (Path & "/node.tmplt", Node_Assoc);
            end Generate_Node;
Maxime Perrotin's avatar
Maxime Perrotin committed
709

710
711
712
713
714
            Nodes           : Unbounded_String;
            Tmpl_File       : constant String  := Path & "/filesys.tmplt";
            Tmpl_Sys        : constant String  := Path & "/system.tmplt";
            Valid_Dir       : constant Boolean := Exists (Tmpl_File);
            File_Sys        : constant String  :=
Maxime Perrotin's avatar
Maxime Perrotin committed
715
              (if Valid_Dir then Strip_String (Parse (Tmpl_File)) else "");
716
717
            Trig_Sys        : constant Boolean := Exists (Tmpl_Sys);
            Set_Sys         : Translate_Set;
Maxime Perrotin's avatar
Maxime Perrotin committed
718
719
            Node_Names,                    --  List of nodes
            Node_CPU,                      --  Corresponding CPU name
720
            Node_Platform,                 --  Corresponding CPU Platform
Maxime Perrotin's avatar
Maxime Perrotin committed
721
            Node_CPU_Cls,                  --  Corresponding CPU classifier
Maxime Perrotin's avatar
Maxime Perrotin committed
722
723
            Node_Major_Frame,              --  Corresponding time frame (TSP)
            Node_Has_Memory : Vector_Tag;  --  Corresponding memory flag (TSP)
Maxime Perrotin's avatar
Maxime Perrotin committed
724
725
726
            Partition_Names,               --  List of partitions
            Partition_Node,                --  Corresponding node name
            Partition_CPU,                 --  Corresponding CPU name
Maxime Perrotin's avatar
Maxime Perrotin committed
727
            Partition_Time,                --  Corresponding TSP VP time
Maxime Perrotin's avatar
Maxime Perrotin committed
728
            Partition_VP    : Vector_Tag;  --  for TSP: VP binding
729
730
            Part_Source_Name,
            Part_Source_Port,
731
            Part_Dest_Port,
732
            Part_Dest_Name  : Vector_Tag;  -- Inter-partition connections (TSP)
Maxime Perrotin's avatar
Maxime Perrotin committed
733
734
            Bus_Names,
            Bus_AADL_Pkg,
735
            Bus_Properties,
Maxime Perrotin's avatar
Maxime Perrotin committed
736
            Bus_Classifier  : Vector_Tag;  --  System busses
737
            Device_Node_Name,
738
739
            Device_Partition_Name : Vector_Tag;
            All_Drivers : Taste_Drivers.Vector;
740
741
742
743
744
745

            --  To keep a list of ASN.1 files/modules without duplicates:
            Unique_ASN1_Sorts_Set : String_Sets.Set;
            Unique_ASN1_Files,
            Unique_ASN1_Sorts,
            Unique_ASN1_Modules : Vector_Tag;
746
747
748
749
            Connect_From_Partition,           --  Partition to bus connections
            Connect_Port_Name,
            Connect_Via_Bus    : Vector_Tag;
            Found : Boolean := False;
750
         begin
Maxime Perrotin's avatar
Maxime Perrotin committed
751
752
753
754
755
756
757
758
            --  Prepare the template tags of system.aadl with the busses
            for Bus of CV.Deployment.Busses loop
               --  The bus user properties are ignored here
               --  Could be added if needed but they would require an
               --  additional template file to process the name/values.
               Bus_Names      := Bus_Names & Bus.Name;
               Bus_AADL_Pkg   := Bus_AADL_Pkg & Bus.AADL_Package;
               Bus_Classifier := Bus_Classifier & Bus.Classifier;
759
               Bus_Properties := Bus_Properties & Generate_Bus (Bus);
Maxime Perrotin's avatar
Maxime Perrotin committed
760
761
            end loop;

762
763
764
765
766
767
            --  Bus connections: we need the output port name, partition and
            --  bus name to make the AADL construct. Check Bus_Connection type
            --  in deployment_view.ads if anything else is needed. It does not
            --  directly provide the partition name of the function so we have
            --  to retrieve it here
            for BC : Bus_Connection of CV.Deployment.Connections loop
768
               Connect_Via_Bus   := Connect_Via_Bus   & BC.Bus_Name;
769
770
771
772
773
774
775
               Connect_Port_Name := Connect_Port_Name & BC.Source_Port;
               Found := False;
               for Node of CV.Deployment.Nodes loop
                  exit when Found;
                  for Part of Node.Partitions loop
                     exit when Found;
                     if Part.Bound_Functions.Contains
776
                       (To_String (BC.Source_Function))
777
778
779
780
781
782
783
784
785
786
                     then
                        Connect_From_Partition :=
                          Connect_From_Partition & Part.Name;
                        Found := True;
                     end if;
                  end loop;
               end loop;
               if not Found then
                  raise Concurrency_View_Error with
                    "Could not find partition of function "
787
                    & To_String (BC.Source_Function);
788
789
790
               end if;
            end loop;

791
792
793
            for Node in CV.Nodes.Iterate loop
               declare
                  Node_Name    : constant String := CV_Nodes.Key (Node);
Maxime Perrotin's avatar
Maxime Perrotin committed
794
                  Output_Dir   : constant String := CV_Out_Dir & Node_Name;
795
796
797
798
799
800
801
802
803
804
805
806
                  Do_It        : constant Boolean :=
                    Exists (Path & "/filenode.tmplt");
                  Filename_Set : constant Translate_Set :=
                    +Assoc ("Node_Name", Node_Name);
                  --  Get output file name from template
                  File_Name    : constant String :=
                    (if Do_It then
                        Strip_String
                       (Parse (Path & "/filenode.tmplt", Filename_Set))
                     else "");
                  --  Check if file already exists
                  Present      : constant Boolean :=
807
808
                    (File_Name /= ""
                     and then Exists (Output_Dir & "/" & File_Name));
809

810
                  Trig_Tmpl    : constant Translate_Set :=
811
                    CV.Configuration.To_Template
812
813
814
815
816
817
818
819
820
821
                    & Assoc ("Filename_Is_Present", Present)
                    & Assoc ("CPU_Name",
                             CV.Nodes (Node_Name).Deployment_Node.CPU_Name)
                    & Assoc ("CPU_Family",
                             CV.Nodes (Node_Name).Deployment_Node.CPU_Family)
                    & Assoc ("CPU_Platform",
                             CV.Nodes (Node_Name).Deployment_Node
                               .CPU_Platform'Img)
                    & Assoc ("CPU_Classifier",
                             CV.Nodes (Node_Name).Deployment_Node
Maxime Perrotin's avatar
Maxime Perrotin committed
822
823
824
                             .CPU_Classifier)
                    & Assoc ("Is_Distributed",
                             CV.Deployment.Busses.Length > 0);
825

826
827
828
829
                  Trigger      : constant Boolean :=
                    (Node_Name /= "interfaceview"
                     and then Exists (Path & "/trigger.tmplt") and then
                     Strip_String
830
831
                       (String'(Parse (Path & "/trigger.tmplt", Trig_Tmpl))) =
                        "TRUE");
832
833
834
835
                  Node_Content : constant String :=
                    (if Trigger then Generate_Node (Node_Name)
                     else "");
               begin
836
837
838
839
                  Document_Template
                    (Templates_Concurrency_View_Sub_File_Node, Filename_Set);
                  Document_Template
                    (Templates_Concurrency_View_Sub_Trigger, Trig_Tmpl);
840
                  if Trigger then
841
842

                     --  Associate node name, CPU name and CPU classifier
Maxime Perrotin's avatar
Maxime Perrotin committed
843
                     --  Also set flag if a memory region is defined
844
                     --  (this is needed for AADL backends)
Maxime Perrotin's avatar
Maxime Perrotin committed
845
                     Node_Names := Node_Names & Node_Name;
846
847
                     Node_CPU := Node_CPU
                       & CV.Nodes (Node_Name).Deployment_Node.CPU_Name;
848
849
                     Node_Platform := Node_Platform
                       & CV.Nodes (Node_Name).Deployment_Node.CPU_Platform'Img;
850
851
                     Node_CPU_Cls := Node_CPU_Cls
                       & CV.Nodes (Node_Name).Deployment_Node.CPU_Classifier;
Maxime Perrotin's avatar
Maxime Perrotin committed
852
853
854
                     Node_Has_Memory := Node_Has_Memory
                       & (CV.Nodes (Node_Name)
                          .Deployment_Node.Memory.Name /= "");
Maxime Perrotin's avatar
Maxime Perrotin committed
855
856
                     Node_Major_Frame := Node_Major_Frame
                       & CV.Nodes (Node_Name).Deployment_Node.CPU_Duration;
857
858
859
860
861
862
863
864
865
866

                     --  Associate partition name, corresponding node and CPU
                     --  for AADL backends
                     for Partition in CV.Nodes (Node_Name).Partitions.Iterate
                     loop
                        Partition_Names := Partition_Names
                          & CV_Partitions.Key (Partition);
                        Partition_CPU := Partition_CPU
                          & CV_Partitions.Element (Partition)
                          .Deployment_Partition.CPU_Name;
Maxime Perrotin's avatar
Maxime Perrotin committed
867
868
869
                        Partition_VP := Partition_VP
                          & CV_Partitions.Element (Partition)
                          .Deployment_Partition.VP_Name;
870
                        Partition_Node := Partition_Node & Node_Name;
Maxime Perrotin's avatar
Maxime Perrotin committed
871
872
873
                        Partition_Time := Partition_Time
                          & CV_Partitions.Element (Partition)
                          .Deployment_Partition.VP_Duration;
874
875
876
877
878
879
880
881
882
883
884

                        --  Create the inter-partition connections
                        for Out_Port of
                          CV_Partitions.Element (Partition).Out_Ports
                        loop
                           Part_Source_Name := Part_Source_Name
                             & CV_Partitions.Key (Partition);
                           Part_Source_Port := Part_Source_Port
                             & Out_Port.Port_Name;
                           Part_Dest_Name := Part_Dest_Name
                             & Out_Port.Remote_Partition_Name;
885
886
                           Part_Dest_Port := Part_Dest_Port
                             & Out_Port.Remote_Port_Name;
887
                        end loop;
888
889
890
                     end loop;

                     Nodes := Nodes & Newline & Node_Content;
891
                     if File_Name /= "" then
892
893
                        Create_Path (Output_Dir & Dir_Separator
                                       & Dir_Name (File_Name));
894
895
                        Create (File => Output_File,
                                Mode => Out_File,
896
897
                                Name => Output_Dir
                                  & Dir_Separator & File_Name);
898
899
900
901
902
903
                        Put_Line (Output_File, Node_Content);
                        Close (Output_File);
                     end if;
                  end if;
               end;
            end loop;
904
905
906
907
908
            --  Iterate again on the nodes to set the devices
            --  at system level (they could also be added to
            --  nodes if needed, but for the concurrency view
            --  in AADL they are only used at system level)
            for N : Taste_Node of CV.Deployment.Nodes loop
909
910
911
912
913
914
915
916
               --  Check that there if there are drivers, there is only one
               --  partition in the node as the current design does not specify
               --  what partition(s) use the drivers.
               if not N.Drivers.Is_Empty and N.Partitions.Length > 1 then
                  raise Concurrency_View_Error with
                    "Drivers in multi-partition systems are not supported";
               end if;

917
918
               All_Drivers.Append (N.Drivers);

919
920
               for D : Taste_Device_Driver of N.Drivers loop
                  Device_Node_Name  := Device_Node_Name & N.Name;
921
922
                  Device_Partition_Name :=  -- There must be only one
                    Device_Partition_Name & N.Partitions.First_Element.Name;
923
924
925
926
927
928
929
930
931
932
933
                  --  Update list of types and files without duplicates
                  if not Unique_ASN1_Sorts_Set.Contains
                    (Strip_String (To_String (D.ASN1_Typename)))
                  then
                     Unique_ASN1_Sorts_Set.Insert
                       (Strip_String (To_String (D.ASN1_Typename)));
                     Unique_ASN1_Sorts := Unique_ASN1_Sorts & D.ASN1_Typename;
                     Unique_ASN1_Modules :=
                       Unique_ASN1_Modules & D.ASN1_Module;
                     Unique_ASN1_Files := Unique_ASN1_Files & D.ASN1_Filename;
                  end if;
934
935
936
               end loop;
            end loop;

Maxime Perrotin's avatar
Maxime Perrotin committed
937
            if Trig_Sys and File_Sys /= "" and Nodes /= "" then
Maxime Perrotin's avatar
Maxime Perrotin committed
938
               --  Generate from system.tmplt
939
940
941
942
943
944

               for Shared of Actual_Shared loop
                  --  Add list of actually used shared types at system level
                  Used_Shared_Types := Used_Shared_Types & Shared;
               end loop;

945
946
               Set_Sys := Join_Sets (CV.Configuration.To_Template,
                                     Drivers_To_Template (All_Drivers))
947
                 & Assoc ("Nodes",               Nodes)
948
949
                 & Assoc ("Node_Names",          Node_Names)
                 & Assoc ("Node_CPU",            Node_CPU)
950
                 & Assoc ("Node_Platform",       Node_Platform)
951
                 & Assoc ("Node_CPU_Classifier", Node_CPU_Cls)
Maxime Perrotin's avatar
Maxime Perrotin committed
952
                 & Assoc ("Node_Major_Frame",    Node_Major_Frame)
Maxime Perrotin's avatar
Maxime Perrotin committed
953
                 & Assoc ("Node_Has_Memory",     Node_Has_Memory)
954
955
956
                 & Assoc ("Partition_Names",     Partition_Names)
                 & Assoc ("Partition_Node",      Partition_Node)
                 & Assoc ("Partition_CPU",       Partition_CPU)
Maxime Perrotin's avatar
Maxime Perrotin committed
957
                 & Assoc ("Partition_Duration",  Partition_Time)
Maxime Perrotin's avatar
Maxime Perrotin committed
958
                 & Assoc ("Partition_VP",        Partition_VP)
959
960
961
                 & Assoc ("Part_Source_Name",    Part_Source_Name)
                 & Assoc ("Part_Source_Port",    Part_Source_Port)
                 & Assoc ("Part_Dest_Name",      Part_Dest_Name)
962
                 & Assoc ("Part_Dest_Port",      Part_Dest_Port)
963
964
                 & Assoc ("Threads",             Threads)
                 & Assoc ("Thread_Names",        All_Thread_Names)
965
                 & Assoc ("Block_Names",         All_Block_Names)
Maxime Perrotin's avatar
Maxime Perrotin committed
966
                 & Assoc ("Block_Languages",     All_Block_Languages)
967
                 & Assoc ("Block_Instance_Of",   All_Block_Instance_Of)
Maxime Perrotin's avatar
Maxime Perrotin committed
968
969
970
                 & Assoc ("Target_Packages",     All_Target_Names)
                 & Assoc ("Bus_Names",           Bus_Names)
                 & Assoc ("Bus_AADL_Package",    Bus_AADL_Pkg)
971
                 & Assoc ("Bus_Classifier",      Bus_Classifier)
972
                 & Assoc ("Bus_Properties",      Bus_Properties)
973
                 & Assoc ("Device_Node_Name",    Device_Node_Name)
974
                 & Assoc ("Device_Partition",    Device_Partition_Name)
975
976
977
                 & Assoc ("Unique_Dev_ASN1_Files", Unique_ASN1_Files)
                 & Assoc ("Unique_Dev_ASN1_Mod",   Unique_ASN1_Modules)
                 & Assoc ("Unique_Dev_ASN1_Sorts", Unique_ASN1_Sorts)
978
979
                 & Assoc ("Connect_From_Part",   Connect_From_Partition)
                 & Assoc ("Connect_Via_Bus",     Connect_Via_Bus)
980
981
                 & Assoc ("Connect_Port_Name",   Connect_Port_Name)
                 & Assoc ("Used_Shared_Types",   Used_Shared_Types);
982
983
               Create_Path (CV_Out_Dir
                           & Dir_Separator & Dir_Name (File_Sys));
Maxime Perrotin's avatar
Maxime Perrotin committed
984
985
               Create (File => Output_File,
                       Mode => Out_File,
986
                       Name => CV_Out_Dir & Dir_Separator & File_Sys);
Maxime Perrotin's avatar
Maxime Perrotin committed
987
               Put_Line (Output_File, Parse (Tmpl_Sys, Set_Sys));
988
989
               Document_Template
                 (Templates_Concurrency_View_Sub_System, Set_Sys);
Maxime Perrotin's avatar
Maxime Perrotin committed
990
991
               Close (Output_File);
            end if;
Maxime Perrotin's avatar
Maxime Perrotin committed
992
         end;
Maxime Perrotin's avatar
Maxime Perrotin committed
993
994
         <<continue>>
      end loop;
Maxime Perrotin's avatar
Maxime Perrotin committed
995
      End_Search (ST);
996
   end Generate_Code;
Maxime Perrotin's avatar
Maxime Perrotin committed
997
998
999

   procedure Generate_CV (CV : Taste_Concurrency_View) is
   begin
1000
      CV.Generate_Code;
For faster browsing, not all history is shown. View entire blame