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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [yp/] [lib.pm] - Rev 130

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

#/**********************************************************************/
#/*                                                                    */
#/*             -------                                                */
#/*            /   SOC  \                                              */
#/*           /    GEN   \                                             */
#/*          /    TOOL    \                                            */
#/*          ==============                                            */
#/*          |            |                                            */
#/*          |____________|                                            */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*  Author(s):                                                        */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*                                                                    */
#/**********************************************************************/
#/*                                                                    */
#/*    Copyright (C) <2010-2011>  <Ouabache Design Works>              */
#/*                                                                    */
#/*  This source file may be used and distributed without              */
#/*  restriction provided that this copyright statement is not         */
#/*  removed from the file and that any derivative work contains       */
#/*  the original copyright notice and the associated disclaimer.      */
#/*                                                                    */
#/*  This source file is free software; you can redistribute it        */
#/*  and/or modify it under the terms of the GNU Lesser General        */
#/*  Public License as published by the Free Software Foundation;      */
#/*  either version 2.1 of the License, or (at your option) any        */
#/*  later version.                                                    */
#/*                                                                    */
#/*  This source is distributed in the hope that it will be            */
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
#/*  details.                                                          */
#/*                                                                    */
#/*  You should have received a copy of the GNU Lesser General         */
#/*  Public License along with this source; if not, download it        */
#/*  from http://www.opencores.org/lgpl.shtml                          */
#/*                                                                    */
#/**********************************************************************/
 
 
 
 
 
 
use strict;
 
package yp::lib;
 
 
############################################################################
### Set up Databases
############################################################################
 
use BerkeleyDB;
 
 
my $repo_db      = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/repo.dbm', -Flags => DB_CREATE ) or die "Cannot open file: $!";
my $component_db = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/component.dbm', -Flags => DB_CREATE ) or die "Cannot open file: $!";
my $design_db    = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/design.dbm', -Flags => DB_CREATE ) or die "Cannot open file: $!";
my $abstractionDefinition_db    = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/abstractionDefinition.dbm', -Flags => DB_CREATE ) or die "Cannot open file: $!";
my $busDefinition_db    = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/busDefinition.dbm', -Flags => DB_CREATE ) or die "Cannot open file: $!";
my $libraryConfiguration_db    = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/libraryConfiguration.dbm', -Flags => DB_CREATE ) or die "Cannot open file: $!";
my $componentConfiguration_db    = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/componentConfiguration.dbm', -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
 
 
 
#/***********************************************************************************************/
#/  find_ipxact_component                                                                       */
#/                                                                                              */
#/  returns full path name to ip-xact component file                                            */
#/                                                                                              */
#/  my $spirit_type_file = yp::lib::find_ipxact_component($vendor,$library,$component,$version);*/
#/                                                                                              */
#/***********************************************************************************************/
 
sub find_ipxact_component
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
   my $comp_data;
   my $component_version;
   my $component_xml;
   my $comp_xml_sep;
      $component_db->db_get("${vendor}__${library}_${component}_${version}", $comp_data );
      ( $component_xml, $comp_xml_sep,$component_version ) = split ':', $comp_data;
#   print "XXXXXX ${vendor}__${library}_${component}_${version}  $comp_data  \n";
 
 
      return("$component_xml");
   }
 
 
 
#/***********************************************************************************************/
#/  find_ipxact_design                                                                          */
#/                                                                                              */
#/  returns full path name to ip-xact design file                                               */
#/                                                                                              */
#/  my $spirit_type_file = yp::lib::find_ipxact_design($vendor,$library,$component,$version);   */
#/                                                                                              */
#/***********************************************************************************************/
 
sub find_ipxact_design
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
   my $data;
   my $design_xml_sep ;
   my $design_xml_file ;
   my $design_version;
 
      $design_db->db_get("${vendor}__${library}_${component}_${version}", $data );
      ( $design_xml_file, $design_xml_sep,$design_version ) = split ':', $data;
 
      return("$design_xml_file");
   }
 
 
#/**************************************************************************************************************/
#/  find_ipxact_abstractionDefinition                                                                          */
#/                                                                                                             */
#/  returns full path name to ip-xact abstractionDefinition file                                               */
#/                                                                                                             */
#/  my $spirit_type_file = yp::lib::find_ipxact_abstractionDefinition($vendor,$library,$component,$version);   */
#/                                                                                                             */
#/**************************************************************************************************************/
 
sub find_ipxact_abstractionDefinition
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $data;
   my $design_xml_sep ;
   my $design_xml_file ;
   my $design_version;
 
      $abstractionDefinition_db->db_get("${vendor}__${library}_${component}_${version}", $data );
      ( $design_xml_file, $design_xml_sep,$design_version ) = split ':', $data;
 
      return("$design_xml_file");
 
   }
 
 
 
#/**************************************************************************************************************/
#/  find_ipxact_busDefinition                                                                                  */
#/                                                                                                             */
#/  returns full path name to ip-xact busDefinition file                                                       */
#/                                                                                                             */
#/  my $spirit_type_file = yp::lib::find_ipxact_busDefinition($vendor,$library,$component,$version);           */
#/                                                                                                             */
#/**************************************************************************************************************/
 
sub find_ipxact_busDefinition
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $data;
   my $design_xml_sep ;
   my $design_xml_file ;
   my $design_version;
 
 
      $busDefinition_db->db_get("${vendor}__${library}_${component}_${version}", $data );
      ( $design_xml_file, $design_xml_sep,$design_version ) = split ':', $data;
 
      return("$design_xml_file");
   }
 
 
 
#/**************************************************************************************************************/
#/  find_libraryConfiguration                                                                                  */
#/                                                                                                             */
#/  returns full path name to socgen  libraryConfiguration xml file                                            */
#/                                                                                                             */
#/  my $socgen_file = yp::lib::find_libraryConfiguration($vendor,$library);                                    */
#/                                                                                                             */
#/**************************************************************************************************************/
 
sub find_libraryConfiguration
   {
   my @params     = @_;
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $libraryConfiguration_xml;
      $libraryConfiguration_db->db_get("${vendor}__${library}", $libraryConfiguration_xml );
   return("$libraryConfiguration_xml");
   }
 
 
#/**************************************************************************************************************/
#/  find_componentConfiguration                                                                                */
#/                                                                                                             */
#/  returns full path name to socgen  componentConfiguration xml file                                          */
#/                                                                                                             */
#/  my $socgen_file = yp::lib::find_componentConfiguration($vendor,$library,$component);                       */
#/                                                                                                             */
#/**************************************************************************************************************/
 
sub find_componentConfiguration
   {
   my @params     = @_;
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $componentConfiguration_xml;
      $componentConfiguration_db->db_get("${vendor}__${library}_${component}", $componentConfiguration_xml );
   return("$componentConfiguration_xml");
   }
 
 
 
 
#/**************************************************************************************************************/
#/  find_lib_comp_sep                                                                                          */
#/                                                                                                             */
#/  returns libraries path to components                                                                       */
#/                                                                                                             */
#/  my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$library,$component);                                */
#/                                                                                                             */
#/**************************************************************************************************************/
 
sub find_lib_comp_sep
   {
   my @params     = @_;
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $type;
   my $name;
   my $lib_comp_sep;
   my $repo_data;
 
      $repo_db->db_get("${vendor}__${library}_${component}", $repo_data );
   ( $type,$name, $lib_comp_sep ) = split ':', $repo_data;
   return("${lib_comp_sep}");
   }
 
 
 
#/***********************************************************************************************/
#/  find_ipxact_comp_xml_sep                                                                    */
#/                                                                                              */
#/                                                                                              */
#/                                                                                              */
#/  my $comp_xml_sep = yp::lib::find_ipxact_component($vendor,$library,$component,$version);    */
#/                                                                                              */
#/***********************************************************************************************/
 
sub find_comp_xml_sep
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
   my $comp_data;
   my $comp_version;
   my $comp_xml_sep;
   my $component_xml;
      $component_db->db_get("${vendor}__${library}_${component}_${version}", $comp_data );
      ( $component_xml, $comp_xml_sep, $comp_version) = split ':', $comp_data;
      return("$comp_xml_sep");
   }
 
 
 
 
 
 
#/*********************************************************************************************/
#/  find_lib_sw_dir                                                                           */
#/                                                                                            */
#/  returns  library sw directory                                                             */
#/                                                                                            */
#/   my $file_lib_sw_dir = yp::lib::find_file_lib_sw_dir($vendor,$library);                   */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_lib_sw_dir
   {
   my @params     = @_;
   my $library    = pop(@params);
   my $vendor     = pop(@params);
   my $parser     = XML::LibXML->new();
 
   my $lib_sw_dir ;
  if(yp::lib::find_libraryConfiguration($vendor,$library))
   {
   my $socgen_libraryConfiguration= $parser->parse_file(yp::lib::find_libraryConfiguration($vendor,$library)); 
      $lib_sw_dir  = $socgen_libraryConfiguration->findnodes('//socgen:libraryConfiguration/socgen:lib_sw_dir/text()')->to_literal ;
   }
 
      return("/${lib_sw_dir}");
 
   }
 
 
 
 
#/*********************************************************************************************/
#/  find_vendors                                                                              */
#/                                                                                            */
#/  returns  array of all vendors                                                             */
#/                                                                                            */
#/   my @vendors = yp::lib::find_vendors();                                                   */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_vendors
   {
   my $key;
   my $value;
   my $type;
   my $name;
   my $path;
   my @vendors = ();
 
   my $cursor = $repo_db->db_cursor() ;
   while ($cursor->c_get($key, $value, DB_NEXT) == 0) 
   {
   ( $type,$name, $path ) = split ':', $value;
   if($type  eq "vendor")
     {
      push (@vendors,$name );
      }
   }
     @vendors = trim_sort(@vendors);
     return (@vendors);
   }
 
 
 
#/*********************************************************************************************/
#/  find_libraries                                                                            */
#/                                                                                            */
#/  returns  array of all libraries from a vendor                                             */
#/                                                                                            */
#/   my @libraries = yp::lib::find_libraries($vendor);                                        */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_libraries
   {
   my @params     = @_;
   my $vendor    = pop(@params);
   my $type;
   my $key;
   my $value;
   my $name;
   my $path;
   my @libraries = ();
 
   my $cursor = $repo_db->db_cursor() ;
   while ($cursor->c_get($key, $value, DB_NEXT) == 0) 
   {
   ( $type,$name, $path ) = split ':', $value;
 
 
   if(($type  eq "library")&& ($key eq "${vendor}__${name}")          )
     {
      push (@libraries,$name );
      }
   }
   @libraries = trim_sort(@libraries);
   return (@libraries);
   }
 
 
#/*********************************************************************************************/
#/  find_components                                                                           */
#/                                                                                            */
#/  returns  array of all components from a vendors library                                   */
#/                                                                                            */
#/   my @components = yp::lib::find_components($vendor,$library);                                      */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_components
   {
   my @params     = @_;
   my $library    = pop(@params);
   my $vendor     = pop(@params);
   my $type;
   my $key;
   my $value;
   my $name;
   my $path;
   my @components = ();
   my $cursor = $repo_db->db_cursor() ;
   while ($cursor->c_get($key, $value, DB_NEXT) == 0) 
      {
      ( $type,$name, $path ) = split ':', $value;
      if(($type  eq "component")&& ($key eq "${vendor}__${library}_${name}"))
         { push (@components,$name );}
      }
   @components = trim_sort(@components);
   return (@components);
   }
 
 
 
 
#/*********************************************************************************************/
#/  find_component_versions                                                                   */
#/                                                                                            */
#/  returns  array of all versions os a component                                             */
#/                                                                                            */
#/   my @components = yp::lib::find_component_versions($vendor,$library,$component);          */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_component_versions
   {
   my @params     = @_;
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $xml_file;
   my $key;
   my $value;
   my $comp_xml_sep;
   my $version;
 
   my @versions = ();
   my $cursor = $component_db->db_cursor() ;
   while ($cursor->c_get($key, $value, DB_NEXT) == 0) 
      {
      ( $xml_file,$comp_xml_sep, $version ) = split ':', $value;
      if(($key eq "${vendor}__${library}_${component}_${version}"))
         { 
         push (@versions,$version );
         }
      }
   @versions = trim_sort(@versions);
   return (@versions);
   }
 
 
 
 
 
#/************************************************************************************************************************/
#/  find_abstractionDefinition_versions                                                                                  */
#/                                                                                                                       */
#/  returns  array of all versions os a abstractionDefinition                                                            */
#/                                                                                                                       */
#/   my @abstractionDefinitions = yp::lib::find_abstractionDefinition_versions($vendor,$library,$abstractionDefinition); */
#/                                                                                                                       */
#/************************************************************************************************************************/
 
sub find_abstractionDefinition_versions
   {
   my @params     = @_;
   my $abstractionDefinition  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $xml_file;
   my $key;
   my $value;
   my $comp_xml_sep;
   my $version;
 
   my @versions = ();
   my $cursor = $abstractionDefinition_db->db_cursor() ;
   while ($cursor->c_get($key, $value, DB_NEXT) == 0) 
      {
      ( $xml_file,$comp_xml_sep, $version ) = split ':', $value;
      if(($key eq "${vendor}__${library}_${abstractionDefinition}_${version}"))
         { 
         push (@versions,$version );
         }
      }
   @versions = trim_sort(@versions);
   return (@versions);
   }
 
 
 
 
 
 
#/************************************************************************************************************************/
#/  find_busDefinition_versions                                                                                  */
#/                                                                                                                       */
#/  returns  array of all versions os a busDefinition                                                            */
#/                                                                                                                       */
#/   my @busDefinitions = yp::lib::find_busDefinition_versions($vendor,$library,$busDefinition); */
#/                                                                                                                       */
#/************************************************************************************************************************/
 
sub find_busDefinition_versions
   {
   my @params     = @_;
   my $busDefinition  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $xml_file;
   my $key;
   my $value;
   my $comp_xml_sep;
   my $version;
 
   my @versions = ();
   my $cursor = $busDefinition_db->db_cursor() ;
   while ($cursor->c_get($key, $value, DB_NEXT) == 0) 
      {
      ( $xml_file,$comp_xml_sep, $version ) = split ':', $value;
      if(($key eq "${vendor}__${library}_${busDefinition}_${version}"))
         { 
         push (@versions,$version );
         }
      }
   @versions = trim_sort(@versions);
   return (@versions);
   }
 
#/*********************************************************************************************/
#/  get_module_name                                                                           */
#/                                                                                            */
#/  returns module name for component                                                         */
#/                                                                                            */
#/   my $module_name = yp::lib::get_module_name($vendor,$library,$component,$version);        */
#/                                                                                            */
#/*********************************************************************************************/
 
sub get_module_name
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $name_depth =2;
 
   my $parser     = XML::LibXML->new();
 
   my $socgen_component_file  = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));  
 
   foreach my $new_comp ($socgen_component_file->findnodes("//socgen:componentConfiguration")) 
     {
     $name_depth        = $new_comp->findnodes('./socgen:ip_name_depth/text()')->to_literal ;
     }
  if($name_depth eq "0"){   return("${library}");}  
  if($name_depth eq "1"){   return("${component}");}  
  if($name_depth eq "2"){   return("${component}_${version}");}  
  if($name_depth eq "3"){   return("${library}_${component}_${version}");}  
  if($name_depth eq "4"){   return("${vendor}_${library}_${component}_${version}");}  
 
   }
 
 
 
 
 
 
 
 
#/*********************************************************************************************/
#/  find_versions                                                                             */
#/                                                                                            */
#/  returns  array of all versions from a vendors library component                           */
#/                                                                                            */
#/   my @versions = yp::lib::find_versions($type,$vendor,$library,component);                 */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_versions
   {
   my @params     = @_;
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
   my $type       = pop(@params);
   my $card_type;
   my $card_vendor;
   my $card_library;
   my $card_component;
   my $card_version;
 
   my $parser           = XML::LibXML->new();
   my $yp_index_file    = $parser->parse_file("./tools/yp/index.xml"); 
   my @versions = ();
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_vendor        = $index_card->findnodes('../vendor/text()')->to_literal ;
     $card_library       = $index_card->findnodes('../library/text()')->to_literal ;
     $card_component     = $index_card->findnodes('../name/text()')->to_literal ;
     $card_version       = $index_card->findnodes('../version/text()')->to_literal ;
     if(($card_type eq $type) & ($card_vendor eq $vendor) & ($card_library eq $library) & ($card_component  eq $component))
 
     {   
     push (@versions,$card_version);}
#     print "XXXXXG   ${vendor}__${library}_${component}   $card_version   \n";
 
     }
   @versions = trim_sort(@versions);
#         print "XXXXXG   ++++++++++++++++++++ Old \n";
   return (@versions);
   }
 
 
#/*********************************************************************************************/
#/  parse_component_file                                                                      */
#/                                                                                            */
#/  returns design names for component                                                        */
#/                                                                                            */
#/   my @filelist = yp::lib::parse_component_file($vendor,$library,$component,$version);      */
#/                                                                                            */
#/*********************************************************************************************/
 
 
 
sub parse_component_file
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $parser     = XML::LibXML->new();
 
 
   my $spirit_cmp_filename =yp::lib::find_ipxact_component($vendor,$library,$component,$version ); 
 
   unless($spirit_cmp_filename)
      {
      print("spirit:component MISSING   $vendor,$library,$component,$version \n"); 
      }
 
 
   my $spirit_component_file  = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version )); 
 
 
   my $line;
 
   my      @filelist_acc = (  );
   push(@filelist_acc,"::${vendor}::${library}::${component}::${version}::");
 
   foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef")) 
     {
     my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
     my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
     my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
     my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
     my @filelist_sub       = parse_component_fileX($new_vendor,$new_library,$new_name,$new_version);
                              foreach $line (@filelist_sub) { push(@filelist_acc,"$line"); }
     }
 
   foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef")) 
     {
     my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
     my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
     my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
     my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
 
     if(yp::lib::find_ipxact_design($new_vendor,$new_library,$new_name,$new_version ))
             {
             my $spirit_design_file = $parser->parse_file(yp::lib::find_ipxact_design($new_vendor,$new_library,$new_name,$new_version )); 
             foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
                {
                my($vendor_name)         = $i_name  ->to_literal ;
                my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
                my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
                my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;
 
                push(@filelist_acc,"::${vendor_name}::${library_name}::${component_name}::${version_name}::");
                my  @filelist_sub = parse_component_fileX($vendor_name,$library_name,$component_name,$version_name);
                  foreach $line (@filelist_sub) { push(@filelist_acc,"$line"); }
                }            
             }
     }
 
   @filelist_acc     =       sys::lib::trim_sort(@filelist_acc);
   return(@filelist_acc);
}
 
 
 
 
 
sub parse_component_fileX
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $parser     = XML::LibXML->new();
 
 
   my $spirit_cmp_filename =yp::lib::find_ipxact_component($vendor,$library,$component,$version ); 
 
   unless($spirit_cmp_filename)
      {
      print("spirit:component MISSING   $vendor,$library,$component,$version \n"); 
      }
 
 
   my $spirit_component_file  = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version )); 
 
 
   my $line;
 
   my      @filelist_acc = (  );
 
 
   foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef")) 
     {
     my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
     my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
     my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
     my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
     my @filelist_sub       = parse_component_fileX($new_vendor,$new_library,$new_name,$new_version);
                              foreach $line (@filelist_sub) { push(@filelist_acc,"$line"); }
     }
 
   foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef")) 
     {
     my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
     my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
     my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
     my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
 
     if(yp::lib::find_ipxact_design($new_vendor,$new_library,$new_name,$new_version ))
          {
          my $spirit_design_file = $parser->parse_file(yp::lib::find_ipxact_design($new_vendor,$new_library,$new_name,$new_version )); 
          foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
                {
                my($vendor_name)         = $i_name  ->to_literal ;
                my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
                my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
                my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;
 
                push(@filelist_acc,"::${vendor_name}::${library_name}::${component_name}::${version_name}::");
                my  @filelist_sub = parse_component_fileX($vendor_name,$library_name,$component_name,$version_name);
                  foreach $line (@filelist_sub) { push(@filelist_acc,"$line"); }
                }       
 
           }
     }
 
   @filelist_acc     =       sys::lib::trim_sort(@filelist_acc);
   return(@filelist_acc);
}
 
 
 
 
 
 
#/*********************************************************************************************/
#/  parse_component_brothers                                                                  */
#/                                                                                            */
#/  returns names for component brothers                                                      */
#/                                                                                            */
#/   my @filelist = yp::lib::parse_component_brother($vendor,$library,$component,$version);   */
#/                                                                                            */
#/*********************************************************************************************/
 
sub parse_component_brothers
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
   my $parser     = XML::LibXML->new();
   unless (yp::lib::find_ipxact_component($vendor,$library,$component,$version)){print "Missing Component  $vendor, $library, $component, $version \n";  }
   my $spirit_component_file  = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version )); 
 
   my $line;
   my      @filelist_acc = (  );
   push(@filelist_acc,"::${vendor}::${library}::${component}::${version}::");
 
   foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef")) 
     {
     my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
     my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
     my($new_component)     = $new_comp->findnodes('./@spirit:name')->to_literal ;
     my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
     push(@filelist_acc,"::${new_vendor}::${new_library}::${new_component}::${new_version}::");
     }
 
   return(@filelist_acc);
}
 
#/*****************************************************************************************************/
#/  find_ipxact_design_files                                                                          */
#/                                                                                                    */
#/  returns parser tokens  to ip-xact design files referred to by component file vlnv                 */
#/                                                                                                    */
#/  my @spirit_design_files = yp::lib::find_ipxact_design_file($vendor,$library,$component,$version);  */
#/                                                                                                    */
#/*****************************************************************************************************/
 
sub find_ipxact_design_files 
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
 
 
   my @design_files = ();
   my $parser           = XML::LibXML->new();
   unless (yp::lib::find_ipxact_component($vendor,$library,$component,$version)){print "Missing Component  $vendor, $library, $component, $version \n";  }
   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
 
   foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:vendorExtensions/spirit:componentRef")) 
     {
     my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
     my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
     my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
     my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
     my @filelist_sub       = yp::lib::find_ipxact_design_files($new_vendor,$new_library,$new_name,$new_version);
                              foreach my $line (@filelist_sub) { push(@design_files,"$line"); }     }
 
   foreach my $comp_view ($spirit_component_file->findnodes('//spirit:component/spirit:model/spirit:views/spirit:view')) 
      {
      my($hier_ref_vendor)         = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:vendor')->to_literal ;
      my($hier_ref_library)        = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:library')->to_literal ;
      my($hier_ref_design)         = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:name')->to_literal ;
      my($hier_ref_version)        = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:version')->to_literal ;
      if(find_ipxact_design($hier_ref_vendor,$hier_ref_library,$hier_ref_design,$hier_ref_version))
        {
        push(@design_files,":::${hier_ref_vendor}:::${hier_ref_library}:::${hier_ref_design}:::${hier_ref_version}:::");           
        }
      }
     return(@design_files);
   }
 
 
 
 
sub trim_sort {
   my @output_files  = @_;
   my %trim = ();
   foreach my $descriptor (@output_files) { $trim{$descriptor}  = 1; }
   my @k = keys %trim;
   @output_files =  sort(sort @k);  
   return(@output_files);
   }
 
 
 
 
 
1;
 

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

powered by: WebSVN 2.1.0

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