OpenCores
URL https://opencores.org/ocsvn/socgen/socgen/trunk

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_verilog] - Blame information for rev 120

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 119 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
#/**********************************************************************/
4
#/*                                                                    */
5
#/*             -------                                                */
6
#/*            /   SOC  \                                              */
7
#/*           /    GEN   \                                             */
8
#/*          /    TOOL    \                                            */
9
#/*          ==============                                            */
10
#/*          |            |                                            */
11
#/*          |____________|                                            */
12
#/*                                                                    */
13
#/*                                                                    */
14
#/*                                                                    */
15
#/*                                                                    */
16
#/*  Author(s):                                                        */
17
#/*      - John Eaton, jt_eaton@opencores.org                          */
18
#/*                                                                    */
19
#/**********************************************************************/
20
#/*                                                                    */
21
#/*    Copyright (C) <2010-2011>                */
22
#/*                                                                    */
23
#/*  This source file may be used and distributed without              */
24
#/*  restriction provided that this copyright statement is not         */
25
#/*  removed from the file and that any derivative work contains       */
26
#/*  the original copyright notice and the associated disclaimer.      */
27
#/*                                                                    */
28
#/*  This source file is free software; you can redistribute it        */
29
#/*  and/or modify it under the terms of the GNU Lesser General        */
30
#/*  Public License as published by the Free Software Foundation;      */
31
#/*  either version 2.1 of the License, or (at your option) any        */
32
#/*  later version.                                                    */
33
#/*                                                                    */
34
#/*  This source is distributed in the hope that it will be            */
35
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
36
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
37
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
38
#/*  details.                                                          */
39
#/*                                                                    */
40
#/*  You should have received a copy of the GNU Lesser General         */
41
#/*  Public License along with this source; if not, download it        */
42
#/*  from http://www.opencores.org/lgpl.shtml                          */
43
#/*                                                                    */
44
#/**********************************************************************/
45
 
46
 
47
############################################################################
48
# General PERL config
49
############################################################################
50
use Getopt::Long;
51
use English;
52
use File::Basename;
53
use Cwd;
54
use XML::LibXML;
55
use lib './tools';
56
use sys::lib;
57
use yp::lib;
58
 
59
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
60
 
61
 
62
############################################################################
63
### Process the options
64
############################################################################
65
Getopt::Long::config("require_order", "prefix=-");
66
GetOptions("h","help",
67
           "view=s" => \$view,
68
           "prefix=s" => \$prefix,
69
           "vendor=s" => \$vendor,
70
           "project=s" => \$project,
71
           "version=s" => \$version,
72
           "component=s" => \$component,
73
           "dest_dir=s" => \$dest_dir,
74
           "destination=s" => \$destination,
75
           "configuration=s" => \$configuration,
76
           "fragment","no_port","local_parameters"
77
) || die "(use '$program_name -h' for help)";
78
 
79
 
80
 
81
##############################################################################
82
## Help option
83
##############################################################################
84
if ( $opt_h  or $opt_help  )
85
  { print "\n gen_verilog -view {sim/syn}  -prefix /work -vendor vendor_name -project project_name  -component component_name  -version version_name -fragment -no_port -local_parameters -destination destination -configuration configuration -dest_dir  ../verilog";
86
    print "\n";
87
    exit 1;
88
  }
89
 
90
print "\n  GEN_verilog  $view  $prefix $vendor $project $component $version    $dest_dir  $destination \n";
91
 
92
 
93
 
94
#############################################################################
95
##
96
##
97
#############################################################################
98
 
99
 
100
$home = cwd();
101
my $variant;
102
 if($version)       {$variant   = "${component}_${version}";}
103
 else               {$variant   = "${component}";}
104
 
105
 
106 120 jt_eaton
 
107
#   print "XXXXXW  $vendor $project $component  $version  GEN_VERILOG $view \n";
108
 
109 119 jt_eaton
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$project);
110
my $comp_xml_sep    = yp::lib::find_ipxact_component_path("spirit:component",$vendor,$project,$component,$version);
111
 
112
my $parser = XML::LibXML->new();
113
 
114
 
115
my $path  = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}";
116
mkdir $path,0755             unless( -e $path );
117
 
118
my $path  = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}";
119
mkdir $path,0755             unless( -e $path );
120
 
121
my   @filelist_hier     =       ();
122
my   @instantiations    =       ();
123
my   @parameters        =       ();
124
my   %parameter_values  =       ();
125
 
126
print  "  Building verilog for ${project} ${component}  ${variant} \n  ";
127
my $socgen_ip_file                  = $parser->parse_file(yp::lib::find_socgen("socgen:ip",$vendor,$project,$component));
128
my $spirit_component_file           = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
129
 
130
 
131
#/**********************************************************************/
132
#/*                                                                    */
133
#/* Every hier cell is constructed from the ipxact file with seperate  */
134
#/* version  for each view                                             */
135
#/*                                                                    */
136
#/* Start by opening the output file                                   */
137
#/* get fileset name                                                   */
138
#/* check that requested view exists                                   */
139
#/*                                                                    */
140
#/**********************************************************************/
141
 
142 120 jt_eaton
foreach my $comp_view ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:name[text() = '$view']"             ))
143 119 jt_eaton
   {
144 120 jt_eaton
   my($view_fileset_name)  = $comp_view->findnodes('../spirit:fileSetRef/spirit:localName/text()')->to_literal ;
145
   $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}/${destination}";
146
   open DEST_FILE,">$outfile" or die "unable to open $outfile";
147
   unless ($opt_fragment){     print DEST_FILE  "\n module \n\n  $variant \n ";}
148 119 jt_eaton
 
149 120 jt_eaton
   #/*****************************************************************************/
150
   #/*  wire_decs array holds all port and signal declarations                   */
151
   #/*  :::name:::node_input_output:::wire_reg:::scaler_vector:::left:::right::: */
152
   #/*****************************************************************************/
153 119 jt_eaton
 
154 120 jt_eaton
   @wire_decs = (  );
155 119 jt_eaton
 
156
 
157 120 jt_eaton
   #/**********************************************************************/
158
   #/*  inst_conns holds all instance connections                         */
159
   #/**********************************************************************/
160 119 jt_eaton
 
161 120 jt_eaton
   @inst_conns = (  );
162 119 jt_eaton
 
163 120 jt_eaton
   my @decl_names  = ();
164
   my %decl_dirs  = ();
165
   my %decl_types  = ();
166
   my %decl_vector = ();
167
   my %decl_lefts  = ();
168
   my %decl_rights = ();
169 119 jt_eaton
 
170 120 jt_eaton
   #  component file
171
   parse_component_file($spirit_component_file);
172
   parse_design_files($spirit_component_file);
173
   process_design_files($spirit_component_file);
174 119 jt_eaton
 
175 120 jt_eaton
   #/**********************************************************************/
176
   #/*                                                                    */
177
   #/* pack ports and nodes into hashes                                   */
178
   #/*                                                                    */
179
   #/**********************************************************************/
180 119 jt_eaton
 
181
 
182 120 jt_eaton
   @wire_decs      = sys::lib::trim_sort(@wire_decs);
183
   foreach $line (@wire_decs)
184
     {
185
     $_ = $line;
186 119 jt_eaton
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
187
          {
188
          $q_index               = $1;
189
          $q_node_name           = $2;
190
          $q_direction           = $3;
191
          $q_type                = $4;
192
          $q_vector              = $5;
193
          $q_left                = $6;
194
          $q_right               = $7;
195
          $q_instance            = $8;
196
          $q_depth               = $9;
197
          $q_phy_name            = $10;
198
          $q_busref_name         = $11;
199
          $q_abslog_name         = $12;
200
 
201
 
202
 
203
 
204
         push ( @decl_names,$q_index);
205
 
206
 
207
          if(  $decl_pnames{$q_index})
208
            {
209
            if(  $decl_pnames{$q_index} eq ${q_index})
210
              {
211
              $decl_pnames{$q_index}  = "${q_node_name}";
212
              }
213
            }
214
          else
215
            {
216
            $decl_pnames{$q_index}  = "${q_node_name}";
217
            }
218
 
219
 
220
          if(  $decl_dirs{$q_index})
221
            {
222
            if(  $decl_dirs{$q_index} eq "node")
223
              {
224
              $decl_types{$q_index}  = "${q_type}";
225
              $decl_dirs{$q_index}  = "${q_direction}";
226
              }
227
            }
228
          else
229
            {
230
            $decl_types{$q_index}  = "${q_type}";
231
            $decl_dirs{$q_index}  = "${q_direction}";
232
            }
233
 
234
          if(  $decl_vector{$q_index})
235
            {  unless(  $decl_vector{$q_index} eq "vector"){ $decl_vector{$q_index}  = "${q_vector}";  }}
236
          else  { $decl_vector{$q_index}  = "${q_vector}"; }
237
 
238
          if( $q_vector eq "vector" )
239
            {
240
            if ( defined $decl_lefts{$q_index})
241
               {
242
               if($decl_lefts{$q_index}   <= $q_left  ) {$decl_lefts{$q_index}   = $q_left;}
243
               if($decl_rights{$q_index}  >= $q_right ) {$decl_rights{$q_index}  = $q_right;}
244
               }
245
            else
246
               {
247
               $decl_lefts{$q_index}   = $q_left;
248
               $decl_rights{$q_index}  = $q_right;
249
               }
250
            }
251
          }
252
        }
253
     @decl_names      = sys::lib::trim_sort(@decl_names);
254
 
255
 
256
 
257
 
258
 
259
     #/**********************************************************************/
260
     #/*                                                                    */
261
     #/* All port and signal info is now loaded in hashes, print out verilog*/
262
     #/*                                                                    */
263
     #/* Print out module header , parameters and ports                     */
264
     #/*                                                                    */
265
     #/**********************************************************************/
266
 
267
     #/**********************************************************************/
268
     #/*                                                                    */
269
     #/* parse parameters and values                                        */
270
     #/*                                                                    */
271
     #/**********************************************************************/
272 120 jt_eaton
 
273 119 jt_eaton
     foreach  my   $i_name ($spirit_component_file->findnodes('//spirit:model/spirit:modelParameters/spirit:modelParameter/spirit:name'))
274
        {
275
        my($parameter_name)     = $i_name ->to_literal;
276
        my($parameter_default)  = $i_name ->findnodes('../spirit:value/text()')->to_literal ;
277
 
278
        unless($parameter_values{$parameter_name}) {push ( @parameters,  "$parameter_name");};
279
        $parameter_values{$parameter_name} = ${parameter_default};
280
        }
281
 
282
     #/**********************************************************************/
283
     #/*                                                                    */
284
     #/* if configuration set then read parameters from socgen:ip file      */
285
     #/*                                                                    */
286
     #/**********************************************************************/
287
 
288
    if($configuration)
289
      {
290
      # print "XXX Reading configuration   $configuration \n";
291
      unless ($socgen_ip_file)      { print "No socgen ip file \n";};
292
 
293
      foreach my $socgen_cfg ($socgen_ip_file->findnodes("//socgen:ip/socgen:configurations/socgen:configuration/socgen:parameters/socgen:parameter/socgen:name"))
294
                {
295
                my($param_name)         = $socgen_cfg->findnodes('./text()')->to_literal ;
296
                my($param_value)        = $socgen_cfg->findnodes('../socgen:value/text()')->to_literal ;
297
                my($config_name)        = $socgen_cfg->findnodes('../../../socgen:name/text()')->to_literal ;
298
                if($config_name eq $configuration  )
299
                  {
300 120 jt_eaton
 
301 119 jt_eaton
                  unless($parameter_values{$param_name}) {push ( @parameters,  "$param_name");};
302
                  $parameter_values{$param_name} = ${param_value};
303
                  }
304
                }
305
 
306
      }
307
      else {print "No configuration \n";};
308
 
309
 
310
 
311
 
312
 
313
 
314
     #/**********************************************************************/
315
     #/*                                                                    */
316
     #/* Add any and all global parameters with their default values        */
317
     #/*                                                                    */
318
     #/**********************************************************************/
319
 
320
     unless ($opt_local_parameters)
321
     {
322
     my $first = 1;
323
     foreach my $parameter_name (@parameters)
324
        {
325
        my $parameter_value = $parameter_values{$parameter_name};
326
        if($first)
327
          {
328
          print DEST_FILE  "   #( parameter \n      ${parameter_name}=${parameter_value}";
329
          $first=0;
330
          }
331
        else  { print DEST_FILE  ",\n      ${parameter_name}=${parameter_value}";}
332
        }
333
 
334
     if    ($first == 0)   { print DEST_FILE  ")\n"; }
335
       }
336
 
337
 
338
     #/**********************************************************************/
339
     #/*                                                                    */
340
     #/* sort all  ports  with their type, size and direction               */
341
     #/*                                                                    */
342
     #/**********************************************************************/
343
 
344
 
345
     my @port_list  = ();
346
 
347
 
348
     foreach $x_name (@decl_names)
349
        {
350
        my $q_width  = "     ";
351
        if( $decl_vector{$x_name} eq "vector" )  { $q_width = "[ $decl_lefts{$x_name} :  $decl_rights{$x_name}]"}
352
 
353
        if( $decl_dirs{$x_name} ne "node" )
354
          {
355
          push (@port_list,  "$decl_dirs{$x_name}   $decl_types{$x_name}    $q_width        $decl_pnames{$x_name}");
356
          }
357
        }
358
 
359
     @port_list      = sys::lib::trim_sort(@port_list);
360
 
361
 
362
     #/**********************************************************************/
363
     #/*                                                                    */
364
     #/* Now add all ports  with their type, size and direction             */
365
     #/*                                                                    */
366
     #/**********************************************************************/
367
 
368
 
369
     print DEST_FILE  "\n    ";
370
     $first = 1;
371
 
372
     foreach $port_line (@port_list)
373
        {
374
          if($first)
375
            {
376
            print DEST_FILE  " (\n ${port_line}";
377
            $first=0;
378
            }
379
          else
380
            {
381
            print DEST_FILE  ",\n ${port_line}";
382
            }
383
 
384
        }
385
 
386
     if    ($first == 0)   { print DEST_FILE  ");\n\n\n\n"; }
387
     elsif ($opt_no_port)  { print DEST_FILE  "\n\n\n\n";  }
388
     else                  { print DEST_FILE  "();\n\n\n\n";}
389
 
390
     #/**********************************************************************/
391
     #/*                                                                    */
392
     #/* Add any and all local parameters with their default values         */
393
     #/*                                                                    */
394
     #/**********************************************************************/
395
 
396
     if ($opt_local_parameters)
397
     {
398
     foreach my $parameter_name (@parameters)
399
        {
400
        my $parameter_value = $parameter_values{${parameter_name}};
401
        print DEST_FILE  "parameter ${parameter_name} = ${parameter_value};\n";
402
        }
403
     }
404
 
405
     #/**********************************************************************/
406
     #/*                                                                    */
407
     #/* Add all internal wires and regs with their sizes                   */
408
     #/*                                                                    */
409
     #/**********************************************************************/
410
 
411
     foreach $x_name (@decl_names)
412
        {
413
        my $q_width  = "     ";
414
        if( $decl_vector{$x_name} eq "vector" ){ $q_width = "[ $decl_lefts{$x_name} :  $decl_rights{$x_name}]"}
415
        if( $decl_dirs{$x_name} eq "node" )    { print DEST_FILE     "$decl_types{$x_name}     $q_width              $decl_pnames{$x_name};\n";}
416
        }
417
 
418
     print DEST_FILE  "\n\n\n";
419 120 jt_eaton
 
420 119 jt_eaton
 
421 120 jt_eaton
     while(   my $line_out      = shift(@instantiations))             {  print DEST_FILE  "$line_out";}
422 119 jt_eaton
 
423
     #/**********************************************************************/
424
     #/*                                                                    */
425
     #/* After all the data from the ip-xact file has been entered we now   */
426
     #/* insert any and all verilog fragments at the end before closing     */
427
     #/* the module                                                         */
428
     #/*                                                                    */
429
     #/**********************************************************************/
430
 
431
 
432
     foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
433
        {
434
        my($rtl_file)       = $i_name ->findnodes('./text()')->to_literal;
435 120 jt_eaton
        my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal;
436 119 jt_eaton
        my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
437
 
438 120 jt_eaton
        if(($file_type eq "fragment")&& (($view_file eq $view_fileset_name)))
439 119 jt_eaton
          {
440
          $SRCFILE ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${rtl_file}";
441
          open(SRCFILE) or die("Could not open src file.  $SRCFILE ");
442
          foreach $line ()
443
             {
444
             chomp($line);
445
             print DEST_FILE  "${line}\n";
446
             }
447
          }
448
        }
449
     unless ($opt_fragment ) {print DEST_FILE  "\n\n\n  endmodule\n\n";}
450 120 jt_eaton
 
451 119 jt_eaton
   }
452
 
453
 
454
 
455
 
456
 
457
 
458
 
459
 
460
 
461
 
462 120 jt_eaton
 
463 119 jt_eaton
#/*********************************************************************************************/
464
#/                                                                                            */
465
#/                                                                                            */
466
#/                                                                                            */
467
#/                                                                                            */
468
#/                                                                                            */
469
#/                                                                                            */
470
#/*********************************************************************************************/
471
 
472
 
473
 
474
 
475
sub parse_busInterface
476
   {
477
   my @params     = @_;
478
   my $depth      = pop(@params);
479
   my $busref     = pop(@params);
480
   my $version    = pop(@params);
481
   my $component  = pop(@params);
482
   my $project    = pop(@params);
483
   my $vendor     = pop(@params);
484
 
485
   my $home = cwd();
486
 
487
   my @out_stack  = ();
488
 
489
 
490
   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
491 120 jt_eaton
   my @spirit_design_files       = yp::lib::find_ipxact_design_files($vendor,$project,$component,$version);
492 119 jt_eaton
 
493 120 jt_eaton
 
494 119 jt_eaton
   my $busInterfaceTest = 0;
495
 
496
   my @mas_slave;
497
     push @mas_slave  , "master";
498
     push @mas_slave  , "slave";
499
 
500
     foreach my $seek_type (@mas_slave)
501
        {
502
 
503
 
504
     foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:${seek_type}"))
505
        {
506
        my($fff_cname)         = $bus_iface->findnodes('../spirit:name/text()')->to_literal ;
507
        my($fff_vendor)        = $bus_iface->findnodes('../spirit:abstractionType/@spirit:vendor')->to_literal ;
508
        my($fff_library)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:library')->to_literal ;
509
        my($fff_name)          = $bus_iface->findnodes('../spirit:abstractionType/@spirit:name')->to_literal ;
510
        my($fff_version)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:version')->to_literal ;
511
        my $fff_variant_name   = "";
512
        if($fff_version)         {$fff_variant_name = "${fff_name}_${fff_version}";}
513
        else                     {$fff_variant_name = "${fff_name}";}
514
 
515
 
516
 
517
 
518
        foreach my $port_face ($spirit_component_file->findnodes('//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort'))
519
           {
520
 
521
           my($fff_xxx_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
522
 
523
           my($fff_log_name)      = $port_face->findnodes('./spirit:name/text()')->to_literal ;
524
           my($fff_phy_name)      = $port_face->findnodes('../spirit:physicalPort/spirit:name/text()')->to_literal ;
525
           my($fff_type_name)     = $port_face->findnodes('../spirit:physicalPort/spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
526
           my($fff_int_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
527
 
528
           my($fff_left_value)    = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
529
           my($fff_right_value)   = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
530
 
531
           unless ($fff_type_name)  {$fff_type_name = "wire";};
532
 
533
           if(  ( $fff_xxx_name  eq  $busref) && (  $busref eq   $fff_cname  )       )
534
             {
535
             $busInterfaceTest = 1;
536
             my $busdef_parser = XML::LibXML->new();
537
 
538
             my $spirit_abstractor_file     = $parser->parse_file(yp::lib::find_ipxact("spirit:abstractionDefinition",$fff_vendor,$fff_library,$fff_name,$fff_version));
539
 
540
 
541
 
542
 
543
             foreach my $abstr_view ($spirit_abstractor_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$fff_log_name']"))
544
                {
545
                my($sss_m_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onMaster/spirit:direction/text()')->to_literal ;
546
                my($sss_s_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onSlave/spirit:direction/text()')->to_literal ;
547
 
548
                    if    ($sss_m_dir eq "in")  { $sss_m_dir = "input";}
549
                    elsif ($sss_m_dir eq "out") { $sss_m_dir = "output";}
550
 
551
                    if    ($sss_s_dir eq "in")  { $sss_s_dir = "input";}
552
                    elsif ($sss_s_dir eq "out") { $sss_s_dir = "output";}
553
 
554
 
555
                my $fff_direction = "";
556
 
557
 
558
                  if    ( $seek_type eq "master")  { $fff_direction = $sss_m_dir;     }
559
                  elsif ( $seek_type eq "slave" )  { $fff_direction = $sss_s_dir;     }
560
 
561
                  my $fff_dir = "";
562
                  if   ($fff_direction  eq "in" )  {$fff_dir = "input" ;}
563
                  elsif($fff_direction  eq "out" ) {$fff_dir = "output" ;}
564
                  else                             {$fff_dir = $fff_direction;     }
565
 
566
                  if($fff_left_value) { push @out_stack, ":::${depth}:::${fff_log_name}:::${fff_phy_name}:::${fff_dir}:::${fff_type_name}:::vector:::${fff_left_value}:::${$fff_right_value}:::"; }
567
                  else                { push @out_stack, ":::${depth}:::${fff_log_name}:::${fff_phy_name}:::${fff_dir}:::${fff_type_name}:::scaler:::none:::none:::";    }
568
 
569
 
570
                }
571
             }
572
 
573
           }
574
       }
575
 
576
}
577
 
578
 
579
 
580
 
581
 
582
       if ( $busInterfaceTest){
583
                              @out_stack      = sys::lib::trim_sort(@out_stack);
584
                              return(@out_stack);
585
                              }
586
 
587
 
588 120 jt_eaton
 
589
 
590
     foreach  my   $sd_file (@spirit_design_files)
591 119 jt_eaton
     {
592
 
593 120 jt_eaton
 
594
     foreach  my   $x_name ($sd_file->findnodes('//spirit:hierConnections/spirit:hierConnection/@spirit:interfaceRef'))
595 119 jt_eaton
        {
596
        my($hierConn_name)                   = $x_name ->to_literal ;
597
        my($hierConn_comref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:componentRef')->to_literal ;
598
        my($hierConn_busref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:busRef')->to_literal ;
599
        if($busref eq  $hierConn_name)
600
          {
601 120 jt_eaton
          foreach  my   $x_name ($sd_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName[text() = '$hierConn_comref_name']"))
602 119 jt_eaton
            {
603
            #/**********************************************************************/
604
            #/*                                                                    */
605
            #/* Lookup VLNV for each instantiated component                        */
606
            #/*                                                                    */
607
            #/**********************************************************************/
608
 
609
            my($vendor_name)         = $x_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
610
            my($library_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
611
            my($component_name)      = $x_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
612
            my($version_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
613
            $depth = $depth +1;
614
            @out_stack = parse_busInterface ($vendor_name, $library_name,$component_name,$version_name,$hierConn_busref_name,$depth );
615
            }
616
          }
617
        }
618 120 jt_eaton
 
619
     }
620
 
621 119 jt_eaton
        @out_stack      = sys::lib::trim_sort(@out_stack);
622
        return(@out_stack);
623 120 jt_eaton
 
624 119 jt_eaton
 
625
   }
626
 
627
 
628
 
629
 
630 120 jt_eaton
 
631
 
632
 
633
 
634
 
635
 
636
 
637
 
638
 
639
 
640 119 jt_eaton
#/*********************************************************************************************/
641
#/                                                                                            */
642
#/                                                                                            */
643
#/                                                                                            */
644
#/                                                                                            */
645
#/                                                                                            */
646
#/                                                                                            */
647
#/*********************************************************************************************/
648
 
649
 
650
 
651
 
652 120 jt_eaton
sub parse_design_files
653
   {
654
   my @params     = @_;
655
   my $spirit_component_file      = pop(@params);
656
 
657
   print "\n";
658
   foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:vendor"))
659
    {
660
    my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
661
    my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
662
    my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
663
    my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
664
#    print "XXXXXX  $new_vendor $new_library $new_name $new_version  COMPONENT \n";
665
    }
666
 
667
 
668
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
669
    {
670
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
671
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
672
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
673
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
674
 
675
 
676
           my $foo = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
677
 
678
#              print "XXXXXZ  $new_vendor $new_library $new_name $new_version $foo\n";
679
 
680
     if($foo eq "spirit:component")
681
     {
682
        parse_design_files($parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_library,$new_name,$new_version )) );
683
     }
684
 
685
     elsif($foo eq "spirit:design")
686
     {
687
        parse_design_file($parser->parse_file(yp::lib::find_ipxact("spirit:design",$new_vendor,$new_library,$new_name,$new_version )) );
688
#              print "XXXXXA+  $new_vendor $new_library $new_name $new_version \n";
689
 
690
      }
691
 
692
     elsif($foo eq "spirit:designConfiguration")
693
     {
694
 
695
        my $spirit_designCfg_file
696
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version ));
697
 
698
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
699
           {
700
           my($hier_xref_vendor)         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
701
           my($hier_xref_library)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
702
           my($hier_xref_component)      = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
703
           my($hier_xref_version)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
704
          parse_design_file($parser->parse_file(yp::lib::find_ipxact("spirit:design",$hier_xref_vendor,$hier_xref_library,$hier_xref_component,$hier_xref_version)));
705
#           print "XXXXXA-  $hier_xref_vendor $hier_xref_library $hier_xref_component $hier_xref_version \n";
706
           }
707
     }
708
 
709
  }
710
 
711
}
712
 
713
 
714
 
715
 
716
 
717
 
718
 
719
#/*********************************************************************************************/
720
#/                                                                                            */
721
#/                                                                                            */
722
#/                                                                                            */
723
#/                                                                                            */
724
#/                                                                                            */
725
#/                                                                                            */
726
#/*********************************************************************************************/
727
 
728
 
729
 
730
 
731
sub process_design_files
732
   {
733
   my @params     = @_;
734
   my $spirit_component_file      = pop(@params);
735
 
736
   print "\n";
737
   foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:vendor"))
738
    {
739
    my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
740
    my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
741
    my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
742
    my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
743
#    print "xXXXXX  $new_vendor $new_library $new_name $new_version  COMPONENT \n";
744
    }
745
 
746
 
747
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
748
    {
749
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
750
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
751
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
752
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
753
 
754
 
755
           my $foo = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
756
 
757
#              print "xXXXXZ  $new_vendor $new_library $new_name $new_version $foo\n";
758
 
759
     if($foo eq "spirit:component")
760
     {
761
        process_design_files($parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_library,$new_name,$new_version )) );
762
     }
763
 
764
     elsif($foo eq "spirit:design")
765
     {
766
        process_design_file($parser->parse_file(yp::lib::find_ipxact("spirit:design",$new_vendor,$new_library,$new_name,$new_version )) );
767
#              print "xXXXXA+  $new_vendor $new_library $new_name $new_version \n";
768
 
769
      }
770
 
771
     elsif($foo eq "spirit:designConfiguration")
772
     {
773
 
774
        my $spirit_designCfg_file
775
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version ));
776
 
777
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
778
           {
779
           my($hier_xref_vendor)         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
780
           my($hier_xref_library)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
781
           my($hier_xref_component)      = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
782
           my($hier_xref_version)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
783
          process_design_file($parser->parse_file(yp::lib::find_ipxact("spirit:design",$hier_xref_vendor,$hier_xref_library,$hier_xref_component,$hier_xref_version)));
784
#           print "xXXXXA-  $hier_xref_vendor $hier_xref_library $hier_xref_component $hier_xref_version \n";
785
           }
786
     }
787
 
788
  }
789
 
790
}
791
 
792
 
793
 
794
 
795
 
796
 
797
 
798
 
799
 
800
 
801
#/*********************************************************************************************/
802
#/                                                                                            */
803
#/                                                                                            */
804
#/                                                                                            */
805
#/                                                                                            */
806
#/                                                                                            */
807
#/                                                                                            */
808
#/*********************************************************************************************/
809
 
810
 
811
 
812
 
813 119 jt_eaton
sub parse_design_file
814
   {
815
   my @params     = @_;
816
   my $spirit_design_file      = pop(@params);
817
 
818
 
819
 
820
 
821 120 jt_eaton
 
822
print "\n";
823
foreach my $new_comp ($spirit_design_file->findnodes("//spirit:design/spirit:vendor"))
824
   {
825
   my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
826
   my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
827
   my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
828
   my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
829
#   print "XXXXXX  $new_vendor $new_library $new_name $new_version  DESIGN \n";
830
   }
831
 
832
 
833
 
834
 
835
 
836
 
837 119 jt_eaton
     #/**********************************************************************/
838
     #/*                                                                    */
839
     #/* Read each hierConnection and enter signals into wire_decs          */
840
     #/*                                                                    */
841
     #/**********************************************************************/
842
     foreach  my   $x_name ($spirit_design_file->findnodes('//spirit:hierConnections/spirit:hierConnection/@spirit:interfaceRef'))
843
        {
844
        my($hierConn_name)                   = $x_name ->to_literal ;
845
        my($hierConn_comref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:componentRef')->to_literal ;
846
        my($hierConn_busref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:busRef')->to_literal ;
847
 
848
        foreach  my   $x_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
849
           {
850
           #/**********************************************************************/
851
           #/*                                                                    */
852
           #/* Lookup VLNV for each instantiated component                        */
853
           #/*                                                                    */
854
           #/**********************************************************************/
855
 
856
           my($instance_name)       = $x_name ->findnodes('./text()')->to_literal ;
857
          my($vendor_name)         = $x_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
858
         my($library_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
859
         my($component_name)      = $x_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
860
         my($version_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
861
 
862
           if( "$instance_name" eq  "$hierConn_comref_name"     )
863
             {
864
             my  @filelist_sub = parse_busInterface($vendor_name, $library_name,$component_name,$version_name,$hierConn_busref_name,"1" );
865
           #/**********************************************************************/
866
           #/*                                                                    */
867
           #/* follow bus all the way to it's source                              */
868
           #/*                                                                    */
869
           #/**********************************************************************/
870
 
871
             foreach $xxline (@filelist_sub)
872
                {
873
                $_ = $xxline;
874
                if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
875
                  {
876
                  $k_depth               = $1;
877
                  $k_log_name            = $2;
878
                  $k_phy_name            = $3;
879
                  $k_direction           = $4;
880
                  $k_type                = $5;
881
                  $k_vector              = $6;
882
                  $k_left                = $7;
883
                  $k_right               = $8;
884
                  push  @wire_decs,":::${hierConn_name}_${k_log_name}:::${hierConn_name}_${k_log_name}:::${k_direction}:::wire:::${k_vector}:::${k_left}:::${k_right}:::${hierConn_comref_name}:::${k_depth}:::${k_phy_name}:::${hierConn_busref_name}:::${k_log_name}:::";
885
                  }
886
                }
887
             }
888
           }
889
        }
890
 
891
 
892
 
893
 
894
 
895
     #/**************************************************************************/
896
     #/*                                                                        */
897
     #/* Read each  interconnection and enter sub signals into wire_decs        */
898
     #/*                                                                        */
899
     #/**************************************************************************/
900
 
901
 
902
 
903
 
904
     foreach  my   $x_name ($spirit_design_file->findnodes('//spirit:interconnections/spirit:interconnection/spirit:activeInterface/@spirit:componentRef'))
905
        {
906
        my($hierConn_comref_name)            = $x_name ->to_literal;
907
        my($hierConn_busref_name)            = $x_name ->findnodes('../@spirit:busRef')->to_literal ;
908
        my($hierConn_name)                   = $x_name ->findnodes('../../spirit:name/text()')->to_literal ;
909
 
910
        foreach  my   $x_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
911
           {
912
           #/**********************************************************************/
913
           #/*                                                                    */
914
           #/* Lookup VLNV for each instantiated component                        */
915
           #/*                                                                    */
916
           #/**********************************************************************/
917
 
918
           my($instance_name)       = $x_name ->findnodes('./text()')->to_literal ;
919
           my($vendor_name)         = $x_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
920
           my($library_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
921
           my($component_name)      = $x_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
922
           my($version_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
923
 
924
 
925
 
926
           my $variant_name   = "";
927
           if($version_name)  {$variant_name = "${component_name}_${version_name}";}
928
           else               {$variant_name = "${component_name}";}
929
 
930
           if( "$instance_name" eq  "$hierConn_comref_name"     )
931
             {
932
 
933
 
934
 
935
           #/**********************************************************************/
936
           #/*                                                                    */
937
           #/* follow bus all the way to it's source                              */
938
           #/*                                                                    */
939
           #/**********************************************************************/
940
 
941
 
942
             my  @filelist_sub = parse_busInterface($vendor_name, $library_name,$component_name,$version_name,$hierConn_busref_name,"1" );
943
             foreach $xxline (@filelist_sub)
944
                {
945
 
946
 
947
                $_ = $xxline;
948
                if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
949
                  {
950
                  $k_depth               = $1;
951
                  $k_log_name            = $2;
952
                  $k_phy_name            = $3;
953
                  $k_direction           = $4;
954
                  $k_type                = $5;
955
                  $k_vector              = $6;
956
                  $k_left                = $7;
957
                  $k_right               = $8;
958
 
959
 
960
                  push  @wire_decs,":::${hierConn_name}_${k_log_name}:::${hierConn_name}_${k_log_name}:::node:::wire:::${k_vector}:::${k_left}:::${k_right}:::${hierConn_comref_name}:::${k_depth}:::${k_phy_name}:::${hierConn_busref_name}:::${k_log_name}:::";
961
                  }
962
                }
963
             }
964
           }
965
        }
966
 
967
 
968
 
969
     #/*******************************************************************************/
970
     #/*                                                                             */
971
     #/* Read each  interconnection and enter modified signals into wire_decs        */
972
     #/*                                                                             */
973
     #/*******************************************************************************/
974
 
975
 
976
 
977
 
978
 
979
        foreach  my  $k_name ($spirit_design_file->findnodes('//spirit:interconnections/spirit:interconnection/spirit:activeInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort/spirit:name'))
980
           {
981
           my($lp_name)                = $k_name ->to_literal;
982
           my($lp_pname)               = $k_name ->findnodes('../../spirit:physicalPort/spirit:name/text()')->to_literal ;
983
           my($lp_left)                = $k_name ->findnodes('../../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
984
           my($lp_right)               = $k_name ->findnodes('../../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
985
           my($lp_componentref_name)   = $k_name ->findnodes('../../../../@spirit:componentRef')->to_literal ;
986
           my($lp_busref_name)         = $k_name ->findnodes('../../../../@spirit:busRef')->to_literal ;
987
           my($lp_interconnect_name)   = $k_name ->findnodes('../../../../../spirit:name/text()')->to_literal ;
988
 
989
 
990
           if ( $lp_pname eq '' ) { $lp_pname ="${lp_interconnect_name}_${lp_name}";}
991
           if ( $lp_left  eq '' ) { $lp_left ="none";}
992
           if ( $lp_right eq '' ) { $lp_right ="none";}
993
 
994
 
995
 
996
          if ( $lp_left  eq 'none' )
997
          {
998
           push  @wire_decs,":::${lp_interconnect_name}_${lp_name}:::${lp_pname}:::node:::wire:::scaler:::none:::none:::${lp_componentref_name}:::0:::${lp_interconnect_name}_${lp_name}:::${lp_busref_name}:::${lp_pname}:::";
999
          }
1000
          else
1001
          {
1002
           push  @wire_decs,":::${lp_interconnect_name}_${lp_name}:::${lp_pname}:::node:::wire:::vector:::${lp_left}:::${lp_right}:::${lp_componentref_name}:::0:::${lp_interconnect_name}_${lp_name}:::${lp_busref_name}:::${lp_pname}:::";
1003
          }
1004
           }
1005
 
1006
 
1007
 
1008
 
1009
 
1010
 
1011
 
1012
 
1013
 
1014
 
1015
 
1016
     #/**********************************************************************/
1017
     #/*                                                                    */
1018
     #/* Read all adHocConnections and load instance connect info into array*/
1019
     #/*                                                                    */
1020
     #/**********************************************************************/
1021
 
1022
 
1023
     foreach  my   $i_xame ($spirit_design_file->findnodes('//spirit:adHocConnections/spirit:adHocConnection/spirit:internalPortReference/@spirit:componentRef'))
1024
        {
1025
        my($comp_name)    = $i_xame ->to_literal;
1026
        my($int_value)    = $i_xame ->findnodes('../../spirit:name/text()')->to_literal ;
1027
        my($int_name)     = $i_xame ->findnodes('../@spirit:portRef')->to_literal ;
1028
        my($vec_left)     = $i_xame ->findnodes('../@spirit:left')->to_literal ;
1029
        my($vec_right)    = $i_xame ->findnodes('../@spirit:right')->to_literal ;
1030
 
1031
        if($vec_left ne "")
1032
          {
1033
          my $vecs = "";
1034
          if($vec_left ne $vec_right ){$vecs ="[${vec_left}:${vec_right}]";}
1035
          else                        {$vecs ="[${vec_right}]";}
1036
          push @inst_conns , ":::${comp_name}:::adhoc:::${int_name}:::${int_value}:::vector:::${vec_left}:::${vec_right}:::";
1037
          }
1038
        else
1039
          {
1040
          push @inst_conns , ":::${comp_name}:::adhoc:::${int_name}:::${int_value}:::scaler:::none:::none:::";
1041
          }
1042
        }
1043
 
1044
 
1045
 
1046
     #/**********************************************************************/
1047
     #/*                                                                    */
1048
     #/* Add all internal wires and regs with their sizes                   */
1049
     #/*                                                                    */
1050
     #/**********************************************************************/
1051
 
1052
     foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/nodes/node/spirit:name"))
1053
        {
1054
        my($node_name)  = $i_name ->findnodes('./text()')->to_literal ;
1055
        my($left)            = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1056
        my($right)           = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1057
        my($type)            = $i_name ->findnodes('../spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
1058
 
1059
        if($left)      { push @wire_decs , ":::${node_name}:::${node_name}:::node:::${type}:::vector:::${left}:::${$right}:::none:::0:::${node_name}:::XXX:::${node_name}:::"; }
1060
        else           { push @wire_decs , ":::${node_name}:::${node_name}:::node:::${type}:::scaler:::none:::none:::none:::0:::${node_name}:::XXX:::${node_name}:::";   }
1061
 
1062
        }
1063
 
1064
 
1065
 
1066
 
1067
 
1068
 
1069
 
1070
 
1071
 
1072
 
1073
 
1074
 
1075
 
1076
     #/**********************************************************************/
1077
     #/*                                                                    */
1078
     #/* extract bus instance connections from wire_decs                    */
1079
     #/*                                                                    */
1080
     #/**********************************************************************/
1081
 
1082
     print "+-+";
1083
 
1084
 
1085
 
1086
     my @inst_names  = ();
1087
     my @inst_Inames  = ();
1088
     my %inst_ports  = ();
1089
     my %inst_sigs   = ();
1090
     my %inst_vector = ();
1091
     my %inst_left   = ();
1092
     my %inst_right  = ();
1093
 
1094
 
1095
     foreach $line (@wire_decs)
1096
        {
1097
        $_ = $line;
1098
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1099
          {
1100
          my $t_index               = $1;
1101
          my $t_node_name           = $2;
1102
          my $t_direction           = $3;
1103
          my $t_type                = $4;
1104
          my $t_vector              = $5;
1105
          my $t_left                = $6;
1106
          my $t_right               = $7;
1107
          my $t_instance            = $8;
1108
          my $t_depth               = $9;
1109
          my $t_phy_name            = $10;
1110
          my $t_busref_name         = $11;
1111
          my $t_abslog_name         = $12;
1112
 
1113
        if( 1)
1114
          {
1115
 
1116
         push ( @inst_names, "${t_instance}_${t_busref_name}_${t_index}");
1117
 
1118
         $inst_Inames{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_instance}";
1119
 
1120
         if(  $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"})
1121
            {
1122
            if(  $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"} eq ${t_index})
1123
              {
1124
              $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_node_name}";
1125
              }
1126
            }
1127
         else
1128
            {
1129
            $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_node_name}";
1130
            }
1131
 
1132
         if   ($t_depth >= 2 )      { $inst_ports{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_busref_name}_${t_abslog_name}" ;}
1133
         elsif($t_depth == 1 )      { $inst_ports{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_phy_name}";}
1134
 
1135
         if(  $inst_vector{"${t_instance}_${t_busref_name}_${t_index}"})
1136
            {
1137
            if(  $inst_vector{"${t_instance}_${t_busref_name}_${t_index}"} eq "scaler")
1138
              {$inst_vector{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_vector}";}
1139
            }
1140
         else
1141
            {$inst_vector{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_vector}";}
1142
 
1143
         unless(  $inst_left{"${t_instance}_${t_busref_name}_${t_index}"} eq '')
1144
            {
1145
            if(  $inst_left{"${t_instance}_${t_busref_name}_${t_index}"} eq "none")
1146
              {
1147
              $inst_left{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_left}";
1148
              }
1149
            elsif(  $inst_left{"${t_instance}_${t_busref_name}_${t_index}"} < ${t_left})
1150
              {
1151
              $inst_left{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_left}";
1152
              }
1153
            }
1154
          else
1155
            {
1156
            $inst_left{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_left}";
1157
            }
1158
 
1159
          unless(  $inst_right{"${t_instance}_${t_busref_name}_${t_index}"} eq '')
1160
            {
1161
            if(  $inst_right{"${t_instance}_${t_busref_name}_${t_index}"} eq "none")
1162
              {
1163
              $inst_right{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_right}";
1164
              }
1165
            elsif(  $inst_right{"${t_instance}_${t_busref_name}_${t_index}"} < ${t_right})
1166
              {
1167
              $inst_right{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_right}";
1168
              }
1169
            }
1170
          else {$inst_right{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_right}";}
1171
 
1172
        }
1173
      }
1174
     }
1175
     @inst_names = sys::lib::trim_sort(@inst_names);
1176
     foreach $i_name (@inst_names)
1177
         {
1178
        unless($inst_Inames{$i_name} eq "none")
1179
         {
1180
         if($inst_vector{$i_name} eq "vector"  )
1181
           {
1182
          push @inst_conns ,":::$inst_Inames{$i_name}:::adhoc:::$inst_ports{$i_name}:::$inst_sigs{$i_name}:::vector:::$inst_left{$i_name}:::$inst_right{$i_name}:::\n";
1183
          }
1184
        else
1185
          {
1186
          push @inst_conns ,":::$inst_Inames{$i_name}:::adhoc:::$inst_ports{$i_name}:::$inst_sigs{$i_name}:::scaler:::none:::none:::\n";
1187
 
1188
           }
1189
         }
1190
         }
1191 120 jt_eaton
     }
1192 119 jt_eaton
 
1193
 
1194
 
1195
 
1196
 
1197
 
1198
 
1199
 
1200
 
1201 120 jt_eaton
#/*********************************************************************************************/
1202
#/                                                                                            */
1203
#/                                                                                            */
1204
#/                                                                                            */
1205
#/                                                                                            */
1206
#/                                                                                            */
1207
#/                                                                                            */
1208
#/*********************************************************************************************/
1209 119 jt_eaton
 
1210
 
1211
 
1212
 
1213 120 jt_eaton
sub process_design_file
1214
   {
1215
   my @params     = @_;
1216
   my $spirit_design_file      = pop(@params);
1217 119 jt_eaton
 
1218
 
1219
 
1220
 
1221
 
1222 120 jt_eaton
print "\n";
1223
foreach my $new_comp ($spirit_design_file->findnodes("//spirit:design/spirit:vendor"))
1224
   {
1225
   my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
1226
   my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
1227
   my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
1228
   my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
1229
#   print "XXXXXX-  $new_vendor $new_library $new_name $new_version  DESIGN \n";
1230
   }
1231 119 jt_eaton
 
1232
 
1233
 
1234
     #/**********************************************************************/
1235
     #/*                                                                    */
1236
     #/* Instantiate each component with parameters and port connections    */
1237
     #/*                                                                    */
1238
     #/* If the component doesn't have a instance name then this is skipped */
1239
     #/*                                                                    */
1240
     #/**********************************************************************/
1241
 
1242
     print "+-+";
1243
 
1244
     push @instantiations  , "////////////////////////////////////////////////////////////////\n";
1245
 
1246
     foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
1247
        {
1248
        my($instance_name)       = $i_name ->findnodes('./text()')->to_literal ;
1249
        my($component_name)      = $i_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
1250
        my($version_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
1251
        my $variant_name   = "";
1252
        if($version_name)  {$variant_name = "${component_name}_${version_name}";}
1253
        else               {$variant_name = "${component_name}";}
1254
 
1255
        if($instance_name)
1256
          {
1257
          push @instantiations  , "$variant_name\n";
1258
 
1259
#     print "$instance_name \n";
1260
 
1261
          $first = 1;
1262
 
1263
          foreach  my   $i_parameter ($spirit_design_file->findnodes("//spirit:componentInstance[spirit:instanceName/text() = '$instance_name']/spirit:configurableElementValues/spirit:configurableElementValue/\@spirit:referenceId"))
1264
             {
1265
             my($foo_name)       = $i_parameter ->to_literal ;
1266
             my($foo_value)      = $i_parameter ->findnodes('../text()')->to_literal ;
1267
             if($first)
1268
               {
1269
               push @instantiations  , "#( .${foo_name} (${foo_value})";
1270
               $first = 0;
1271
               }
1272
             else  {push @instantiations  , ",\n   .${foo_name} (${foo_value})";}
1273
             }
1274
 
1275
             if($first == 0)  { push @instantiations  , ")\n";}
1276
             push @instantiations  , "$instance_name \n   (\n ";
1277
             $first = 1;
1278
              @per_inst = sys::lib::trim_sort(@inst_conns);
1279
 
1280
             foreach $line (@per_inst)
1281
                {
1282
                $_ = $line;
1283
 
1284
                if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1285
                  {
1286
                  my $z_instance_name           = $1;
1287
                  my $z_busRef_name   = $2;
1288
                  my $z_port_name           = $3;
1289
                  my $z_signal_name           = $4;
1290
                  my $z_vecscal           = $5;
1291
                  my $z_left           = $6;
1292
                  my $z_right           = $7;
1293
                  if($z_vecscal eq "vector")
1294
                    {
1295
                    if($z_left eq $z_right){$z_signal_name =  "${z_signal_name}[${z_left}]" ;}
1296
                    else    {$z_signal_name =  "${z_signal_name}[${z_left}:${z_right}]" ;}
1297
                    }
1298
                  if($instance_name eq  $z_instance_name )
1299
                    {
1300
                    if($first)
1301
                      {
1302
                      push @instantiations  ,          "  .${z_port_name}         (${z_signal_name})";
1303
                      $first =0;
1304
                      }
1305
                    else   {           push @instantiations  , ",\n   .${z_port_name}         (${z_signal_name})";}
1306
                    }
1307
                  }
1308
                }
1309
 
1310
     print ".";
1311
     push @instantiations  , ");\n\n";
1312
     }
1313
     }
1314
     }
1315
 
1316
 
1317
 
1318
 
1319
 
1320
 
1321
 
1322 120 jt_eaton
 
1323
 
1324 119 jt_eaton
#/*********************************************************************************************/
1325
#/                                                                                            */
1326
#/                                                                                            */
1327
#/                                                                                            */
1328
#/                                                                                            */
1329
#/                                                                                            */
1330
#/                                                                                            */
1331
#/*********************************************************************************************/
1332
 
1333
 
1334
 
1335
 
1336
sub parse_component_file
1337
   {
1338
   my @params     = @_;
1339
   my $spirit_component_file      = pop(@params);
1340
 
1341
 
1342
 
1343
 
1344 120 jt_eaton
print "\n";
1345
foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:vendor"))
1346
   {
1347
   my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
1348
   my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
1349
   my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
1350
   my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
1351
#   print "XXXXXX  $new_vendor $new_library $new_name $new_version  COMPONENT \n";
1352
   }
1353
 
1354
 
1355
 
1356
 
1357
foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
1358
   {
1359
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
1360
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
1361
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
1362
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
1363
 
1364
 
1365
             my $foo = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
1366
 
1367
#              print "XXXXXZ  $new_vendor $new_library $new_name $new_version $foo\n";
1368
 
1369
     if($foo eq "spirit:component")
1370
     {
1371
     my $spirit_sub_component_file           = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_library,$new_name,$new_version));
1372
     parse_component_file($spirit_sub_component_file);
1373
     }
1374
 
1375
     elsif($foo eq "spirit:design")
1376
     {
1377
 
1378
 
1379
      }
1380
 
1381
     elsif($foo eq "spirit:designConfiguration")
1382
     {
1383
 
1384
        my $spirit_designCfg_file
1385
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version ));
1386
 
1387
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
1388
           {
1389
           my($hier_xref_vendor)         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
1390
           my($hier_xref_library)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
1391
           my($hier_xref_component)      = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
1392
           my($hier_xref_version)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
1393
 
1394
           my $spirit_design_file           = $parser->parse_file(yp::lib::find_ipxact("spirit:design",$hier_xref_vendor,$hier_xref_library,$hier_xref_component,$hier_xref_version));
1395
 
1396
#              print "XXXXXA  $hier_xref_vendor $hier_xref_library $hier_xref_component $hier_xref_version \n";
1397
           }
1398
     }
1399
 
1400
  }
1401
 
1402
 
1403
 
1404 119 jt_eaton
     #/**********************************************************************/
1405
     #/*                                                                    */
1406
     #/* Read each  busInterface and save master/slave direction            */
1407
     #/*                                                                    */
1408
     #/**********************************************************************/
1409
 
1410
     my @mas_slave;
1411
 
1412
     push @mas_slave  , "master";
1413
     push @mas_slave  , "slave";
1414
 
1415
     foreach $seek_type (@mas_slave)
1416
        {
1417
 
1418
         foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:${seek_type}"))
1419
            {
1420
            my($mmm_cname)         = $bus_iface->findnodes('../spirit:name/text()')->to_literal ;
1421
            my($mmm_vendor)        = $bus_iface->findnodes('../spirit:abstractionType/@spirit:vendor')->to_literal ;
1422
            my($mmm_library)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:library')->to_literal ;
1423
            my($mmm_name)          = $bus_iface->findnodes('../spirit:abstractionType/@spirit:name')->to_literal ;
1424
            my($mmm_version)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:version')->to_literal ;
1425
 
1426
            foreach my $port_face ($spirit_component_file->findnodes('//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort'))
1427
               {
1428
               my($rrr_log_name)      = $port_face->findnodes('./spirit:name/text()')->to_literal ;
1429
               my($rrr_phy_name)      = $port_face->findnodes('../spirit:physicalPort/spirit:name/text()')->to_literal ;
1430
               my($rrr_type_name)     = $port_face->findnodes('../spirit:physicalPort/spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
1431
               my($rrr_int_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
1432
               my($rrr_left_value)    = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1433
               my($rrr_right_value)   = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1434
 
1435
               unless ($rrr_type_name)  {$rrr_type_name = "wire";}
1436
 
1437
               if(   $mmm_cname  eq  $rrr_int_name )
1438
                 {
1439
 
1440
                 my $busdef_parser = XML::LibXML->new();
1441
                 my $spirit_abstractor_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:abstractionDefinition",$mmm_vendor,$mmm_library,$mmm_name,$mmm_version));
1442
 
1443
                 foreach my $abstr_view ($spirit_abstractor_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$rrr_log_name']"))
1444
                    {
1445
                    my($sss_m_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onMaster/spirit:direction/text()')->to_literal ;
1446
                    my($sss_s_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onSlave/spirit:direction/text()')->to_literal ;
1447
 
1448
                    if    ($sss_m_dir eq "in")  { $sss_m_dir = "input";}
1449
                    elsif ($sss_m_dir eq "out") { $sss_m_dir = "output";}
1450
 
1451
                    if    ($sss_s_dir eq "in")  { $sss_s_dir = "input";}
1452
                    elsif ($sss_s_dir eq "out") { $sss_s_dir = "output";}
1453
 
1454
                    my $rrr_direction = "";
1455
 
1456
                    if( $seek_type eq "master") {        $rrr_direction = $sss_m_dir;}
1457
                    else                        {        $rrr_direction = $sss_s_dir;}
1458
 
1459
                    my $rrr_dir = "";
1460
                    if   ($rrr_direction  eq "in" )  {$rrr_dir = "input" ;}
1461
                    elsif($rrr_direction  eq "out" ) {$rrr_dir = "output" ;}
1462
                    else                             {$rrr_dir = $rrr_direction;     }
1463
 
1464
                    if($rrr_left_value)
1465
                        {
1466
                        push @wire_decs , ":::${mmm_cname}_${rrr_log_name}:::${rrr_phy_name}:::${rrr_dir}:::${rrr_type_name}:::vector:::${rrr_left_value}:::${$rrr_right_value}:::none:::0:::${rrr_phy_name}:::XXX:::${rrr_log_name}:::";
1467
                        }
1468
                      else
1469
                        {
1470
                        push @wire_decs , ":::${mmm_cname}_${rrr_log_name}:::${rrr_phy_name}:::${rrr_dir}:::${rrr_type_name}:::scaler:::none:::none:::none:::0:::${rrr_phy_name}:::XXX:::${rrr_log_name}:::";
1471
                        }
1472
                    }
1473
                 }
1474
               }
1475
        }
1476
     }
1477
 
1478
 
1479
 
1480
 
1481
     #/**********************************************************************/
1482
     #/*                                                                    */
1483
     #/* Read all ports and store into array                                */
1484
     #/*                                                                    */
1485
     #/**********************************************************************/
1486
 
1487
     foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:ports/spirit:port/spirit:name"))
1488
        {
1489
        my($port_name)       = $i_name ->findnodes('./text()')->to_literal ;
1490
        my($direction)       = $i_name ->findnodes('../spirit:wire/spirit:direction/text()')->to_literal ;
1491
        my($left)            = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1492
        my($right)           = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1493
        my($type)            = $i_name ->findnodes('../spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
1494
 
1495
 
1496
        if    ($direction eq "in")  { $direction = "input";}
1497
        elsif ($direction eq "out") { $direction = "output";}
1498
 
1499
 
1500
        if($left)  { push @wire_decs , ":::${port_name}:::${port_name}:::${direction}:::${type}:::vector:::${left}:::${right}:::none:::0:::${port_name}:::XXX:::${port_name}:::";  }
1501
        else       { push @wire_decs , ":::${port_name}:::${port_name}:::${direction}:::${type}:::scaler:::none:::none:::none:::0:::${port_name}:::XXX:::${port_name}:::";          }
1502
        }
1503
 
1504
 
1505
 
1506
 
1507
}
1508
 
1509
 
1510
1
1511
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.