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

Subversion Repositories socgen

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

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;
 
 
#/***********************************************************************************************/
#/  find_ipxact                                                                                 */
#/                                                                                              */
#/  returns full path name to ip-xact file                                                      */
#/                                                                                              */
#/  my $spirit_type_file = yp::lib::find_ipxact($type,$vendor,$library,$component,$version);    */
#/                                                                                              */
#/***********************************************************************************************/
 
sub find_ipxact
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $project    = pop(@params);
   my $vendor     = pop(@params);
   my $type       = pop(@params);
 
 
   my $card_file_name;
   my $card_dir_name;
 
   my $parser           = XML::LibXML->new();
   my $yp_index_file    = $parser->parse_file("./tools/yp/hier_index.xml"); 
 
   foreach  my   $i_vendor ($yp_index_file->findnodes("//socgen:file_types/socgen:file_type[socgen:name/text() = '$type']/socgen:vendors/socgen:vendor[socgen:name/text() = '$vendor']/socgen:libraries/socgen:library[socgen:name/text() = '$project']/socgen:components/socgen:component[socgen:name/text() = '$component']/socgen:versions/socgen:version[socgen:name/text() = '$version']"))
     {
     $card_file_name       = $i_vendor->findnodes('./socgen:file_name/text()')->to_literal ;
     $card_dir_name       = $i_vendor->findnodes('./socgen:dir_name/text()')->to_literal ;
     return("./${card_dir_name}/${card_file_name}");  
     }
     return("");
 
   }
 
 
 
 
 
 
 
 
 
#/*********************************************************************************************/
#/  find_ipxact_file                                                                          */
#/                                                                                            */
#/  returns local name of the ip-xact file                                                    */
#/                                                                                            */
#/   my $file_name = yp::lib::find_ipxact_file($type,$vendor,$library,$component,$version);   */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_ipxact_file 
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $project    = pop(@params);
   my $vendor     = pop(@params);
   my $type       = pop(@params);
 
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   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"); 
 
 
 
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/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 "${project}"   ) &
        ( $card_component eq "${component}" ) &
        ( $card_version   eq "${version}"   ) 
       )  {return("${card_file_name}");  }
     }
   }
 
 
 
#/*********************************************************************************************/
#/  find_ipxact_dir_name                                                                      */
#/                                                                                            */
#/  returns  path to ip-xact directory from top level                                         */
#/   my $dir_name = yp::lib::find_ipxact_dir_name($type,$vendor,$library,$component,$version);                 */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_ipxact_dir_name
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $project    = pop(@params);
   my $vendor     = pop(@params);
   my $type       = pop(@params);
 
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   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"); 
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/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 "${project}"   ) &
        ( $card_component eq "${component}" ) &
        ( $card_version   eq "${version}"   ) 
       )  
 
       {return("${card_dir_name}");  }
     }
   }
 
 
 
 
 
 
 
 
#/*********************************************************************************************/
#/  find_ipxact_vendor_path                                                                   */
#/                                                                                            */
#/  returns  path to ip-xact directory from vendor level                                      */
#/  The ip-xact file MUST be stored under a subdirectory that matches the vendor name         */
#/   my $vendor_path = yp::lib::find_ipxact_vendor_path($type,$vendor,$library,$component,$version);                 */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_ipxact_vendor_path
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $project    = pop(@params);
   my $vendor     = pop(@params);
   my $type       = pop(@params);
 
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   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"); 
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/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 "${project}"   ) &
        ( $card_component eq "${component}" ) &
        ( $card_version   eq "${version}"   ) 
       )  
 
       {return("/${card_vendor_path}");  }
     }
   }
 
 
 
 
#/*********************************************************************************************/
#/  find_ipxact_library_path                                                                  */
#/                                                                                            */
#/  returns  path to ip-xact directory from library level                                     */
#/  The ip-xact file MUST be stored under a subdirectory that matches the library name        */
#/   my $library_path = yp::lib::find_ipxact_library_path($type,$vendor,$library,$component,$version);                 */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_ipxact_library_path
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $project    = pop(@params);
   my $vendor     = pop(@params);
   my $type       = pop(@params);
 
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   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"); 
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/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 "${project}"   ) &
        ( $card_component eq "${component}" ) &
        ( $card_version   eq "${version}"   ) 
       )  
 
       {return("/${card_library_path}");  }
     }
   }
 
 
#/*********************************************************************************************/
#/  find_ipxact_component_path                                                                */
#/                                                                                            */
#/  returns  path to ip-xact directory from component level                                   */
#/  The ip-xact file MUST be stored under a subdirectory that matches the component name      */
#/   my $component_path = yp::lib::find_ipxact_component_path($type,$vendor,$library,$component,$version);                 */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_ipxact_component_path
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $project    = pop(@params);
   my $vendor     = pop(@params);
   my $type       = pop(@params);
 
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   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"); 
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/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 "${project}"   ) &
        ( $card_component eq "${component}" ) &
        ( $card_version   eq "${version}"   ) 
       )  
 
       {return("/${card_component_path}");  }
     }
   }
 
 
 
 
 
#/*********************************************************************************************/
#/  find_lib_comp_sep                                                                         */
#/                                                                                            */
#/  returns  path to the component from library level                                         */
#/  The file MUST be stored under a subdirectory that matches the component name              */
#/   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 $project    = pop(@params);
   my $vendor     = pop(@params);
 
 
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   my $card_lib_comp_sep;
   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"); 
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/text()')->to_literal ;
     $card_lib_comp_sep  = $index_card->findnodes('../lib_comp_sep/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_vendor    eq "${vendor}"    ) &
        ( $card_library   eq "${project}"   ) &
        ( $card_component eq "${component}" ) 
       )  
       {
       if($card_lib_comp_sep)   {return("/${card_lib_comp_sep}");}  
       else                     {return("");}  
       }
     }
   }
 
 
 
 
 
 
 
 
#/*********************************************************************************************/
#/  find_file_type                                                                            */
#/                                                                                            */
#/  returns  file_type                                                                        */
#/  The file MUST be stored under a subdirectory that matches the component name              */
#/   my $file_type = yp::lib::find_file_type($vendor,$library,$component,$version);           */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_file_type
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $project    = pop(@params);
   my $vendor     = pop(@params);
 
 
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   my $card_lib_comp_sep;
   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"); 
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/text()')->to_literal ;
     $card_lib_comp_sep  = $index_card->findnodes('../lib_comp_sep/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_vendor    eq "${vendor}"    ) &
        ( $card_library   eq "${project}"   ) &
        ( $card_component eq "${component}" ) &
        ( $card_version   eq "${version}"   ) 
       )  
       {
       if($card_type)    {return("${card_type}");}  
       else                     {return("xxxx");}  
       }
     }
   }
 
 
 
 
 
 
#/*********************************************************************************************/
#/  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 $project    = pop(@params);
   my $vendor     = pop(@params);
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   my $card_lib_comp_sep;
   my $card_vendor;
   my $card_library;
   my $card_component;
   my $card_version;
   my $card_lib_sw_dir;
 
   my $parser           = XML::LibXML->new();
   my $yp_index_file    = $parser->parse_file("./tools/yp/index.xml"); 
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/text()')->to_literal ;
     $card_lib_comp_sep  = $index_card->findnodes('../lib_comp_sep/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 ;
     $card_lib_sw_dir    = $index_card->findnodes('../lib_sw_dir/text()')->to_literal ;
     if(( $card_vendor    eq "${vendor}"    ) &
        ( $card_library   eq "${project}"   ) &
        ( $card_type      eq "socgen:libraryConfiguration"   ) 
       )  
       {
       if($card_lib_sw_dir){return("/${card_lib_sw_dir}");}  
       }
     }
   }
 
 
 
 
 
 
 
 
 
#/*********************************************************************************************/
#/  find_vendors                                                                              */
#/                                                                                            */
#/  returns  array of all vendors                                                             */
#/                                                                                            */
#/   my @vendors = yp::lib::find_vendors($type);                                                       */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_vendors
   {
   my @params     = @_;
   my $type       = pop(@params);
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   my $card_lib_comp_sep;
   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 @vendors = ();
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/text()')->to_literal ;
     $card_lib_comp_sep  = $index_card->findnodes('../lib_comp_sep/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){   
     push (@vendors,$card_vendor );
     }
 
     }
   @vendors = trim_sort(@vendors);
   return (@vendors);
   }
 
 
 
#/*********************************************************************************************/
#/  find_libraries                                                                            */
#/                                                                                            */
#/  returns  array of all libraries from a vendor                                             */
#/                                                                                            */
#/   my @libraries = yp::lib::find_libraries($type,$vendor);                                                 */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_libraries
   {
   my @params     = @_;
   my $vendor    = pop(@params);
   my $type      = pop(@params);
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   my $card_lib_comp_sep;
   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 @libraries = ();
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/text()')->to_literal ;
     $card_lib_comp_sep  = $index_card->findnodes('../lib_comp_sep/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))  {   
     push (@libraries,$card_library );}
     }
   @libraries = trim_sort(@libraries);
   return (@libraries);
   }
 
 
#/*********************************************************************************************/
#/  find_components                                                                           */
#/                                                                                            */
#/  returns  array of all components from a vendors library                                   */
#/                                                                                            */
#/   my @components = yp::lib::find_components($type,$vendor,$library);                                      */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_components
   {
   my @params     = @_;
   my $library    = pop(@params);
   my $vendor    = pop(@params);
   my $type      = pop(@params);
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   my $card_lib_comp_sep;
   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 @components = ();
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/text()')->to_literal ;
     $card_lib_comp_sep  = $index_card->findnodes('../lib_comp_sep/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))
 
     {   
     push (@components,$card_component);}
     }
   @components = trim_sort(@components);
   return (@components);
   }
 
 
 
 
#/*********************************************************************************************/
#/  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_file_name;
   my $card_dir_name;
   my $card_vendor_path;
   my $card_library_path;
   my $card_component_path;
   my $card_lib_comp_sep;
   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_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/text()')->to_literal ;
     $card_vendor_path   = $index_card->findnodes('../vendor_path/text()')->to_literal ;
     $card_component_path= $index_card->findnodes('../component_path/text()')->to_literal ;
     $card_library_path  = $index_card->findnodes('../library_path/text()')->to_literal ;
     $card_lib_comp_sep  = $index_card->findnodes('../lib_comp_sep/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);}
     }
   @versions = trim_sort(@versions);
   return (@versions);
   }
 
 
 
 
 
 
 
 
#/*********************************************************************************************/
#/  find_socgen                                                                               */
#/                                                                                            */
#/  returns full path name to socgen file                                                     */
#/                                                                                            */
#/   my $socgen_ip_file = yp::lib::find_socgen($type,$vendor,$library,$component);            */
#/                                                                                            */
#/*********************************************************************************************/
 
sub find_socgen
   {
   my @params     = @_;
   my $component  = pop(@params);
   my $project    = pop(@params);
   my $vendor     = pop(@params);
   my $type       = pop(@params);
 
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor;
   my $card_library;
   my $card_component;
 
   my $parser           = XML::LibXML->new();
   my $yp_index_file    = $parser->parse_file("./tools/yp/index.xml"); 
 
 
   foreach my $index_card  ($yp_index_file->findnodes('//socgen:index_file/index_card/type')) 
     {
     $card_type          = $index_card->findnodes('./text()')->to_literal ;
     $card_file_name     = $index_card->findnodes('../file_name/text()')->to_literal ;
     $card_dir_name      = $index_card->findnodes('../dir_name/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 ;
     if(( $card_type      eq "${type}"      ) &
        ( $card_vendor    eq "${vendor}"    ) &
        ( $card_library   eq "${project}"   ) &
        ( $card_component eq "${component}" ) 
       )  {return("./${card_dir_name}/${card_file_name}");  }
     }
   }
 
 
 
#/*********************************************************************************************/
#/  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_socgen("socgen: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}");}  
 
   }
 
 
 
 
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);
   }
 
#/*********************************************************************************************/
#/  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("spirit: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("spirit: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 $hier_ref_type      = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
     my @filelist_sub       = parse_component_file($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 ;
     my $hier_ref_type      = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
 
     if($hier_ref_type eq "spirit:designConfiguration")
        {
        my $spirit_designCfg_file    
        = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version )); 
 
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration')) 
            {
            $new_vendor         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
            $new_library        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
            $new_name           = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
            $new_version        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
            $hier_ref_type                ="spirit:design";
            }
        }
 
        if($hier_ref_type eq "spirit:design")
           {
           my $spirit_design_file = $parser->parse_file(yp::lib::find_ipxact("spirit:design",$new_vendor,$new_library,$new_name,$new_version )); 
           if($spirit_design_file)
             {
             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_file($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);
}
 
 
 
 
 
 
 
#/*****************************************************************************************************/
#/  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 $project    = pop(@params);
   my $vendor     = pop(@params);
 
 
   my $card_type;
   my $card_file_name;
   my $card_dir_name;
   my $card_vendor;
   my $card_library;
   my $card_component;
   my $card_version;
 
   my @design_files = ();
 
   my $parser           = XML::LibXML->new();
   my $yp_index_file    = $parser->parse_file("./tools/yp/hier_index.xml"); 
 
   unless (yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version)){print "Missing Component  $vendor, $project, $component, $version \n";  }
 
   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$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_component)      = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:name')->to_literal ;
      my($hier_ref_version)        = $comp_view->findnodes('./spirit:hierarchyRef/@spirit:version')->to_literal ;
 
 
 
      if(yp::lib::find_ipxact("spirit:designConfiguration",$hier_ref_vendor,$hier_ref_library,$hier_ref_component,$hier_ref_version ))
      {
 
      my $spirit_designCfg_file    
       = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$hier_ref_vendor,$hier_ref_library,$hier_ref_component,$hier_ref_version )); 
 
      foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration')) 
         {
         ($hier_ref_vendor)         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
         ($hier_ref_library)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
         ($hier_ref_component)      = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
         ($hier_ref_version)        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
         }
      }
 
 
 
 
         foreach  my   $index_card ($yp_index_file->findnodes("//socgen:file_types/socgen:file_type[socgen:name/text() = 'spirit:design']/socgen:vendors/socgen:vendor[socgen:name/text() = '$hier_ref_vendor']/socgen:libraries/socgen:library[socgen:name/text() = '$hier_ref_library']/socgen:components/socgen:component[socgen:name/text() = '$hier_ref_component']/socgen:versions/socgen:version[socgen:name/text() = '$hier_ref_version']"))
           {
           push(@design_files,":::${hier_ref_vendor}:::${hier_ref_library}:::${hier_ref_component}:::${hier_ref_version}:::");
           };
 
 
      }
     return(@design_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.