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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_ports] - Blame information for rev 131

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

Line No. Rev Author Line
1 131 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 Scalar::Util qw(looks_like_number);
55
use XML::LibXML;
56
use lib './tools';
57
use sys::lib;
58
use yp::lib;
59
use BerkeleyDB;
60
 
61
 
62
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
63
 
64
 
65
############################################################################
66
### Process the options
67
############################################################################
68
Getopt::Long::config("require_order", "prefix=-");
69
GetOptions("h","help",
70
           "vendor=s" => \$vendor,
71
           "library=s" => \$library,
72
           "version=s" => \$version,
73
           "component=s" => \$component,
74
           "debug","verbose"
75
) || die "(use '$program_name -h' for help)";
76
 
77
 
78
##############################################################################
79
## Help option
80
##############################################################################
81
if ( $opt_h  or $opt_help  )
82
  { print "\n gen_ports   - -vendor vendor_name -library library_name  -component component_name  -version version_name  \n";
83
    exit 1;
84
  }
85
 
86
 
87
 
88
 
89
 
90
 
91
#############################################################################
92
##
93
##
94
#############################################################################
95
 
96
 
97
$home = cwd();
98
 
99
 
100
my $variant;
101
 
102
if($version)       {$variant   = "${component}_${version}";}
103
else               {$variant   = "${component}";}
104
 
105
 
106
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
107
my $parser = XML::LibXML->new();
108
 
109
 
110
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
111
 
112
#print "\n GEN_ports     $vendor $library $component $version         \n";
113
 
114
 
115
 
116
my $io_ports  = yp::lib::get_io_ports() ;
117
 
118
 
119
 
120
 
121
my $path  = "${home}/${io_ports}";
122
   mkdir $path,0755             unless( -e $path );
123
   $path  = "${home}/${io_ports}/${vendor}__${library}";
124
   mkdir $path,0755             unless( -e $path );
125
   $path  = "${home}/${io_ports}/${vendor}__${library}/${component}";
126
   mkdir $path,0755             unless( -e $path );
127
   $outfile    ="${path}/${main_module_name}";
128
 
129
   if(-e ${outfile} )
130
     {
131
     # print " $outfile Exists, exiting \n";
132
     exit 0
133
     }
134
 
135
#   print " $outfile Does not Exist, creating \n";
136
   open  DEST_FILE,">$outfile" or die "unable to open $outfile";
137
 
138
 
139
   $outfile = yp::lib::get_io_busses_db_filename($vendor,$library,$component,$version);
140
   $busses_db   = new BerkeleyDB::Hash( -Filename => $outfile, -Flags => DB_CREATE ) or die "Cannot open ${outfile}: $!";
141
 
142
 
143
 
144
#   print "XXXXXXXX   $outfile           GEN_PORTS CREATE \n";
145
   process_design_files($spirit_component_file);
146
   parse_component_file($spirit_component_file);
147
 
148
   my $key;
149
   my $value;
150
 
151
 
152
   my @bus_list;
153
 
154
 
155
   my $cursor = $busses_db ->db_cursor() ;
156
   while ($cursor->c_get($key, $value, DB_NEXT) == 0)
157
   {
158
 
159
                 ( ${key_type},${busref},${conn}) = split( /\./ , $key);
160
                 ( ${log_name},${direction},${type},${vector},${left},${right},${phy_name}) = split ':', $value;
161
                 if(($key_type eq "BusRef"))
162
                    {
163
                    push (@bus_list,  "${busref}_${conn}     ${phy_name}  ${log_name}   ${direction}  ${type}  ${vector}   ${left}:${right}    ");
164
                    }
165
                 else
166
                    {
167
 
168
                    }
169
 
170
   }
171
 
172
   my $status = $cursor->c_close() ;
173
 
174
 
175
   $busses_db   -> db_close();
176
 
177
 
178
 
179
 
180
   @bus_list      = sys::lib::trim_sort(@bus_list);
181
 
182
   foreach $list (@bus_list)
183
      { print DEST_FILE  "${list}\n";}
184
 
185
 
186
#   print "XXXXXXXX   $outfile  GEN_PORTS CLOSED \n";
187
 
188
 
189
#/*********************************************************************************************/
190
#/                                                                                            */
191
#/                                                                                            */
192
#/                                                                                            */
193
#/                                                                                            */
194
#/                                                                                            */
195
#/                                                                                            */
196
#/*********************************************************************************************/
197
 
198
 
199
 
200
 
201
sub parse_component_file
202
   {
203
   my @params     = @_;
204
   my $spirit_component_file      = pop(@params);
205
 
206
 
207
   foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef"))
208
    {
209
    my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
210
    my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
211
    my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
212
    my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
213
    if(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_name,$new_version))
214
     {
215
     parse_component_file($parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_name,$new_version))    );
216
     }
217
   }
218
 
219
 
220
 
221
 
222
 
223
     #/**********************************************************************/
224
     #/*                                                                    */
225
     #/*                                                                    */
226
     #/*                                                                    */
227
     #/**********************************************************************/
228
 
229
foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:slave"))
230
        {
231
        my $busInterface_name          = $bus_iface->findnodes('../spirit:name/text()')->to_literal ;
232
        my $memMap_name                = $bus_iface->findnodes('./spirit:memoryMapRef/@spirit:memoryMapRef')->to_literal ;
233
 
234
 
235
        foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:busInterface[spirit:name/text() = '$busInterface_name']/spirit:slave/spirit:bridge"))
236
          {
237
          my($bridge_map)        = $bus_iface->findnodes('./@spirit:masterRef')->to_literal ;
238
#          print "FFFFFFF SLAVE BRIDGE  $busInterface_name  $memMap_name --  $bridge_map   \n";
239
 
240
          foreach my $mem_map ($spirit_component_file->findnodes("//spirit:component/spirit:memoryMaps/spirit:memoryMap[spirit:name/text() = '$memMap_name']/spirit:subspaceMap[spirit:name/text() = '$bridge_map']/spirit:baseAddress"))
241
              {
242
#               my $xxx         = $mem_map->findnodes('../spirit:subspaceMap/@spirit:masterRef')->to_literal ;
243
               my $add         = $mem_map->findnodes('./text()')->to_literal ;
244
               my $int_base_addr    = hex($add);
245
 
246
                  my $repo_data;
247
                  $busses_db->db_get( "AbsDef.${busInterface_name}.bridge", $repo_data );
248
                  $busses_db->db_put( "AbsDef.${busInterface_name}.bridge","${bridge_map}..${int_base_addr}::${repo_data}" );
249
 
250
#                  print "FFFFFFF SUBSPACE   BI name  $busInterface_name MM name  $memMap_name bridge  $bridge_map  Add - $add   \n";
251
 
252
 
253
 
254
 
255
          foreach my $addSpace_map ($spirit_component_file->findnodes("//spirit:component/spirit:addressSpaces/spirit:addressSpace[spirit:name/text() = '$bridge_map']/spirit:range"))
256
               {
257
               my $range         = $addSpace_map->findnodes('./text()')->to_literal ;
258
               my $int_range    = hex($range);
259
             $busses_db->db_put( "BlkDef.${busInterface_name}.${bridge_map}","${int_base_addr}::${int_range}::8" );
260
#             print "FFFFFFF RANGE    BlkDef.${busInterface_name}.${bridge_map}   ${int_base_addr}::${int_range}::8   \n";
261
               }
262
 
263
              }
264
 
265
          }
266
 
267
 
268
 
269
        foreach my $mem_map ($spirit_component_file->findnodes("//spirit:component/spirit:memoryMaps/spirit:memoryMap[spirit:name/text() = '$memMap_name']/spirit:bank/spirit:addressBlock"))
270
                {
271
                     my($addB_name)        = $mem_map->findnodes('./spirit:name/text()')->to_literal ;
272
                     my($baseAdd)          = $mem_map->findnodes('../spirit:baseAddress/text()')->to_literal ;
273
                     my($range)            = $mem_map->findnodes('./spirit:range/text()')->to_literal ;
274
                     my($width)            = $mem_map->findnodes('./spirit:width/text()')->to_literal ;
275
                     my $int_baseAdd      = hex($baseAdd);
276
                     my $int_range      = hex($range);
277
                     $busses_db->db_put( "BlkDef.${memMap_name}.${addB_name}","${int_baseAdd}::${int_range}::${width}" );
278
                     }
279
 
280
 
281
 
282
 
283
 
284
        foreach my $mem_map ($spirit_component_file->findnodes("//spirit:component/spirit:memoryMaps/spirit:memoryMap[spirit:name/text() = '$memMap_name']/spirit:bank/spirit:addressBlock/spirit:register"))
285
                {
286
                     my($reg_name)         = $mem_map->findnodes('./spirit:name/text()')->to_literal ;
287
                     my($bank_name)        = $mem_map->findnodes('../../../spirit:name/text()')->to_literal ;
288
                     my($reg_offset)       = $mem_map->findnodes('./spirit:addressOffset/text()')->to_literal ;
289
                     my($reg_size)         = $mem_map->findnodes('./spirit:size/text()')->to_literal ;
290
                     my($reg_access)       = $mem_map->findnodes('./spirit:access/text()')->to_literal ;
291
                     my $int_reg_offset    = hex($reg_offset);
292
                     $busses_db->db_put( "RegDef.${bank_name}.${reg_name}","${int_reg_offset}::${reg_name}::${reg_size}::${reg_access}" );
293
#                     print "FFFFFFF REGISTER  ${bank_name}.${reg_name}    ${reg_offset}::${reg_size}::${reg_access}   \n";
294
                     }
295
 
296
 
297
 
298
 
299
 
300
 
301
 
302
 
303
 
304
 
305
 
306
 
307
 
308
}
309
 
310
 
311
 
312
 
313
 
314
 
315
 
316
 
317
 
318
 
319
 
320
 
321
 
322
 
323
 
324
 
325
 
326
 
327
 
328
 
329
 
330
 
331
 
332
 
333
 
334
 
335
 
336
 
337
     #/**********************************************************************/
338
     #/*                                                                    */
339
     #/* Read each  busInterface and save master/slave direction            */
340
     #/*                                                                    */
341
     #/**********************************************************************/
342
 
343
 
344
     my @mas_slave;
345
 
346
     push @mas_slave  , "master";
347
     push @mas_slave  , "slave";
348
 
349
     foreach $seek_type (@mas_slave)
350
        {
351
 
352
         foreach my $bus_iface ($spirit_component_file->findnodes("//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:${seek_type}"))
353
            {
354
            my($mmm_cname)         = $bus_iface->findnodes('../spirit:name/text()')->to_literal ;
355
            my($mmm_vendor)        = $bus_iface->findnodes('../spirit:abstractionType/@spirit:vendor')->to_literal ;
356
            my($mmm_library)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:library')->to_literal ;
357
            my($mmm_name)          = $bus_iface->findnodes('../spirit:abstractionType/@spirit:name')->to_literal ;
358
            my($mmm_version)       = $bus_iface->findnodes('../spirit:abstractionType/@spirit:version')->to_literal ;
359
 
360
 
361
 
362
            if($mmm_cname)
363
              {
364
              $busses_db->db_put( "AbsDef.${mmm_cname}.${seek_type}","${mmm_vendor}:${mmm_library}:${mmm_name}:${mmm_version}"  );
365
              }
366
 
367
            foreach my $port_face ($spirit_component_file->findnodes('//spirit:component/spirit:busInterfaces/spirit:busInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort'))
368
               {
369
               my($rrr_log_name)      = $port_face->findnodes('./spirit:name/text()')->to_literal ;
370
               my($rrr_int_name)      = $port_face->findnodes('../../../spirit:name/text()')->to_literal ;
371
               my($rrr_phy_name)      = $port_face->findnodes('../spirit:physicalPort/spirit:name/text()')->to_literal ;
372
               my($rrr_type_name)     = $port_face->findnodes('../spirit:physicalPort/spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
373
               my($rrr_left_value)    = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
374
               my($rrr_right_value)   = $port_face->findnodes('../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
375
 
376
               unless ($rrr_type_name)  {$rrr_type_name = "wire";}
377
               unless ($rrr_phy_name)   {$rrr_phy_name  = ${rrr_log_name} ;}
378
 
379
               if(   $mmm_cname  eq  $rrr_int_name )
380
                 {
381
                 my $absDef_filename = yp::lib::get_absDef_db_filename($mmm_vendor,$mmm_library,$mmm_name,$mmm_version);
382
                 $absDef_db   = new BerkeleyDB::Hash( -Filename => $absDef_filename, -Flags => DB_CREATE ) or die "Cannot open ${absDef_filename}: $!";
383
 
384
                  my $abs_data;
385
                  $absDef_db->db_get("${seek_type}__${rrr_log_name}", $abs_data );
386
 
387
                 ( $berk_name, $berk_presence,$berk_width,$berk_direction ) = split ':', $abs_data;
388
                 my        $rrr_direction = $berk_direction;
389
 
390
 
391
 
392
 
393
                 if($rrr_left_value ne "")
394
                     {
395
                      $berk_vector = "vector";
396
                      }
397
                  else
398
                      {
399
                      $berk_vector = "scaler";
400
                      $rrr_left_value = "none";
401
                      $rrr_right_value = "none";
402
                       }
403
 
404
 
405
 
406
                  uplift_busref(${mmm_cname},${rrr_log_name},${rrr_direction},${rrr_type_name},${berk_vector},${rrr_left_value},${rrr_right_value},${rrr_phy_name});
407
 
408
 
409
 
410
                  $absDef_db->db_close();
411
                 }
412
               }
413
        }
414
     }
415
 
416
 
417
 
418
 
419
     #/**********************************************************************/
420
     #/*                                                                    */
421
     #/* Read all ports and store into array                                */
422
     #/*                                                                    */
423
     #/**********************************************************************/
424
 
425
     foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:ports/spirit:port/spirit:name"))
426
        {
427
        my($port_name)       = $i_name ->findnodes('./text()')->to_literal ;
428
        my($direction)       = $i_name ->findnodes('../spirit:wire/spirit:direction/text()')->to_literal ;
429
        my($left)            = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
430
        my($right)           = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
431
        my($type)            = $i_name ->findnodes('../spirit:wireTypeDefs/spirit:wireTypeDef/spirit:typeName/text()')->to_literal ;
432
 
433
 
434
        if    ($direction eq "in")  { $direction = "input";}
435
        elsif ($direction eq "out") { $direction = "output";}
436
 
437
 
438
        my $vector;
439
        $vector  ="vector";
440
 
441
        if($left ne "")
442
           {
443
 
444
           }
445
        else
446
           {
447
           $vector = "scaler";
448
           $left   = "none";
449
           $right  = "none";
450
           }
451
 
452
 
453
           uplift_busref("adhoc", ${port_name} , ${direction}, ${type} , ${vector},${left},${right},${port_name} );
454
 
455
 
456
        }
457
 
458
}
459
 
460
 
461
 
462
 
463
 
464
#/*********************************************************************************************/
465
#/                                                                                            */
466
#/                                                                                            */
467
#/                                                                                            */
468
#/                                                                                            */
469
#/                                                                                            */
470
#/                                                                                            */
471
#/*********************************************************************************************/
472
 
473
 
474
 
475
 
476
sub process_design_files
477
   {
478
   my @params     = @_;
479
   my $spirit_component_file      = pop(@params);
480
 
481
   #print "\n";
482
 
483
 
484
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef"))
485
    {
486
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
487
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
488
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
489
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
490
            process_design_files($parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_name,$new_version )) );
491
    }
492
 
493
  foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
494
    {
495
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
496
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
497
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
498
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
499
            if( yp::lib::find_ipxact_design($new_vendor,$new_library,$new_name,$new_version )  )
500
              {
501
              if($opt_verbose){print "process_design_file  $new_vendor $new_library $new_name $new_version  \n"; }
502
              process_design_file($parser->parse_file(yp::lib::find_ipxact_design($new_vendor,$new_library,$new_name,$new_version )) );
503
              }
504
    }
505
}
506
 
507
 
508
#/*********************************************************************************************/
509
#/                                                                                            */
510
#/                                                                                            */
511
#/                                                                                            */
512
#/                                                                                            */
513
#/                                                                                            */
514
#/                                                                                            */
515
#/*********************************************************************************************/
516
 
517
 
518
sub process_design_file
519
   {
520
   my @params     = @_;
521
   my $spirit_design_file      = pop(@params);
522
 
523
   foreach my $new_comp ($spirit_design_file->findnodes("//spirit:design/spirit:vendor"))
524
     {
525
     my($new_vendor)          = $new_comp->findnodes('./text()')->to_literal ;
526
     my($new_library)         = $new_comp->findnodes('../spirit:library/text()')->to_literal ;
527
     my($new_name)            = $new_comp->findnodes('../spirit:name/text()')->to_literal ;
528
     my($new_version)         = $new_comp->findnodes('../spirit:version/text()')->to_literal ;
529
     #   print "XXXXXX-  $new_vendor $new_library $new_name $new_version  DESIGN \n";
530
     }
531
 
532
   foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
533
        {
534
        my($instance_name)       = $i_name ->findnodes('./text()')->to_literal ;
535
        my($vendor_name)         = $i_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
536
        my($library_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
537
        my($component_name)      = $i_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
538
        my($version_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
539
        my $module_name          = yp::lib::get_module_name($vendor_name,$library_name,$component_name,$version_name) ;
540
        my $inst_path             = "${home}/${io_ports}/${vendor_name}__${library_name}/${component_name}";
541
 
542
        my $file =  "$inst_path/${module_name}";
543
        if(-e $file) { # print "XXXXXXXX   $file  Exists \n";
544
                     }
545
        else
546
          {
547
#           print "XXXXXXXX   $file           Doesn't Exist \n";
548
          $cmd = "./tools/verilog/gen_ports    -vendor $vendor_name -library $library_name  -component $component_name  -version $version_name   ";
549
          if (system($cmd)) {}
550
 
551
 
552
          }
553
 
554
        }
555
 
556
 
557
            #/**********************************************************************/
558
            #/*                                                                    */
559
            #/* Hierarchical connections                                           */
560
            #/*                                                                    */
561
            #/**********************************************************************/
562
 
563
 
564
#        print "XCCCD  Process HierConns \n";
565
        foreach  my   $i_name ($spirit_design_file->findnodes('//spirit:hierConnections/spirit:hierConnection/@spirit:interfaceRef'))
566
        {
567
 
568
        my($hierConn_name)                   = $i_name ->to_literal ;
569
        my($hierConn_comref_name)            = $i_name ->findnodes('../spirit:interface/@spirit:componentRef')->to_literal ;
570
        my($hierConn_busref_name)            = $i_name ->findnodes('../spirit:interface/@spirit:busRef')->to_literal ;
571
 
572
#        print "XCCCC HIER_CONN  inst  ${hierConn_comref_name}  name  ${hierConn_name} busref  $hierConn_busref_name \n";
573
 
574
 
575
          foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName[text() = '$hierConn_comref_name']"))
576
            {
577
            #/**********************************************************************/
578
            #/*                                                                    */
579
            #/* Lookup VLNV for each instantiated component                        */
580
            #/*                                                                    */
581
            #/**********************************************************************/
582
 
583
            my($vendor_name)         = $i_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
584
            my($library_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
585
            my($component_name)      = $i_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
586
            my($version_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
587
 
588
#            print "XCCXX HIER_CONN  inst  ${hierConn_comref_name}  name  ${hierConn_name} busref  $hierConn_busref_name  child ${vendor_name}_${library_name}_${component_name}_${version_name}\n";
589
 
590
            my $child_file  = yp::lib::get_io_busses_db_filename($vendor_name,$library_name,$component_name,$version_name);
591
            $child_ports_db   = new BerkeleyDB::Hash( -Filename => $child_file, -Flags => DB_CREATE ) or die "Cannot open ${child_file}: $!";
592
 
593
#            print "XXXXXXXX         GEN_PORTS OPENNED $child_file  \n";
594
 
595
            my $child_cursor = $child_ports_db->db_cursor() ;
596
            while ($child_cursor->c_get($key, $value, DB_NEXT) == 0)
597
               {
598
               ( ${log_name},${direction},${type},${vector},${left},${right}) = split ':', $value;
599
 
600
 
601
               if(($key eq "BusRef.${hierConn_busref_name}.${log_name}"))
602
                 {
603
                 if(${vector} eq "vector")
604
                      {
605
                      unless( looks_like_number($left) ) { $left=0;}
606
                      }
607
                  uplift_busref(${hierConn_name},${log_name},${direction},"wire",${vector},${left},${right},"${hierConn_name}_${log_name}");
608
                }
609
               elsif (($key eq "AbsDef.${hierConn_busref_name}.master"))
610
                {
611
                ( ${xx_vendor},${xx_library},${xx_name},${xx_version}) = split ':', $value;
612
                $busses_db->db_put( "AbsDef.${hierConn_name}.master","${xx_vendor}:${xx_library}:${xx_name}:${xx_version}"  );
613
                $busses_db->db_put( "AbsDef.${hierConn_name}.interconnect","${hierConn_comref_name}..${hierConn_busref_name}::"  );
614
                }
615
               elsif (($key eq "AbsDef.${hierConn_busref_name}.slave"))
616
                {
617
                ( ${xx_vendor},${xx_library},${xx_name},${xx_version}) = split ':', $value;
618
                $busses_db->db_put( "AbsDef.${hierConn_name}.slave","${xx_vendor}:${xx_library}:${xx_name}:${xx_version}"  );
619
                $busses_db->db_put( "AbsDef.${hierConn_name}.interconnect","${hierConn_comref_name}..${hierConn_busref_name}::"  );
620
                }
621
 
622
 
623
 
624
 
625
 
626
               }
627
 
628
               my $status = $child_cursor->c_close() ;
629
               $child_ports_db   -> db_close();
630
            }
631
   }
632
 
633
 
634
 
635
 
636
 
637
 
638
 
639
     #/*******************************************************************************/
640
     #/*                                                                             */
641
     #/* Read each  interconnection         */
642
     #/*                                                                             */
643
     #/*******************************************************************************/
644
 
645
 
646
 
647
 
648
 
649
        foreach  my  $i_name ($spirit_design_file->findnodes('//spirit:interconnections/spirit:interconnection/spirit:activeInterface'))
650
           {
651
           my($lp_componentref_name)   = $i_name ->findnodes('./@spirit:componentRef')->to_literal ;
652
           my($lp_busref_name)         = $i_name ->findnodes('./@spirit:busRef')->to_literal ;
653
           my($lp_interconnect_name)   = $i_name ->findnodes('../spirit:name/text()')->to_literal ;
654
 
655
           my $repo_data;
656
           $busses_db->db_get( "AbsDef.${lp_interconnect_name}.interconnect" , $repo_data );
657
           $busses_db->db_put( "AbsDef.${lp_interconnect_name}.interconnect","${lp_componentref_name}..${lp_busref_name}::${repo_data}"  );
658
           $busses_db->db_put( "Instance.${lp_componentref_name}.${lp_busref_name}","${lp_interconnect_name}"  );
659
 
660
           }
661
 
662
 
663
 
664
 
665
 
666
 
667
 
668
 
669
     #/**************************************************************************/
670
     #/*                                                                        */
671
     #/* Read each  interconnection and enter sub signals into wire_decs        */
672
     #/*                                                                        */
673
     #/**************************************************************************/
674
 
675
 
676
 
677
 
678
     foreach  my   $i_name ($spirit_design_file->findnodes('//spirit:interconnections/spirit:interconnection/spirit:activeInterface/@spirit:componentRef'))
679
        {
680
        my($hierConn_comref_name)            = $i_name ->to_literal;
681
        my($hierConn_busref_name)            = $i_name ->findnodes('../@spirit:busRef')->to_literal ;
682
        my($hierConn_name)                   = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
683
 
684
 
685
 
686
 
687
 
688
 
689
 
690
 
691
 
692
     #/*******************************************************************************/
693
     #/*                                                                             */
694
     #/* Read each  interconnection and enter modified signals into wire_decs        */
695
     #/*                                                                             */
696
     #/*******************************************************************************/
697
 
698
 
699
 
700
 
701
 
702
        foreach  my  $i_name ($spirit_design_file->findnodes('//spirit:interconnections/spirit:interconnection/spirit:activeInterface/spirit:portMaps/spirit:portMap/spirit:logicalPort/spirit:name'))
703
           {
704
           my($lp_name)                = $i_name ->to_literal;
705
           my($lp_pname)               = $i_name ->findnodes('../../spirit:physicalPort/spirit:name/text()')->to_literal ;
706
           my($lp_left)                = $i_name ->findnodes('../../spirit:physicalPort/spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
707
           my($lp_right)               = $i_name ->findnodes('../../spirit:physicalPort/spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
708
           my($lp_componentref_name)   = $i_name ->findnodes('../../../../@spirit:componentRef')->to_literal ;
709
           my($lp_busref_name)         = $i_name ->findnodes('../../../../@spirit:busRef')->to_literal ;
710
           my($lp_interconnect_name)   = $i_name ->findnodes('../../../../../spirit:name/text()')->to_literal ;
711
           $lp_vector = "vector";
712
 
713
 
714
           if ( $lp_pname eq '' ) { $lp_pname ="${lp_interconnect_name}_${lp_name}";}
715
           if ( $lp_left  eq '' )
716
              {
717
              $lp_left ="none";
718
              $lp_vector = "scaler";
719
              }
720
           if ( $lp_right eq '' )
721
              {
722
              $lp_right ="none";
723
              $lp_vector = "scaler";
724
              }
725
 
726
 
727
 
728
           if( ($hierConn_name eq $lp_interconnect_name) &&  ( $hierConn_comref_name  eq   $lp_componentref_name  )            )
729
             {
730
#             print  "TTTTTTTTTTTT  ${lp_pname}_${lp_name}  => ${lp_interconnect_name}_${lp_name}   ${lp_pname}   $lp_left  $lp_right   $lp_busref_name   \n";
731
 
732
                 if(${lp_vector} eq "vector")
733
                     {
734
                     unless( looks_like_number($lp_left) ) { $lp_left=0;}
735
                     }
736
 
737
              uplift_busref(${hierConn_name},${lp_name},"node","wire",${lp_vector},${lp_left},${lp_right},${lp_pname});
738
             }
739
           }
740
 
741
          foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName[text() = '$hierConn_comref_name']"))
742
            {
743
            #/**********************************************************************/
744
            #/*                                                                    */
745
            #/* Lookup VLNV for each instantiated component                        */
746
            #/*                                                                    */
747
            #/**********************************************************************/
748
 
749
            my($vendor_name)         = $i_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
750
            my($library_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
751
            my($component_name)      = $i_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
752
            my($version_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
753
 
754
 
755
 
756
 
757
 
758
#            print "XCCXX INTERCONN  inst  ${hierConn_comref_name}  name  ${hierConn_name} busref  $hierConn_busref_name  child ${vendor_name}_${library_name}_${component_name}_${version_name}\n";
759
            my $child_file  = yp::lib::get_io_busses_db_filename($vendor_name,$library_name,$component_name,$version_name);
760
            $child_ports_db   = new BerkeleyDB::Hash( -Filename => $child_file, -Flags => DB_CREATE ) or die "Cannot open ${child_file}: $!";
761
#            print "XXXXXXXX         GEN_PORTS OPENNED $child_file  \n";
762
 
763
            my $child_cursor = $child_ports_db->db_cursor() ;
764
            while ($child_cursor->c_get($key, $value, DB_NEXT) == 0)
765
               {
766
               ( ${log_name},${direction},${type},${vector},${left},${right}) = split ':', $value;
767
 
768
              if(($key eq "BusRef.${hierConn_busref_name}.${log_name}"))
769
                {
770
#                 print "INTERCONN  ${hierConn_name}_${log_name}      $direction , $vector, $left , $right  \n";
771
                 uplift_busref(${hierConn_name},${log_name},"node","wire",${vector},${left},${right},"${hierConn_name}_${log_name}");
772
                }
773
               elsif(($key eq "AbsDef.${hierConn_busref_name}.master"))
774
                {
775
                $busses_db->db_put( "AbsDef.${hierConn_name}.node","$value"  );
776
                }
777
               elsif(($key eq "AbsDef.${hierConn_busref_name}.slave"))
778
                {
779
                $busses_db->db_put( "AbsDef.${hierConn_name}.node","$value"  );
780
                }
781
 
782
 
783
               }
784
               my $status = $child_cursor->c_close() ;
785
               $child_ports_db   -> db_close();
786
            }
787
 
788
 
789
        foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
790
           {
791
           #/**********************************************************************/
792
           #/*                                                                    */
793
           #/* Lookup VLNV for each instantiated component                        */
794
           #/*                                                                    */
795
           #/**********************************************************************/
796
 
797
           my($instance_name)       = $i_name ->findnodes('./text()')->to_literal ;
798
           my($vendor_name)         = $i_name  ->findnodes('../spirit:componentRef/@spirit:vendor')->to_literal ;
799
           my($library_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:library')->to_literal ;
800
           my($component_name)      = $i_name  ->findnodes('../spirit:componentRef/@spirit:name')->to_literal ;
801
           my($version_name)        = $i_name  ->findnodes('../spirit:componentRef/@spirit:version')->to_literal ;
802
 
803
           if( "$instance_name" eq  "$hierConn_comref_name"     )
804
             {
805
#              print "INTERCONNECTION    $instance_name   $vendor_name   $library_name    $component_name  $version_name  $hierConn_busref_name   $hierConn_name           \n";
806
             }
807
           }
808
         }
809
 
810
     #/**********************************************************************/
811
     #/*                                                                    */
812
     #/* Read all wires and store into array                                */
813
     #/*                                                                    */
814
     #/**********************************************************************/
815
 
816
 
817
 
818
   foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:vendorExtensions/socgen:nodes/socgen:node/spirit:name"))
819
        {
820
        my($node_name)       = $i_name ->findnodes('./text()')->to_literal ;
821
        my($node_busdef)     = $i_name ->findnodes('../socgen:busDef/text()')->to_literal ;
822
        my($node_left)       = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
823
        my($node_right)      = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
824
        my($node_type)       = $i_name ->findnodes('../spirit:typeName/text()')->to_literal ;
825
 
826
        unless($node_busdef){   $node_busdef =    $node_name;     }
827
 
828
        if(  $node_left ne "" )
829
          {
830
          if(  $node_right  eq "" ){ $node_right = $node_left; }
831
          $node_vector = "vector";
832
          }
833
        else
834
          {
835
          $node_vector = "scaler";
836
          $node_left   = "none";
837
          $node_right  = "none";
838
          }
839
 
840
#          print "WIRE_NODE  ${node_name}     node  , $node_type , $node_vector, $node_left , $node_right    $node_busdef \n";
841
          uplift_busref("adhoc",     "${node_name}" , "node" , ${node_type} , ${node_vector}, ${node_left} , ${node_right},${node_name});
842
        }
843
 
844
 
845
     #/**********************************************************************/
846
     #/*                                                                    */
847
     #/* Read all adHocConnections and load instance connect info into array*/
848
     #/*                                                                    */
849
     #/**********************************************************************/
850
 
851
     foreach  my   $i_name ($spirit_design_file->findnodes('//spirit:adHocConnections/spirit:adHocConnection/spirit:internalPortReference/@spirit:componentRef'))
852
        {
853
        my($componentRef_name)      = $i_name ->to_literal;
854
        my($int_portRef_name)       = $i_name ->findnodes('../@spirit:portRef')->to_literal ;
855
        my($adhocConnection_name)   = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
856
        my($ext_portRef_name)       = $i_name ->findnodes('../../spirit:externalPortReference/@spirit:portRef')->to_literal ;
857
        my($left)                   = $i_name ->findnodes('../../spirit:externalPortReference/@spirit:left')->to_literal ;
858
        my($right)                  = $i_name ->findnodes('../../spirit:externalPortReference/@spirit:right')->to_literal ;
859
 
860
        if(  $left ne "" )
861
          {
862
          if(  $right  eq "" ){ $right = $left; }
863
          $vector = "vector";
864
          }
865
        else
866
          {
867
          $vector = "scaler";
868
          $left   = "none";
869
          $right  = "none";
870
          }
871
 
872
        $_ = ${adhocConnection_name};
873
        if(/(\w+)/)
874
            {
875
            $adhocConnection_name      = $1;
876
            unless( looks_like_number($adhocConnection_name) )
877
                  {
878
#                  print "ADHOC_NODE   ${adhocConnection_name}  ,  node  ,  wire  , $vector, $left , $right  \n";
879
                  uplift_busref("adhoc", ${adhocConnection_name} , "node" , "wire" , ${vector}, ${left} , ${right}, ${adhocConnection_name});
880
                  }
881
            }
882
        }
883
}
884
 
885
 
886
 
887
 
888
 
889
 
890
#/*********************************************************************************************/
891
#/                                                                                            */
892
#/                                                                                            */
893
#/                                                                                            */
894
#/                                                                                            */
895
#/                                                                                            */
896
#/                                                                                            */
897
#/*********************************************************************************************/
898
 
899
 
900
 
901
 
902
sub uplift_busref
903
   {
904
   my @params     = @_;
905
   my $phy_name         = pop(@params);
906
   my $right            = pop(@params);
907
   my $left             = pop(@params);
908
   my $vector           = pop(@params);
909
   my $type             = pop(@params);
910
   my $direction        = pop(@params);
911
   my $log_name         = pop(@params);
912
   my $busref_name      = pop(@params);
913
 
914
#   print "BUS_UPLIFT  $busref_name $log_name  $direction  $type  $vector  $left  $right  $phy_name  \n";
915
   $busses_db->db_put( "","${log_name}:${direction}:${type}:${vector}:${left}:${right}:${phy_name}"  );
916
 
917
   my $uplift_data;
918
   my $uplift_log_name ;
919
   my $uplift_phy_name ;
920
   my $uplift_direction ;
921
   my $uplift_type;
922
   my $uplift_vector;
923
   my $uplift_left;
924
   my $uplift_right;
925
 
926
 
927
   $busses_db->db_get("BusRef.${busref_name}.$log_name", $uplift_data );
928
   (${uplift_log_name},${uplift_direction},${uplift_type},${uplift_vector},${uplift_left},${uplift_right},${uplift_phy_name}  ) = split ':', $uplift_data;
929
 
930
   $busses_db->db_get("", $uplift_data );
931
   (${log_name},${direction},${type},${vector},${left},${right},${phy_name}  ) = split ':', $uplift_data;
932
   $busses_db->db_del("");
933
 
934
 
935
  if(${uplift_phy_name} ne "")
936
     {
937
     if(${uplift_phy_name} ne "${busref_name}_${uplift_log_name}"  )
938
       {
939
       ${phy_name}= ${uplift_phy_name};
940
#       print "SET   |${uplift_phy_name}|${busref_name}_${uplift_log_name}| \n";
941
       }
942
 
943
     }
944
 
945
 
946
 
947
   if(${uplift_log_name})
948
     {
949
#     print "REPLACING   ${busref_name} ${uplift_log_name}  ${uplift_direction}  ${uplift_type}  ${uplift_vector}  ${uplift_left}  ${uplift_right} ${uplift_phy_name} \n";
950
     if(${uplift_direction} ne "node"   ) {        $direction =${uplift_direction};}
951
 
952
     if(${type} eq "wire" )   { $type =${uplift_type};}
953
 
954
     if(${uplift_vector} eq "vector")
955
          {
956
          if( $vector eq "vector" )
957
              {
958
              if( looks_like_number($uplift_left))
959
                  {
960
                  if( looks_like_number($left) )
961
                    {
962
                    if($uplift_left  > $left ) {$left  = $uplift_left;}
963
                    }
964
 
965
                  }
966
              else
967
                 {
968
                 if( looks_like_number($left) ) {$left  = ${uplift_left}; }
969
                 unless(${direction} ne "node") {$left  = ${uplift_left}; }
970
                 }
971
               if( looks_like_number($uplift_right) &&  looks_like_number($right) )  { if($uplift_right  < $right ) {$right  = $uplift_right;}}
972
               }
973
          else
974
             {
975
             $vector = "vector";
976
             $left   = ${uplift_left};
977
             $right  = ${uplift_right};
978
             }
979
          }
980
      }
981
#   print "WITH       ${busref_name}  $log_name  $direction  $type  $vector  $left  $right $phy_name \n";
982
 
983
   $busses_db->db_put( "BusRef.${busref_name}.$log_name","${log_name}:${direction}:${type}:${vector}:${left}:${right}:${phy_name}"  );
984
   }
985
 
986
 
987
 
988
 
989
 
990
 
991
 
992
 
993
 
994
 
995
 
996
 
997
 
998
1

powered by: WebSVN 2.1.0

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