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

Subversion Repositories socgen

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

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 121 jt_eaton
           "fragment","no_port","local_parameters","tb"
77 119 jt_eaton
) || die "(use '$program_name -h' for help)";
78
 
79
 
80
##############################################################################
81
## Help option
82
##############################################################################
83
if ( $opt_h  or $opt_help  )
84
  { 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";
85
    print "\n";
86
    exit 1;
87
  }
88
 
89
print "\n  GEN_verilog  $view  $prefix $vendor $project $component $version    $dest_dir  $destination \n";
90
 
91 122 jt_eaton
my $main_module_name = yp::lib::get_module_name($vendor,$project,$component,$version) ;
92 119 jt_eaton
 
93 125 jt_eaton
 
94
 
95
 
96 119 jt_eaton
#############################################################################
97
##
98
##
99
#############################################################################
100
 
101
 
102
$home = cwd();
103
my $variant;
104
 if($version)       {$variant   = "${component}_${version}";}
105
 else               {$variant   = "${component}";}
106
 
107
 
108 120 jt_eaton
 
109
 
110 125 jt_eaton
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$project);
111
my $comp_xml_sep    = yp::lib::find_ipxact_component_path("spirit:component",$vendor,$project,$component,$version);
112 121 jt_eaton
 
113 125 jt_eaton
 
114
 
115
 
116
my $parser = XML::LibXML->new();
117
 
118
 
119
my $path  = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}";
120
mkdir $path,0755             unless( -e $path );
121
 
122
my $path  = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}";
123
mkdir $path,0755             unless( -e $path );
124
 
125
my   @filelist_hier     =       ();
126
my   @instantiations    =       ();
127
my   @parameters        =       ();
128
my   %parameter_values  =       ();
129
 
130
print  "  Building verilog for ${project} ${component}  ${variant} \n  ";
131
my $sogen_file               = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
132
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
133
 
134
 
135
 
136
my $lib_sim_sep              = $sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
137
 
138
#print "XXXXXXX \n";
139
#print "XXXXXXX.  ${home}/projects/${vendor}/${project}/ip/${component}/sim \n";
140
#print "XXXXXXX   ${home}/projects/${vendor}/${project}${lib_sim_sep} \n";
141
 
142
 
143
 
144
 
145
#if( ($prefix eq "/work")  && ($lib_sim_sep)         ){$opt_tb = 1;}
146
 
147
 
148 121 jt_eaton
if($opt_tb )
149
{
150
   print "Creating testbench for   $vendor $project $component  $version \n";
151
 
152
 
153 125 jt_eaton
   my $path  ="${home}/projects/${vendor}/${project}${lib_sim_sep}";
154 121 jt_eaton
   mkdir $path,0755             unless( -e $path );
155
 
156 125 jt_eaton
   my $path  ="${home}/projects/${vendor}/${project}${lib_sim_sep}/testbenches";
157 121 jt_eaton
   mkdir $path,0755             unless( -e $path );
158
 
159 125 jt_eaton
      $path  ="${home}/projects/${vendor}/${project}${lib_sim_sep}/testbenches/xml";
160 124 jt_eaton
   mkdir $path,0755             unless( -e $path );
161 121 jt_eaton
 
162 124 jt_eaton
 
163
   $outfile ="${home}/projects/${vendor}/${project}/ip/${component}/sim/testbenches/xml/${variant}_dut.params.xml";
164 121 jt_eaton
   open TB_COMP_FILE,">$outfile" or die "unable to open $outfile";
165
 
166 124 jt_eaton
   $outfile ="${home}/projects/${vendor}/${project}/ip/${component}/sim/testbenches/xml/${variant}_dutg.design.xml";
167 121 jt_eaton
   open TB_DESIGN_FILE,">$outfile" or die "unable to open $outfile";
168
 
169 122 jt_eaton
 
170 121 jt_eaton
   print TB_COMP_FILE  "\n";
171 122 jt_eaton
   print TB_COMP_FILE  "                                                 \n";
178 121 jt_eaton
   print TB_COMP_FILE  "
179
   print TB_COMP_FILE  "xmlns:spirit=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\"\n";
180 125 jt_eaton
   print TB_COMP_FILE  "xmlns:socgen=\"http://opencores.org\"\n";
181 121 jt_eaton
   print TB_COMP_FILE  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
182
   print TB_COMP_FILE  "xsi:schemaLocation=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\n";
183
   print TB_COMP_FILE  "http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009/index.xsd\">\n";
184
   print TB_COMP_FILE  "${vendor}\n";
185
   print TB_COMP_FILE  "${project}\n";
186
   print TB_COMP_FILE  "${component}\n";
187
   print TB_COMP_FILE  "${version}_dut.params\n";
188
 
189
 
190
   print TB_DESIGN_FILE  "\n";
191 122 jt_eaton
   print TB_DESIGN_FILE  "                                                 \n";
198 121 jt_eaton
   print TB_DESIGN_FILE  "
199
   print TB_DESIGN_FILE  "xmlns:spirit=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\"\n";
200 125 jt_eaton
   print TB_DESIGN_FILE  "xmlns:socgen=\"http://opencores.org\"\n";
201 121 jt_eaton
   print TB_DESIGN_FILE  "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
202
   print TB_DESIGN_FILE  "xsi:schemaLocation=\"http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009\n";
203
   print TB_DESIGN_FILE  "http://www.spiritconsortium.org/XMLSchema/SPIRIT/1685-2009/index.xsd\">\n";
204
   print TB_DESIGN_FILE  "${vendor}\n";
205
   print TB_DESIGN_FILE  "${project}\n";
206
   print TB_DESIGN_FILE  "${component}\n";
207
   print TB_DESIGN_FILE  "${version}_dutg.design\n";
208
 
209
}
210
 
211
 
212
     #/**********************************************************************/
213
     #/*                                                                    */
214 124 jt_eaton
     #/* if configuration set then read parameters from socgen:componentConfiguration file      */
215 121 jt_eaton
     #/*                                                                    */
216
     #/**********************************************************************/
217
 
218
    if($configuration)
219
      {
220
      # print "XXX Reading configuration   $configuration \n";
221 124 jt_eaton
      unless ($sogen_file)      { print "No socgen ip file \n";};
222 121 jt_eaton
 
223 124 jt_eaton
      foreach my $socgen_cfg ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:configurations/socgen:configuration/socgen:parameters/socgen:parameter/socgen:name"))
224 121 jt_eaton
                {
225
                my($param_name)         = $socgen_cfg->findnodes('./text()')->to_literal ;
226
                my($param_value)        = $socgen_cfg->findnodes('../socgen:value/text()')->to_literal ;
227
                my($config_name)        = $socgen_cfg->findnodes('../../../socgen:name/text()')->to_literal ;
228
                if($config_name eq $configuration  )
229
                  {
230
                  unless(defined $parameter_values{$param_name}) {push ( @parameters,  "$param_name");};
231
                  $parameter_values{$param_name} = ${param_value};
232
                  }
233
                }
234
 
235
      }
236
 
237
 
238
 
239
 
240 119 jt_eaton
#/**********************************************************************/
241
#/*                                                                    */
242
#/* Every hier cell is constructed from the ipxact file with seperate  */
243
#/* version  for each view                                             */
244
#/*                                                                    */
245
#/* Start by opening the output file                                   */
246
#/* get fileset name                                                   */
247
#/* check that requested view exists                                   */
248
#/*                                                                    */
249
#/**********************************************************************/
250
 
251 120 jt_eaton
foreach my $comp_view ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:name[text() = '$view']"             ))
252 119 jt_eaton
   {
253 120 jt_eaton
   my($view_fileset_name)  = $comp_view->findnodes('../spirit:fileSetRef/spirit:localName/text()')->to_literal ;
254
   $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}/${destination}";
255
   open DEST_FILE,">$outfile" or die "unable to open $outfile";
256 122 jt_eaton
   unless ($opt_fragment){     print DEST_FILE  "\n module \n\n  $main_module_name \n ";}
257 119 jt_eaton
 
258 120 jt_eaton
   #/*****************************************************************************/
259
   #/*  wire_decs array holds all port and signal declarations                   */
260
   #/*  :::name:::node_input_output:::wire_reg:::scaler_vector:::left:::right::: */
261
   #/*****************************************************************************/
262 119 jt_eaton
 
263 120 jt_eaton
   @wire_decs = (  );
264 119 jt_eaton
 
265
 
266 120 jt_eaton
   #/**********************************************************************/
267
   #/*  inst_conns holds all instance connections                         */
268
   #/**********************************************************************/
269 119 jt_eaton
 
270 120 jt_eaton
   @inst_conns = (  );
271 119 jt_eaton
 
272 120 jt_eaton
   my @decl_names  = ();
273
   my %decl_dirs  = ();
274
   my %decl_types  = ();
275
   my %decl_vector = ();
276
   my %decl_lefts  = ();
277
   my %decl_rights = ();
278 119 jt_eaton
 
279 120 jt_eaton
   #  component file
280
   parse_component_file($spirit_component_file);
281
   parse_design_files($spirit_component_file);
282
   process_design_files($spirit_component_file);
283 119 jt_eaton
 
284 120 jt_eaton
   #/**********************************************************************/
285
   #/*                                                                    */
286
   #/* pack ports and nodes into hashes                                   */
287
   #/*                                                                    */
288
   #/**********************************************************************/
289 119 jt_eaton
 
290
 
291 120 jt_eaton
   @wire_decs      = sys::lib::trim_sort(@wire_decs);
292
   foreach $line (@wire_decs)
293
     {
294
     $_ = $line;
295 119 jt_eaton
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
296
          {
297
          $q_index               = $1;
298
          $q_node_name           = $2;
299
          $q_direction           = $3;
300
          $q_type                = $4;
301
          $q_vector              = $5;
302
          $q_left                = $6;
303
          $q_right               = $7;
304
          $q_instance            = $8;
305
          $q_depth               = $9;
306
          $q_phy_name            = $10;
307
          $q_busref_name         = $11;
308
          $q_abslog_name         = $12;
309
 
310
         push ( @decl_names,$q_index);
311
 
312
 
313
          if(  $decl_pnames{$q_index})
314
            {
315
            if(  $decl_pnames{$q_index} eq ${q_index})
316
              {
317
              $decl_pnames{$q_index}  = "${q_node_name}";
318
              }
319
            }
320
          else
321
            {
322
            $decl_pnames{$q_index}  = "${q_node_name}";
323
            }
324
 
325
 
326
          if(  $decl_dirs{$q_index})
327
            {
328
            if(  $decl_dirs{$q_index} eq "node")
329
              {
330
              $decl_types{$q_index}  = "${q_type}";
331
              $decl_dirs{$q_index}  = "${q_direction}";
332
              }
333
            }
334
          else
335
            {
336
            $decl_types{$q_index}  = "${q_type}";
337
            $decl_dirs{$q_index}  = "${q_direction}";
338
            }
339
 
340
          if(  $decl_vector{$q_index})
341
            {  unless(  $decl_vector{$q_index} eq "vector"){ $decl_vector{$q_index}  = "${q_vector}";  }}
342
          else  { $decl_vector{$q_index}  = "${q_vector}"; }
343
 
344
          if( $q_vector eq "vector" )
345
            {
346
            if ( defined $decl_lefts{$q_index})
347
               {
348
               if($decl_lefts{$q_index}   <= $q_left  ) {$decl_lefts{$q_index}   = $q_left;}
349
               if($decl_rights{$q_index}  >= $q_right ) {$decl_rights{$q_index}  = $q_right;}
350
               }
351
            else
352
               {
353
               $decl_lefts{$q_index}   = $q_left;
354
               $decl_rights{$q_index}  = $q_right;
355
               }
356
            }
357
          }
358
        }
359
     @decl_names      = sys::lib::trim_sort(@decl_names);
360
 
361
 
362
 
363
 
364
 
365
     #/**********************************************************************/
366
     #/*                                                                    */
367
     #/* All port and signal info is now loaded in hashes, print out verilog*/
368
     #/*                                                                    */
369
     #/* Print out module header , parameters and ports                     */
370
     #/*                                                                    */
371
     #/**********************************************************************/
372
 
373
 
374
 
375
 
376 120 jt_eaton
 
377 119 jt_eaton
 
378
     #/**********************************************************************/
379
     #/*                                                                    */
380
     #/* Add any and all global parameters with their default values        */
381
     #/*                                                                    */
382
     #/**********************************************************************/
383
 
384
     unless ($opt_local_parameters)
385
     {
386
     my $first = 1;
387
     foreach my $parameter_name (@parameters)
388
        {
389
        my $parameter_value = $parameter_values{$parameter_name};
390
        if($first)
391
          {
392
          print DEST_FILE  "   #( parameter \n      ${parameter_name}=${parameter_value}";
393
          $first=0;
394
          }
395
        else  { print DEST_FILE  ",\n      ${parameter_name}=${parameter_value}";}
396
        }
397
 
398
     if    ($first == 0)   { print DEST_FILE  ")\n"; }
399
       }
400
 
401
 
402
     #/**********************************************************************/
403
     #/*                                                                    */
404
     #/* sort all  ports  with their type, size and direction               */
405
     #/*                                                                    */
406
     #/**********************************************************************/
407
 
408
 
409
     my @port_list  = ();
410
 
411
 
412
     foreach $x_name (@decl_names)
413
        {
414
        my $q_width  = "     ";
415
        if( $decl_vector{$x_name} eq "vector" )  { $q_width = "[ $decl_lefts{$x_name} :  $decl_rights{$x_name}]"}
416
 
417
        if( $decl_dirs{$x_name} ne "node" )
418
          {
419
          push (@port_list,  "$decl_dirs{$x_name}   $decl_types{$x_name}    $q_width        $decl_pnames{$x_name}");
420
          }
421
        }
422
 
423
     @port_list      = sys::lib::trim_sort(@port_list);
424
 
425
 
426
     #/**********************************************************************/
427
     #/*                                                                    */
428
     #/* Now add all ports  with their type, size and direction             */
429
     #/*                                                                    */
430
     #/**********************************************************************/
431
 
432
 
433
     print DEST_FILE  "\n    ";
434
     $first = 1;
435
 
436
     foreach $port_line (@port_list)
437
        {
438
          if($first)
439
            {
440
            print DEST_FILE  " (\n ${port_line}";
441
            $first=0;
442
            }
443
          else
444
            {
445
            print DEST_FILE  ",\n ${port_line}";
446
            }
447
 
448
        }
449
 
450
     if    ($first == 0)   { print DEST_FILE  ");\n\n\n\n"; }
451
     elsif ($opt_no_port)  { print DEST_FILE  "\n\n\n\n";  }
452
     else                  { print DEST_FILE  "();\n\n\n\n";}
453
 
454 121 jt_eaton
 
455
 
456
 
457
 
458
 
459 119 jt_eaton
     #/**********************************************************************/
460
     #/*                                                                    */
461 121 jt_eaton
     #/* print wire decs for testbench                                      */
462
     #/*                                                                    */
463
     #/**********************************************************************/
464
 
465
     my @tb_node_list  = ();
466
 
467
 
468
     foreach $x_name (@decl_names)
469
        {
470
 
471
        if( $decl_dirs{$x_name} ne "node" )
472
          {
473
    if ( $decl_vector{$x_name} eq "vector" )
474
             {
475
          push (@tb_node_list,  "\n${decl_pnames{$x_name}}<\/spirit:name>\nwire<\/spirit:typeName><\/spirit:wireTypeDef><\/spirit:wireTypeDefs>\n${decl_lefts{$x_name}}<\/spirit:left>${decl_rights{$x_name}}<\/spirit:right><\/spirit:vector><\/spirit:wire>\n<\/node>\n"     );
476
             }
477
             else
478
      {
479
          push (@tb_node_list,  "\n${decl_pnames{$x_name}}<\/spirit:name>\nwire<\/spirit:typeName><\/spirit:wireTypeDef><\/spirit:wireTypeDefs>\n<\/node>\n"     );
480
             }
481
 
482
 
483
              }
484
 
485
        }
486
 
487
     @tb_node_list      = sys::lib::trim_sort(@tb_node_list);
488
     print TB_DESIGN_FILE  "\n\n";
489
 
490
     foreach $node_line (@tb_node_list)
491
        {
492
 
493
            print TB_DESIGN_FILE  "${node_line}\n";
494
 
495
 
496
        }
497
 
498
     print TB_DESIGN_FILE  "\n\n";
499
 
500
 
501
 
502
 
503
 
504
 
505
     #/**********************************************************************/
506
     #/*                                                                    */
507
     #/* print wire decs for testbench                                      */
508
     #/*                                                                    */
509
     #/**********************************************************************/
510
 
511
     my @tb_node_list  = ();
512
 
513
 
514
     foreach $x_name (@decl_names)
515
        {
516
 
517
        if( $decl_dirs{$x_name} ne "node" )
518
          {
519
    if ( $decl_vector{$x_name} eq "vector" )
520
             {
521
    push (@tb_adhoc_list,  "\n${decl_pnames{$x_name}}[${decl_lefts{$x_name}}:${decl_rights{$x_name}}]<\/spirit:name>\n\n<\/spirit:adHocConnection>\n"     );
522
             }
523
             else
524
            {
525
 
526
    push (@tb_adhoc_list,  "\n${decl_pnames{$x_name}}<\/spirit:name>\n\n<\/spirit:adHocConnection>\n"     );
527
 
528
             }
529
 
530
 
531
              }
532
 
533
        }
534
 
535
     @tb_adhoc_list      = sys::lib::trim_sort(@tb_adhoc_list);
536
     print TB_DESIGN_FILE  "\n\n";
537
 
538
     foreach $adhoc_line (@tb_adhoc_list)
539
        {
540
 
541
            print TB_DESIGN_FILE  "${adhoc_line}\n";
542
 
543
 
544
        }
545
 
546
     print TB_DESIGN_FILE  "\n\n";
547
 
548
 
549
 
550
 
551
 
552
 
553
     #/**********************************************************************/
554
     #/*                                                                    */
555
     #/* Add parameters  to dut      */
556
     #/*                                                                    */
557
     #/**********************************************************************/
558
print TB_DESIGN_FILE    "\n\n";
559
 
560
 
561
 
562
 
563
print TB_DESIGN_FILE    "\n";
564
print TB_DESIGN_FILE    "dut\n";
565
print TB_DESIGN_FILE    "\n";
566
print TB_DESIGN_FILE    "\n";
567
 
568
 
569
     foreach my $parameter_name (@parameters)
570
        {
571
        print TB_DESIGN_FILE  " ${parameter_name}<\/spirit:configurableElementValue>\n";
572
        }
573
 
574
print TB_DESIGN_FILE    "\n";
575
print TB_DESIGN_FILE    "\n";
576
print TB_DESIGN_FILE    "\n";
577
print TB_DESIGN_FILE    "\n";
578
 
579
 
580
 
581
 
582
     #/**********************************************************************/
583
     #/*                                                                    */
584
     #/* Add parameters  to comp      */
585
     #/*                                                                    */
586
     #/**********************************************************************/
587
print TB_COMP_FILE    "\n\n";
588 125 jt_eaton
print TB_COMP_FILE    "                                                  \n";
589
print TB_COMP_FILE    "                                   \n";
590
print TB_COMP_FILE    "                                                 \n";
591
print TB_COMP_FILE    "              Dut                                   \n";
592
print TB_COMP_FILE    "                                                 \n";
593
print TB_COMP_FILE    "              
594
print TB_COMP_FILE    "                                   spirit:library=\"${project}\"                                    \n";
595
print TB_COMP_FILE    "                                   spirit:name=\"${component}\"                                    \n";
596
print TB_COMP_FILE    "                                   spirit:version=\"${version}_dutg.design\"/>                                   \n";
597
print TB_COMP_FILE    "                                                 \n";
598
print TB_COMP_FILE    "                                         \n";
599 121 jt_eaton
print TB_COMP_FILE    "\n";
600
 
601
 
602
 
603
 
604
 
605
     foreach my $parameter_name (@parameters)
606
        {
607
        my $parameter_value = $parameter_values{$parameter_name};
608
        print TB_COMP_FILE  "    ${parameter_name}${parameter_value}\n";
609
        }
610
 
611
print TB_COMP_FILE    "\n";
612
print TB_COMP_FILE    "\n";
613
 
614
 
615
 
616
 
617
   print TB_COMP_FILE  "\n";
618
 
619
 
620
 
621
 
622
 
623
 
624
 
625
 
626
 
627
     #/**********************************************************************/
628
     #/*                                                                    */
629 119 jt_eaton
     #/* Add any and all local parameters with their default values         */
630
     #/*                                                                    */
631
     #/**********************************************************************/
632
 
633
     if ($opt_local_parameters)
634
     {
635
     foreach my $parameter_name (@parameters)
636
        {
637
        my $parameter_value = $parameter_values{${parameter_name}};
638
        print DEST_FILE  "parameter ${parameter_name} = ${parameter_value};\n";
639
        }
640
     }
641
 
642
     #/**********************************************************************/
643
     #/*                                                                    */
644
     #/* Add all internal wires and regs with their sizes                   */
645
     #/*                                                                    */
646
     #/**********************************************************************/
647 121 jt_eaton
 
648
     my @wire_nodes = ();
649 119 jt_eaton
 
650 121 jt_eaton
 
651 119 jt_eaton
     foreach $x_name (@decl_names)
652
        {
653
        my $q_width  = "     ";
654
        if( $decl_vector{$x_name} eq "vector" ){ $q_width = "[ $decl_lefts{$x_name} :  $decl_rights{$x_name}]"}
655 121 jt_eaton
        if( $decl_dirs{$x_name} eq "node" )    { push @wire_nodes,     "$decl_types{$x_name}     $q_width              $decl_pnames{$x_name};";}
656 119 jt_eaton
        }
657
 
658 121 jt_eaton
     @wire_nodes      = sys::lib::trim_sort(@wire_nodes);
659
 
660
     foreach my $wire_node (@wire_nodes)
661
     {
662
     print DEST_FILE  "${wire_node}\n";
663
     }
664
 
665 119 jt_eaton
     print DEST_FILE  "\n\n\n";
666 120 jt_eaton
 
667 119 jt_eaton
 
668 120 jt_eaton
     while(   my $line_out      = shift(@instantiations))             {  print DEST_FILE  "$line_out";}
669 119 jt_eaton
 
670
     #/**********************************************************************/
671
     #/*                                                                    */
672
     #/* After all the data from the ip-xact file has been entered we now   */
673
     #/* insert any and all verilog fragments at the end before closing     */
674
     #/* the module                                                         */
675
     #/*                                                                    */
676
     #/**********************************************************************/
677
 
678
 
679
     foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
680
        {
681
        my($rtl_file)       = $i_name ->findnodes('./text()')->to_literal;
682 120 jt_eaton
        my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal;
683 119 jt_eaton
        my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
684
 
685 120 jt_eaton
        if(($file_type eq "fragment")&& (($view_file eq $view_fileset_name)))
686 119 jt_eaton
          {
687
          $SRCFILE ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${rtl_file}";
688
          open(SRCFILE) or die("Could not open src file.  $SRCFILE ");
689
          foreach $line ()
690
             {
691
             chomp($line);
692
             print DEST_FILE  "${line}\n";
693
             }
694
          }
695
        }
696
     unless ($opt_fragment ) {print DEST_FILE  "\n\n\n  endmodule\n\n";}
697 120 jt_eaton
 
698 119 jt_eaton
   }
699
 
700
 
701
 
702
 
703
 
704
 
705
 
706
 
707
 
708
 
709 120 jt_eaton
 
710 119 jt_eaton
#/*********************************************************************************************/
711
#/                                                                                            */
712 125 jt_eaton
#/ this routine does not follow busses down into componentRef                                 */
713 119 jt_eaton
#/                                                                                            */
714
#/                                                                                            */
715
#/                                                                                            */
716
#/                                                                                            */
717
#/*********************************************************************************************/
718
 
719
 
720
 
721
 
722
sub parse_busInterface
723
   {
724
   my @params     = @_;
725
   my $depth      = pop(@params);
726
   my $busref     = pop(@params);
727
   my $version    = pop(@params);
728
   my $component  = pop(@params);
729
   my $project    = pop(@params);
730
   my $vendor     = pop(@params);
731
 
732
   my $home = cwd();
733
 
734
   my @out_stack  = ();
735
 
736
 
737
   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
738
 
739 120 jt_eaton
 
740 125 jt_eaton
 
741 119 jt_eaton
   my $busInterfaceTest = 0;
742
 
743
   my @mas_slave;
744
     push @mas_slave  , "master";
745
     push @mas_slave  , "slave";
746
 
747
     foreach my $seek_type (@mas_slave)
748
        {
749
 
750
 
751
     foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:${seek_type}"))
752
        {
753
        my($fff_cname)         = $bus_iface->findnodes('../spirit:name/text()')->to_literal ;
754
        my($fff_vendor)        = $bus_iface->findnodes('../spirit:abstractionType/@spirit:vendor')->to_literal ;
755
        my($fff_library)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:library')->to_literal ;
756
        my($fff_name)          = $bus_iface->findnodes('../spirit:abstractionType/@spirit:name')->to_literal ;
757
        my($fff_version)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:version')->to_literal ;
758
 
759
 
760
        foreach my $port_face ($spirit_component_file->findnodes('//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort'))
761
           {
762
 
763
           my($fff_xxx_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
764
 
765
           my($fff_log_name)      = $port_face->findnodes('./spirit:name/text()')->to_literal ;
766
           my($fff_phy_name)      = $port_face->findnodes('../spirit:physicalPort/spirit:name/text()')->to_literal ;
767
           my($fff_type_name)     = $port_face->findnodes('../spirit:physicalPort/spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
768
           my($fff_int_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
769
 
770
           my($fff_left_value)    = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
771
           my($fff_right_value)   = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
772
 
773
           unless ($fff_type_name)  {$fff_type_name = "wire";};
774
 
775
           if(  ( $fff_xxx_name  eq  $busref) && (  $busref eq   $fff_cname  )       )
776
             {
777
             $busInterfaceTest = 1;
778
             my $busdef_parser = XML::LibXML->new();
779 125 jt_eaton
 
780
 
781
             my $spirit_abstractor_filename     = yp::lib::find_ipxact("spirit:abstractionDefinition",$fff_vendor,$fff_library,$fff_name,$fff_version);
782
 
783
             unless($spirit_abstractor_filename){
784
              print "  $fff_vendor $fff_library $fff_name $fff_version  \n";
785
 
786
            }
787
 
788
 
789 122 jt_eaton
             my $spirit_abstractor_file     = ($parser->parse_file(yp::lib::find_ipxact("spirit:abstractionDefinition",$fff_vendor,$fff_library,$fff_name,$fff_version))
790 119 jt_eaton
 
791
 
792 122 jt_eaton
                ) || die "(OOPs $fff_vendor $fff_library $fff_name $fff_version )";
793 119 jt_eaton
 
794
 
795
 
796
             foreach my $abstr_view ($spirit_abstractor_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$fff_log_name']"))
797
                {
798
                my($sss_m_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onMaster/spirit:direction/text()')->to_literal ;
799
                my($sss_s_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onSlave/spirit:direction/text()')->to_literal ;
800
 
801
                    if    ($sss_m_dir eq "in")  { $sss_m_dir = "input";}
802
                    elsif ($sss_m_dir eq "out") { $sss_m_dir = "output";}
803
 
804
                    if    ($sss_s_dir eq "in")  { $sss_s_dir = "input";}
805
                    elsif ($sss_s_dir eq "out") { $sss_s_dir = "output";}
806
 
807
 
808
                my $fff_direction = "";
809
 
810
 
811
                  if    ( $seek_type eq "master")  { $fff_direction = $sss_m_dir;     }
812
                  elsif ( $seek_type eq "slave" )  { $fff_direction = $sss_s_dir;     }
813
 
814
                  my $fff_dir = "";
815
                  if   ($fff_direction  eq "in" )  {$fff_dir = "input" ;}
816
                  elsif($fff_direction  eq "out" ) {$fff_dir = "output" ;}
817
                  else                             {$fff_dir = $fff_direction;     }
818
 
819 122 jt_eaton
                  if($fff_left_value ne "") { push @out_stack, ":::${depth}:::${fff_log_name}:::${fff_phy_name}:::${fff_dir}:::${fff_type_name}:::vector:::${fff_left_value}:::${$fff_right_value}:::"; }
820 119 jt_eaton
                  else                { push @out_stack, ":::${depth}:::${fff_log_name}:::${fff_phy_name}:::${fff_dir}:::${fff_type_name}:::scaler:::none:::none:::";    }
821
 
822
 
823
                }
824
             }
825
 
826
           }
827
       }
828
 
829
}
830
 
831
 
832
 
833
 
834
 
835
       if ( $busInterfaceTest){
836
                              @out_stack      = sys::lib::trim_sort(@out_stack);
837
                              return(@out_stack);
838
                              }
839
 
840
 
841 125 jt_eaton
     my @spirit_design_files       = yp::lib::find_ipxact_design_files($vendor,$project,$component,$version);
842 120 jt_eaton
 
843
     foreach  my   $sd_file (@spirit_design_files)
844 119 jt_eaton
     {
845
 
846 125 jt_eaton
     $_ = $sd_file;
847
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::/)
848
          {
849
          $q_vendor            = $1;
850
          $q_library           = $2;
851
          $q_design            = $3;
852
          $q_version           = $4;
853
          $sd_file             = $parser->parse_file(yp::lib::find_ipxact("spirit:design",$q_vendor,$q_library,$q_design,$q_version));
854
          }
855 120 jt_eaton
 
856
     foreach  my   $x_name ($sd_file->findnodes('//spirit:hierConnections/spirit:hierConnection/@spirit:interfaceRef'))
857 119 jt_eaton
        {
858
        my($hierConn_name)                   = $x_name ->to_literal ;
859
        my($hierConn_comref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:componentRef')->to_literal ;
860
        my($hierConn_busref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:busRef')->to_literal ;
861
        if($busref eq  $hierConn_name)
862
          {
863 120 jt_eaton
          foreach  my   $x_name ($sd_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName[text() = '$hierConn_comref_name']"))
864 119 jt_eaton
            {
865
            #/**********************************************************************/
866
            #/*                                                                    */
867
            #/* Lookup VLNV for each instantiated component                        */
868
            #/*                                                                    */
869
            #/**********************************************************************/
870
 
871
            my($vendor_name)         = $x_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
872
            my($library_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
873
            my($component_name)      = $x_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
874
            my($version_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
875
            $depth = $depth +1;
876
            @out_stack = parse_busInterface ($vendor_name, $library_name,$component_name,$version_name,$hierConn_busref_name,$depth );
877
            }
878
          }
879
        }
880 120 jt_eaton
 
881
     }
882
 
883 119 jt_eaton
        @out_stack      = sys::lib::trim_sort(@out_stack);
884
        return(@out_stack);
885 120 jt_eaton
 
886 119 jt_eaton
 
887
   }
888
 
889
 
890
 
891
 
892 120 jt_eaton
 
893
 
894
 
895
 
896
 
897
 
898
 
899
 
900
 
901
 
902 119 jt_eaton
#/*********************************************************************************************/
903
#/                                                                                            */
904
#/                                                                                            */
905
#/                                                                                            */
906
#/                                                                                            */
907
#/                                                                                            */
908
#/                                                                                            */
909
#/*********************************************************************************************/
910
 
911
 
912
 
913
 
914 120 jt_eaton
sub parse_design_files
915
   {
916
   my @params     = @_;
917
   my $spirit_component_file      = pop(@params);
918
 
919
   print "\n";
920 125 jt_eaton
 
921
 
922
 
923
 
924
 
925
 
926
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef"))
927 120 jt_eaton
    {
928 125 jt_eaton
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
929
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
930
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
931
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
932
            parse_design_files($parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_library,$new_name,$new_version )) );
933
   }
934 120 jt_eaton
 
935
 
936 125 jt_eaton
 
937
 
938 120 jt_eaton
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
939
    {
940
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
941
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
942
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
943
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
944 125 jt_eaton
            my $hier_ref_type = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
945 120 jt_eaton
 
946
 
947
 
948 125 jt_eaton
     if($hier_ref_type eq "spirit:component")
949
     {
950 120 jt_eaton
 
951
     }
952
 
953
 
954 125 jt_eaton
     elsif($hier_ref_type eq "spirit:designConfiguration")
955 120 jt_eaton
     {
956
 
957
        my $spirit_designCfg_file
958
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version ));
959
 
960
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
961
           {
962 125 jt_eaton
            $new_vendor          = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
963
            $new_library         = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
964
            $new_name            = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
965
            $new_version         = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
966
            $hier_ref_type       = "spirit:design" ;
967 120 jt_eaton
           }
968
     }
969
 
970 125 jt_eaton
 
971
    if($hier_ref_type eq "spirit:design")
972
     {
973
        parse_design_file($parser->parse_file(yp::lib::find_ipxact("spirit:design",$new_vendor,$new_library,$new_name,$new_version )) );
974
      }
975
 
976
 
977
 
978
 
979
 
980 120 jt_eaton
  }
981
 
982
}
983
 
984
 
985
 
986
 
987
 
988
 
989
 
990
#/*********************************************************************************************/
991
#/                                                                                            */
992
#/                                                                                            */
993
#/                                                                                            */
994
#/                                                                                            */
995
#/                                                                                            */
996
#/                                                                                            */
997
#/*********************************************************************************************/
998
 
999
 
1000
 
1001
 
1002
sub process_design_files
1003
   {
1004
   my @params     = @_;
1005
   my $spirit_component_file      = pop(@params);
1006
 
1007
   print "\n";
1008 125 jt_eaton
 
1009
 
1010
 
1011
 
1012
 
1013
 
1014
 
1015
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef"))
1016 120 jt_eaton
    {
1017 125 jt_eaton
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
1018
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
1019
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
1020
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
1021
            process_design_files($parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_library,$new_name,$new_version )) );
1022 120 jt_eaton
    }
1023
 
1024
 
1025 125 jt_eaton
 
1026
 
1027
 
1028
 
1029 120 jt_eaton
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
1030
    {
1031
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
1032
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
1033
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
1034
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
1035 125 jt_eaton
            my $hier_ref_type = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
1036 120 jt_eaton
 
1037
 
1038 125 jt_eaton
     if($hier_ref_type eq "spirit:component")
1039 120 jt_eaton
     {
1040
     }
1041
 
1042
 
1043
 
1044 125 jt_eaton
     elsif($hier_ref_type eq "spirit:designConfiguration")
1045 120 jt_eaton
     {
1046
 
1047
        my $spirit_designCfg_file
1048
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version ));
1049
 
1050
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
1051
           {
1052 125 jt_eaton
           ($new_vendor)         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
1053
           ($new_library)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
1054
           ($new_name)           = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
1055
           ($new_version)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
1056
           $hier_ref_type = "spirit:design";
1057
 
1058 120 jt_eaton
           }
1059
     }
1060
 
1061 125 jt_eaton
 
1062
     if($hier_ref_type eq "spirit:design")
1063
     {
1064
        process_design_file($parser->parse_file(yp::lib::find_ipxact("spirit:design",$new_vendor,$new_library,$new_name,$new_version )) );
1065
 
1066
 
1067
      }
1068
 
1069
 
1070
 
1071 120 jt_eaton
  }
1072
 
1073
}
1074
 
1075
 
1076
 
1077
 
1078
 
1079
 
1080
 
1081
 
1082
 
1083
 
1084
#/*********************************************************************************************/
1085
#/                                                                                            */
1086
#/                                                                                            */
1087
#/                                                                                            */
1088
#/                                                                                            */
1089
#/                                                                                            */
1090
#/                                                                                            */
1091
#/*********************************************************************************************/
1092
 
1093
 
1094
 
1095
 
1096 119 jt_eaton
sub parse_design_file
1097
   {
1098
   my @params     = @_;
1099
   my $spirit_design_file      = pop(@params);
1100
 
1101
 
1102
 
1103
 
1104 120 jt_eaton
 
1105
print "\n";
1106
foreach my $new_comp ($spirit_design_file->findnodes("//spirit:design/spirit:vendor"))
1107
   {
1108
   my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
1109
   my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
1110
   my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
1111
   my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
1112
#   print "XXXXXX  $new_vendor $new_library $new_name $new_version  DESIGN \n";
1113
   }
1114
 
1115
 
1116
 
1117
 
1118
 
1119
 
1120 119 jt_eaton
     #/**********************************************************************/
1121
     #/*                                                                    */
1122
     #/* Read each hierConnection and enter signals into wire_decs          */
1123
     #/*                                                                    */
1124
     #/**********************************************************************/
1125
     foreach  my   $x_name ($spirit_design_file->findnodes('//spirit:hierConnections/spirit:hierConnection/@spirit:interfaceRef'))
1126
        {
1127
        my($hierConn_name)                   = $x_name ->to_literal ;
1128
        my($hierConn_comref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:componentRef')->to_literal ;
1129
        my($hierConn_busref_name)            = $x_name ->findnodes('../spirit:interface/@spirit:busRef')->to_literal ;
1130
 
1131
        foreach  my   $x_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
1132
           {
1133
           #/**********************************************************************/
1134
           #/*                                                                    */
1135
           #/* Lookup VLNV for each instantiated component                        */
1136
           #/*                                                                    */
1137
           #/**********************************************************************/
1138
 
1139
           my($instance_name)       = $x_name ->findnodes('./text()')->to_literal ;
1140
          my($vendor_name)         = $x_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
1141
         my($library_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
1142
         my($component_name)      = $x_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
1143
         my($version_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
1144
 
1145
           if( "$instance_name" eq  "$hierConn_comref_name"     )
1146
             {
1147
             my  @filelist_sub = parse_busInterface($vendor_name, $library_name,$component_name,$version_name,$hierConn_busref_name,"1" );
1148
           #/**********************************************************************/
1149
           #/*                                                                    */
1150
           #/* follow bus all the way to it's source                              */
1151
           #/*                                                                    */
1152
           #/**********************************************************************/
1153
 
1154
             foreach $xxline (@filelist_sub)
1155
                {
1156
                $_ = $xxline;
1157
                if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1158
                  {
1159
                  $k_depth               = $1;
1160
                  $k_log_name            = $2;
1161
                  $k_phy_name            = $3;
1162
                  $k_direction           = $4;
1163
                  $k_type                = $5;
1164
                  $k_vector              = $6;
1165
                  $k_left                = $7;
1166
                  $k_right               = $8;
1167
                  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}:::";
1168
                  }
1169
                }
1170
             }
1171
           }
1172
        }
1173
 
1174
 
1175
 
1176
 
1177
 
1178
     #/**************************************************************************/
1179
     #/*                                                                        */
1180
     #/* Read each  interconnection and enter sub signals into wire_decs        */
1181
     #/*                                                                        */
1182
     #/**************************************************************************/
1183
 
1184
 
1185
 
1186
 
1187
     foreach  my   $x_name ($spirit_design_file->findnodes('//spirit:interconnections/spirit:interconnection/spirit:activeInterface/@spirit:componentRef'))
1188
        {
1189
        my($hierConn_comref_name)            = $x_name ->to_literal;
1190
        my($hierConn_busref_name)            = $x_name ->findnodes('../@spirit:busRef')->to_literal ;
1191
        my($hierConn_name)                   = $x_name ->findnodes('../../spirit:name/text()')->to_literal ;
1192
 
1193
        foreach  my   $x_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
1194
           {
1195
           #/**********************************************************************/
1196
           #/*                                                                    */
1197
           #/* Lookup VLNV for each instantiated component                        */
1198
           #/*                                                                    */
1199
           #/**********************************************************************/
1200
 
1201
           my($instance_name)       = $x_name ->findnodes('./text()')->to_literal ;
1202
           my($vendor_name)         = $x_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
1203
           my($library_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
1204
           my($component_name)      = $x_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
1205
           my($version_name)        = $x_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
1206
 
1207
 
1208
 
1209
           if( "$instance_name" eq  "$hierConn_comref_name"     )
1210
             {
1211
 
1212
 
1213
 
1214
           #/**********************************************************************/
1215
           #/*                                                                    */
1216
           #/* follow bus all the way to it's source                              */
1217
           #/*                                                                    */
1218
           #/**********************************************************************/
1219
 
1220
 
1221
             my  @filelist_sub = parse_busInterface($vendor_name, $library_name,$component_name,$version_name,$hierConn_busref_name,"1" );
1222
             foreach $xxline (@filelist_sub)
1223
                {
1224
 
1225
 
1226
                $_ = $xxline;
1227
                if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1228
                  {
1229
                  $k_depth               = $1;
1230
                  $k_log_name            = $2;
1231
                  $k_phy_name            = $3;
1232
                  $k_direction           = $4;
1233
                  $k_type                = $5;
1234
                  $k_vector              = $6;
1235
                  $k_left                = $7;
1236
                  $k_right               = $8;
1237
 
1238
 
1239
                  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}:::";
1240
                  }
1241
                }
1242
             }
1243
           }
1244
        }
1245
 
1246
 
1247
 
1248
     #/*******************************************************************************/
1249
     #/*                                                                             */
1250
     #/* Read each  interconnection and enter modified signals into wire_decs        */
1251
     #/*                                                                             */
1252
     #/*******************************************************************************/
1253
 
1254
 
1255
 
1256
 
1257
 
1258
        foreach  my  $k_name ($spirit_design_file->findnodes('//spirit:interconnections/spirit:interconnection/spirit:activeInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort/spirit:name'))
1259
           {
1260
           my($lp_name)                = $k_name ->to_literal;
1261
           my($lp_pname)               = $k_name ->findnodes('../../spirit:physicalPort/spirit:name/text()')->to_literal ;
1262
           my($lp_left)                = $k_name ->findnodes('../../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1263
           my($lp_right)               = $k_name ->findnodes('../../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1264
           my($lp_componentref_name)   = $k_name ->findnodes('../../../../@spirit:componentRef')->to_literal ;
1265
           my($lp_busref_name)         = $k_name ->findnodes('../../../../@spirit:busRef')->to_literal ;
1266
           my($lp_interconnect_name)   = $k_name ->findnodes('../../../../../spirit:name/text()')->to_literal ;
1267
 
1268
 
1269
           if ( $lp_pname eq '' ) { $lp_pname ="${lp_interconnect_name}_${lp_name}";}
1270
           if ( $lp_left  eq '' ) { $lp_left ="none";}
1271
           if ( $lp_right eq '' ) { $lp_right ="none";}
1272
 
1273
 
1274
 
1275
          if ( $lp_left  eq 'none' )
1276
          {
1277
           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}:::";
1278
          }
1279
          else
1280
          {
1281
           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}:::";
1282
          }
1283
           }
1284
 
1285
 
1286
 
1287
 
1288
 
1289
 
1290
 
1291
 
1292
 
1293
 
1294
 
1295
     #/**********************************************************************/
1296
     #/*                                                                    */
1297
     #/* Read all adHocConnections and load instance connect info into array*/
1298
     #/*                                                                    */
1299
     #/**********************************************************************/
1300
 
1301
 
1302
     foreach  my   $i_xame ($spirit_design_file->findnodes('//spirit:adHocConnections/spirit:adHocConnection/spirit:internalPortReference/@spirit:componentRef'))
1303
        {
1304
        my($comp_name)    = $i_xame ->to_literal;
1305
        my($int_value)    = $i_xame ->findnodes('../../spirit:name/text()')->to_literal ;
1306
        my($int_name)     = $i_xame ->findnodes('../@spirit:portRef')->to_literal ;
1307
        my($vec_left)     = $i_xame ->findnodes('../@spirit:left')->to_literal ;
1308
        my($vec_right)    = $i_xame ->findnodes('../@spirit:right')->to_literal ;
1309
 
1310 124 jt_eaton
 
1311
        unless ($int_value)  {$int_value = "_DUMMY_";}
1312
 
1313
 
1314 119 jt_eaton
        if($vec_left ne "")
1315
          {
1316
          my $vecs = "";
1317
          if($vec_left ne $vec_right ){$vecs ="[${vec_left}:${vec_right}]";}
1318
          else                        {$vecs ="[${vec_right}]";}
1319
          push @inst_conns , ":::${comp_name}:::adhoc:::${int_name}:::${int_value}:::vector:::${vec_left}:::${vec_right}:::";
1320
          }
1321
        else
1322
          {
1323
          push @inst_conns , ":::${comp_name}:::adhoc:::${int_name}:::${int_value}:::scaler:::none:::none:::";
1324
          }
1325
        }
1326
 
1327
 
1328
 
1329
     #/**********************************************************************/
1330
     #/*                                                                    */
1331
     #/* Add all internal wires and regs with their sizes                   */
1332
     #/*                                                                    */
1333
     #/**********************************************************************/
1334
 
1335
     foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/nodes/node/spirit:name"))
1336
        {
1337 122 jt_eaton
        my($node_name)       = $i_name ->findnodes('./text()')->to_literal ;
1338
        my($node_left)       = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1339
        my($node_right)      = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1340
        my($node_type)       = $i_name ->findnodes('../spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
1341 119 jt_eaton
 
1342 122 jt_eaton
        if(  $node_left ne "" ) { push @wire_decs , ":::${node_name}:::${node_name}:::node:::${node_type}:::vector:::${node_left}:::${$node_right}:::none:::0:::${node_name}:::XXX:::${node_name}:::"; }
1343
        else                     { push @wire_decs , ":::${node_name}:::${node_name}:::node:::${node_type}:::scaler:::none:::none:::none:::0:::${node_name}:::XXX:::${node_name}:::";   }
1344 119 jt_eaton
 
1345
        }
1346
 
1347
 
1348
 
1349
 
1350
 
1351
 
1352
 
1353
 
1354
 
1355
 
1356
 
1357
 
1358
 
1359
     #/**********************************************************************/
1360
     #/*                                                                    */
1361
     #/* extract bus instance connections from wire_decs                    */
1362
     #/*                                                                    */
1363
     #/**********************************************************************/
1364
 
1365
     print "+-+";
1366
 
1367
 
1368
 
1369
     my @inst_names  = ();
1370
     my @inst_Inames  = ();
1371
     my %inst_ports  = ();
1372
     my %inst_sigs   = ();
1373
     my %inst_vector = ();
1374
     my %inst_left   = ();
1375
     my %inst_right  = ();
1376
 
1377
 
1378
     foreach $line (@wire_decs)
1379
        {
1380
        $_ = $line;
1381
        if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1382
          {
1383
          my $t_index               = $1;
1384
          my $t_node_name           = $2;
1385
          my $t_direction           = $3;
1386
          my $t_type                = $4;
1387
          my $t_vector              = $5;
1388
          my $t_left                = $6;
1389
          my $t_right               = $7;
1390
          my $t_instance            = $8;
1391
          my $t_depth               = $9;
1392
          my $t_phy_name            = $10;
1393
          my $t_busref_name         = $11;
1394
          my $t_abslog_name         = $12;
1395
 
1396
        if( 1)
1397
          {
1398
 
1399
         push ( @inst_names, "${t_instance}_${t_busref_name}_${t_index}");
1400
 
1401
         $inst_Inames{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_instance}";
1402
 
1403
         if(  $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"})
1404
            {
1405
            if(  $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"} eq ${t_index})
1406
              {
1407
              $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_node_name}";
1408
              }
1409
            }
1410
         else
1411
            {
1412
            $inst_sigs{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_node_name}";
1413
            }
1414
 
1415
         if   ($t_depth >= 2 )      { $inst_ports{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_busref_name}_${t_abslog_name}" ;}
1416
         elsif($t_depth == 1 )      { $inst_ports{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_phy_name}";}
1417
 
1418
         if(  $inst_vector{"${t_instance}_${t_busref_name}_${t_index}"})
1419
            {
1420
            if(  $inst_vector{"${t_instance}_${t_busref_name}_${t_index}"} eq "scaler")
1421
              {$inst_vector{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_vector}";}
1422
            }
1423
         else
1424
            {$inst_vector{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_vector}";}
1425
 
1426
         unless(  $inst_left{"${t_instance}_${t_busref_name}_${t_index}"} eq '')
1427
            {
1428
            if(  $inst_left{"${t_instance}_${t_busref_name}_${t_index}"} eq "none")
1429
              {
1430
              $inst_left{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_left}";
1431
              }
1432
            elsif(  $inst_left{"${t_instance}_${t_busref_name}_${t_index}"} < ${t_left})
1433
              {
1434
              $inst_left{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_left}";
1435
              }
1436
            }
1437
          else
1438
            {
1439
            $inst_left{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_left}";
1440
            }
1441
 
1442
          unless(  $inst_right{"${t_instance}_${t_busref_name}_${t_index}"} eq '')
1443
            {
1444
            if(  $inst_right{"${t_instance}_${t_busref_name}_${t_index}"} eq "none")
1445
              {
1446
              $inst_right{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_right}";
1447
              }
1448
            elsif(  $inst_right{"${t_instance}_${t_busref_name}_${t_index}"} < ${t_right})
1449
              {
1450
              $inst_right{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_right}";
1451
              }
1452
            }
1453
          else {$inst_right{"${t_instance}_${t_busref_name}_${t_index}"}  = "${t_right}";}
1454
 
1455
        }
1456
      }
1457
     }
1458
     @inst_names = sys::lib::trim_sort(@inst_names);
1459
     foreach $i_name (@inst_names)
1460
         {
1461
        unless($inst_Inames{$i_name} eq "none")
1462
         {
1463
         if($inst_vector{$i_name} eq "vector"  )
1464
           {
1465
          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";
1466
          }
1467
        else
1468
          {
1469
          push @inst_conns ,":::$inst_Inames{$i_name}:::adhoc:::$inst_ports{$i_name}:::$inst_sigs{$i_name}:::scaler:::none:::none:::\n";
1470
 
1471
           }
1472
         }
1473
         }
1474 120 jt_eaton
     }
1475 119 jt_eaton
 
1476
 
1477
 
1478
 
1479
 
1480
 
1481
 
1482
 
1483
 
1484 120 jt_eaton
#/*********************************************************************************************/
1485
#/                                                                                            */
1486
#/                                                                                            */
1487
#/                                                                                            */
1488
#/                                                                                            */
1489
#/                                                                                            */
1490
#/                                                                                            */
1491
#/*********************************************************************************************/
1492 119 jt_eaton
 
1493
 
1494
 
1495
 
1496 120 jt_eaton
sub process_design_file
1497
   {
1498
   my @params     = @_;
1499
   my $spirit_design_file      = pop(@params);
1500 119 jt_eaton
 
1501
 
1502
 
1503
 
1504
 
1505 120 jt_eaton
print "\n";
1506
foreach my $new_comp ($spirit_design_file->findnodes("//spirit:design/spirit:vendor"))
1507
   {
1508
   my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
1509
   my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
1510
   my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
1511
   my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
1512
#   print "XXXXXX-  $new_vendor $new_library $new_name $new_version  DESIGN \n";
1513
   }
1514 119 jt_eaton
 
1515
 
1516
 
1517
     #/**********************************************************************/
1518
     #/*                                                                    */
1519
     #/* Instantiate each component with parameters and port connections    */
1520
     #/*                                                                    */
1521
     #/* If the component doesn't have a instance name then this is skipped */
1522
     #/*                                                                    */
1523
     #/**********************************************************************/
1524
 
1525
     print "+-+";
1526
 
1527
     push @instantiations  , "////////////////////////////////////////////////////////////////\n";
1528
 
1529
     foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
1530
        {
1531
        my($instance_name)       = $i_name ->findnodes('./text()')->to_literal ;
1532 122 jt_eaton
        my($vendor_name)         = $i_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
1533
        my($library_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
1534 119 jt_eaton
        my($component_name)      = $i_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
1535
        my($version_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
1536
 
1537 122 jt_eaton
        my $module_name = yp::lib::get_module_name($vendor_name,$library_name,$component_name,$version_name) ;
1538
 
1539
 
1540 119 jt_eaton
        if($instance_name)
1541
          {
1542 122 jt_eaton
          push @instantiations  , "$module_name\n";
1543 119 jt_eaton
          $first = 1;
1544
 
1545
          foreach  my   $i_parameter ($spirit_design_file->findnodes("//spirit:componentInstance[spirit:instanceName/text() = '$instance_name']/spirit:configurableElementValues/spirit:configurableElementValue/\@spirit:referenceId"))
1546
             {
1547
             my($foo_name)       = $i_parameter ->to_literal ;
1548
             my($foo_value)      = $i_parameter ->findnodes('../text()')->to_literal ;
1549 124 jt_eaton
 
1550
 
1551
 
1552
 
1553 119 jt_eaton
             if($first)
1554
               {
1555
               push @instantiations  , "#( .${foo_name} (${foo_value})";
1556
               $first = 0;
1557
               }
1558
             else  {push @instantiations  , ",\n   .${foo_name} (${foo_value})";}
1559
             }
1560
 
1561
             if($first == 0)  { push @instantiations  , ")\n";}
1562
             push @instantiations  , "$instance_name \n   (\n ";
1563
             $first = 1;
1564
              @per_inst = sys::lib::trim_sort(@inst_conns);
1565
 
1566
             foreach $line (@per_inst)
1567
                {
1568
                $_ = $line;
1569
 
1570
                if(/:::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::(\S+):::/)
1571
                  {
1572
                  my $z_instance_name           = $1;
1573
                  my $z_busRef_name   = $2;
1574
                  my $z_port_name           = $3;
1575
                  my $z_signal_name           = $4;
1576
                  my $z_vecscal           = $5;
1577
                  my $z_left           = $6;
1578
                  my $z_right           = $7;
1579
                  if($z_vecscal eq "vector")
1580
                    {
1581
                    if($z_left eq $z_right){$z_signal_name =  "${z_signal_name}[${z_left}]" ;}
1582
                    else    {$z_signal_name =  "${z_signal_name}[${z_left}:${z_right}]" ;}
1583
                    }
1584 124 jt_eaton
 
1585
                  if ($z_signal_name eq "_DUMMY_")  {$z_signal_name = "      ";}
1586
 
1587 119 jt_eaton
                  if($instance_name eq  $z_instance_name )
1588
                    {
1589
                    if($first)
1590
                      {
1591
                      push @instantiations  ,          "  .${z_port_name}         (${z_signal_name})";
1592
                      $first =0;
1593
                      }
1594
                    else   {           push @instantiations  , ",\n   .${z_port_name}         (${z_signal_name})";}
1595
                    }
1596
                  }
1597
                }
1598
 
1599
     print ".";
1600
     push @instantiations  , ");\n\n";
1601
     }
1602
     }
1603
     }
1604
 
1605
 
1606
 
1607
 
1608
 
1609
 
1610
 
1611 120 jt_eaton
 
1612
 
1613 119 jt_eaton
#/*********************************************************************************************/
1614
#/                                                                                            */
1615
#/                                                                                            */
1616
#/                                                                                            */
1617
#/                                                                                            */
1618
#/                                                                                            */
1619
#/                                                                                            */
1620
#/*********************************************************************************************/
1621
 
1622
 
1623
 
1624
 
1625
sub parse_component_file
1626
   {
1627
   my @params     = @_;
1628
   my $spirit_component_file      = pop(@params);
1629
 
1630
 
1631
 
1632
 
1633 120 jt_eaton
print "\n";
1634
foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:vendor"))
1635
   {
1636
   my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
1637
   my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
1638
   my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
1639
   my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
1640 121 jt_eaton
#    print "XXXXXX  $new_vendor $new_library $new_name $new_version  COMPONENT \n";
1641 120 jt_eaton
   }
1642
 
1643
 
1644
 
1645
 
1646 121 jt_eaton
     #/**********************************************************************/
1647
     #/*                                                                    */
1648
     #/* parse parameters and values                                        */
1649
     #/*                                                                    */
1650
     #/**********************************************************************/
1651
 
1652
     foreach  my   $i_name ($spirit_component_file->findnodes('//spirit:model/spirit:modelParameters/spirit:modelParameter/spirit:name'))
1653
        {
1654
        my($parameter_name)     = $i_name ->to_literal;
1655
        my($parameter_default)  = $i_name ->findnodes('../spirit:value/text()')->to_literal ;
1656
 
1657
        unless(defined $parameter_values{$parameter_name})
1658
         {
1659
         push ( @parameters,  "$parameter_name");
1660 125 jt_eaton
         $parameter_values{$parameter_name} = ${parameter_default};
1661
         };
1662 121 jt_eaton
 
1663
        }
1664
 
1665
 
1666
 
1667
 
1668
 
1669
 
1670
 
1671 125 jt_eaton
foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef"))
1672 120 jt_eaton
   {
1673 125 jt_eaton
    my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
1674
    my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
1675
    my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
1676
    my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
1677
    my $hier_ref_type = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
1678
    if($hier_ref_type eq "spirit:component")
1679 120 jt_eaton
     {
1680
     my $spirit_sub_component_file           = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_library,$new_name,$new_version));
1681
     parse_component_file($spirit_sub_component_file);
1682
     }
1683
 
1684 125 jt_eaton
   }
1685 120 jt_eaton
 
1686
 
1687
 
1688
 
1689
 
1690 119 jt_eaton
     #/**********************************************************************/
1691
     #/*                                                                    */
1692
     #/* Read each  busInterface and save master/slave direction            */
1693
     #/*                                                                    */
1694
     #/**********************************************************************/
1695
 
1696
     my @mas_slave;
1697
 
1698
     push @mas_slave  , "master";
1699
     push @mas_slave  , "slave";
1700
 
1701
     foreach $seek_type (@mas_slave)
1702
        {
1703
 
1704
         foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:${seek_type}"))
1705
            {
1706
            my($mmm_cname)         = $bus_iface->findnodes('../spirit:name/text()')->to_literal ;
1707
            my($mmm_vendor)        = $bus_iface->findnodes('../spirit:abstractionType/@spirit:vendor')->to_literal ;
1708
            my($mmm_library)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:library')->to_literal ;
1709
            my($mmm_name)          = $bus_iface->findnodes('../spirit:abstractionType/@spirit:name')->to_literal ;
1710
            my($mmm_version)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:version')->to_literal ;
1711
 
1712
            foreach my $port_face ($spirit_component_file->findnodes('//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort'))
1713
               {
1714
               my($rrr_log_name)      = $port_face->findnodes('./spirit:name/text()')->to_literal ;
1715
               my($rrr_phy_name)      = $port_face->findnodes('../spirit:physicalPort/spirit:name/text()')->to_literal ;
1716
               my($rrr_type_name)     = $port_face->findnodes('../spirit:physicalPort/spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
1717
               my($rrr_int_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
1718
               my($rrr_left_value)    = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1719
               my($rrr_right_value)   = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1720
 
1721
               unless ($rrr_type_name)  {$rrr_type_name = "wire";}
1722
 
1723
               if(   $mmm_cname  eq  $rrr_int_name )
1724
                 {
1725
 
1726
                 my $busdef_parser = XML::LibXML->new();
1727 125 jt_eaton
 
1728
 
1729
                 my $spirit_abstractor_filename    = yp::lib::find_ipxact("spirit:abstractionDefinition",$mmm_vendor,$mmm_library,$mmm_name,$mmm_version);
1730
 
1731
                 unless($spirit_abstractor_filename)
1732
 
1733
                 {print "  $mmm_vendor $mmm_library $mmm_name $mmm_version  \n";
1734
}
1735
 
1736 122 jt_eaton
                 my $spirit_abstractor_file    = ($parser->parse_file(yp::lib::find_ipxact("spirit:abstractionDefinition",$mmm_vendor,$mmm_library,$mmm_name,$mmm_version))
1737 119 jt_eaton
 
1738 122 jt_eaton
                ) || die "(OOPs $mmm_vendor $mmm_library $mmm_name $mmm_version )";
1739
 
1740
 
1741
 
1742 119 jt_eaton
                 foreach my $abstr_view ($spirit_abstractor_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$rrr_log_name']"))
1743
                    {
1744
                    my($sss_m_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onMaster/spirit:direction/text()')->to_literal ;
1745
                    my($sss_s_dir)         = $abstr_view->findnodes('../spirit:wire/spirit:onSlave/spirit:direction/text()')->to_literal ;
1746
 
1747
                    if    ($sss_m_dir eq "in")  { $sss_m_dir = "input";}
1748
                    elsif ($sss_m_dir eq "out") { $sss_m_dir = "output";}
1749
 
1750
                    if    ($sss_s_dir eq "in")  { $sss_s_dir = "input";}
1751
                    elsif ($sss_s_dir eq "out") { $sss_s_dir = "output";}
1752
 
1753
                    my $rrr_direction = "";
1754
 
1755
                    if( $seek_type eq "master") {        $rrr_direction = $sss_m_dir;}
1756
                    else                        {        $rrr_direction = $sss_s_dir;}
1757
 
1758
                    my $rrr_dir = "";
1759
                    if   ($rrr_direction  eq "in" )  {$rrr_dir = "input" ;}
1760
                    elsif($rrr_direction  eq "out" ) {$rrr_dir = "output" ;}
1761
                    else                             {$rrr_dir = $rrr_direction;     }
1762
 
1763 122 jt_eaton
                    if($rrr_left_value ne "")
1764 119 jt_eaton
                        {
1765
                        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}:::";
1766
                        }
1767
                      else
1768
                        {
1769
                        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}:::";
1770
                        }
1771
                    }
1772
                 }
1773
               }
1774 122 jt_eaton
        }
1775 119 jt_eaton
     }
1776
 
1777
 
1778
 
1779
 
1780
     #/**********************************************************************/
1781
     #/*                                                                    */
1782
     #/* Read all ports and store into array                                */
1783
     #/*                                                                    */
1784
     #/**********************************************************************/
1785
 
1786
     foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:ports/spirit:port/spirit:name"))
1787
        {
1788
        my($port_name)       = $i_name ->findnodes('./text()')->to_literal ;
1789
        my($direction)       = $i_name ->findnodes('../spirit:wire/spirit:direction/text()')->to_literal ;
1790
        my($left)            = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
1791
        my($right)           = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
1792
        my($type)            = $i_name ->findnodes('../spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
1793
 
1794
 
1795
        if    ($direction eq "in")  { $direction = "input";}
1796
        elsif ($direction eq "out") { $direction = "output";}
1797
 
1798
 
1799 122 jt_eaton
        if($left ne "")  { push @wire_decs , ":::${port_name}:::${port_name}:::${direction}:::${type}:::vector:::${left}:::${right}:::none:::0:::${port_name}:::XXX:::${port_name}:::";  }
1800 119 jt_eaton
        else       { push @wire_decs , ":::${port_name}:::${port_name}:::${direction}:::${type}:::scaler:::none:::none:::none:::0:::${port_name}:::XXX:::${port_name}:::";          }
1801
        }
1802
 
1803
 
1804
 
1805
 
1806
}
1807
 
1808
 
1809
1
1810
 

powered by: WebSVN 2.1.0

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