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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_root] - Diff between revs 133 and 134

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 133 Rev 134
eval 'exec `which perl` -S $0 ${1+"$@"}'
eval 'exec `which perl` -S $0 ${1+"$@"}'
   if 0;
   if 0;
#/**********************************************************************/
#/**********************************************************************/
#/*                                                                    */
#/*                                                                    */
#/*             -------                                                */
#/*             -------                                                */
#/*            /   SOC  \                                              */
#/*            /   SOC  \                                              */
#/*           /    GEN   \                                             */
#/*           /    GEN   \                                             */
#/*          /    TOOL    \                                            */
#/*          /    TOOL    \                                            */
#/*          ==============                                            */
#/*          ==============                                            */
#/*          |            |                                            */
#/*          |            |                                            */
#/*          |____________|                                            */
#/*          |____________|                                            */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*  Author(s):                                                        */
#/*  Author(s):                                                        */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*                                                                    */
#/*                                                                    */
#/**********************************************************************/
#/**********************************************************************/
#/*                                                                    */
#/*                                                                    */
#/*    Copyright (C) <2010-2011>                */
#/*    Copyright (C) <2010-2011>                */
#/*                                                                    */
#/*                                                                    */
#/*  This source file may be used and distributed without              */
#/*  This source file may be used and distributed without              */
#/*  restriction provided that this copyright statement is not         */
#/*  restriction provided that this copyright statement is not         */
#/*  removed from the file and that any derivative work contains       */
#/*  removed from the file and that any derivative work contains       */
#/*  the original copyright notice and the associated disclaimer.      */
#/*  the original copyright notice and the associated disclaimer.      */
#/*                                                                    */
#/*                                                                    */
#/*  This source file is free software; you can redistribute it        */
#/*  This source file is free software; you can redistribute it        */
#/*  and/or modify it under the terms of the GNU Lesser General        */
#/*  and/or modify it under the terms of the GNU Lesser General        */
#/*  Public License as published by the Free Software Foundation;      */
#/*  Public License as published by the Free Software Foundation;      */
#/*  either version 2.1 of the License, or (at your option) any        */
#/*  either version 2.1 of the License, or (at your option) any        */
#/*  later version.                                                    */
#/*  later version.                                                    */
#/*                                                                    */
#/*                                                                    */
#/*  This source is distributed in the hope that it will be            */
#/*  This source is distributed in the hope that it will be            */
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
#/*  details.                                                          */
#/*  details.                                                          */
#/*                                                                    */
#/*                                                                    */
#/*  You should have received a copy of the GNU Lesser General         */
#/*  You should have received a copy of the GNU Lesser General         */
#/*  Public License along with this source; if not, download it        */
#/*  Public License along with this source; if not, download it        */
#/*  from http://www.opencores.org/lgpl.shtml                          */
#/*  from http://www.opencores.org/lgpl.shtml                          */
#/*                                                                    */
#/*                                                                    */
#/**********************************************************************/
#/**********************************************************************/
############################################################################
############################################################################
# General PERL config
# General PERL config
############################################################################
############################################################################
use Getopt::Long;
use Getopt::Long;
use English;
use English;
use File::Basename;
use File::Basename;
use Cwd;
use Cwd;
use Scalar::Util qw(looks_like_number);
use Scalar::Util qw(looks_like_number);
use XML::LibXML;
use XML::LibXML;
use lib './tools';
use lib './tools';
use sys::lib;
use sys::lib;
use yp::lib;
use yp::lib;
use BerkeleyDB;
use BerkeleyDB;
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
############################################################################
############################################################################
### Process the options
### Process the options
############################################################################
############################################################################
Getopt::Long::config("require_order", "prefix=-");
Getopt::Long::config("require_order", "prefix=-");
GetOptions("h","help",
GetOptions("h","help",
           "envidentifier=s" => \$envidentifier,
           "envidentifier=s" => \$envidentifier,
           "prefix=s" => \$prefix,
           "prefix=s" => \$prefix,
           "vendor=s" => \$vendor,
           "vendor=s" => \$vendor,
           "library=s" => \$library,
           "library=s" => \$library,
           "component=s" => \$component,
           "component=s" => \$component,
           "version=s" => \$version,
           "version=s" => \$version,
           "configuration=s" => \$configuration,
           "configuration=s" => \$configuration,
           "dest_dir=s" => \$dest_dir,
           "dest_dir=s" => \$dest_dir,
           "env=s" => \$env,
 
           "tool=s" => \$tool,
 
           "unit=s" => \$unit,
 
           "name=s" => \$name
           "name=s" => \$name
) || die "(use '$program_name -h' for help)";
) || die "(use '$program_name -h' for help)";
##############################################################################
##############################################################################
## Help option
## Help option
##############################################################################
##############################################################################
if ( $opt_h  or $opt_help  )
if ( $opt_h  or $opt_help  )
  { print "\n gen_root -envidentifier {sim/syn}  -prefix /work -vendor vendor_name -library library_name  -component component_name  -version version_name -env env -tool tool -unit unit -name name     \n";
  { print "\n gen_root -envidentifier {sim/syn}  -prefix /work -vendor vendor_name -library library_name  -component component_name  -version version_name   -name name     \n";
    exit 1;
    exit 1;
  }
  }
#############################################################################
#############################################################################
##
##
##
##
#############################################################################
#############################################################################
$home = cwd();
$home = cwd();
unless ($prefix)
unless ($prefix)
 {
 {
 $prefix   = yp::lib::get_workspace();
 $prefix   = yp::lib::get_workspace();
 $prefix   =  "/${prefix}";
 $prefix   =  "/${prefix}";
 }
 }
 
 
 
 
my   $variant;
my   $variant;
 
 
 
 
 
 
 
 
 
 
my $destination       = yp::lib::get_module_name($vendor,$library,$component,$version);
my $destination       = yp::lib::get_module_name($vendor,$library,$component,$version);
 
 
unless ($env ) {$env = "none";}
 
unless ($tool ){$tool = "none";}
 
unless ($unit ){$unit = "none";}
 
 
 
if($name)
if($name)
  {
  {
  $destination   = "${destination}_${name}";
  $destination   = "${destination}";
  }
  }
else
else
  {
  {
#  $name          = $version;
 
  $destination   = "${destination}";
  $destination   = "${destination}";
  }
  }
 
 
 
 
 
 
 
 
my $root                =      "root";
my $root                =      "root";
if($version)       {$variant   = "${component}_${version}";}
if($version)       {$variant   = "${component}_${version}";}
else               {$variant   = "${component}";}
else               {$variant   = "${component}";}
 
 
#print "GEN_ROOT -prefix $prefix -vendor $vendor -library $library -component $component -version $version   -env $env -tool $tool -unit $unit -name $name     \n";
print "GEN_ROOT  -vendor $vendor -library $library -component $component -version $version  -name $name     \n";
 
 
my $parser = XML::LibXML->new();
my $parser = XML::LibXML->new();
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
unless ($socgen_file)      { print "No socgen ip file   \n";};
unless ($socgen_file)      { print "No socgen ip file   \n";};
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
 
 
 
my $elab_db_file;
 
 
$dest_dir = yp::lib::get_io_ports();
if(defined $name)
 
{
 
$elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,$name);
 
}
 
else
 
{
 
$elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,"default");
 
}
 
 
my $path  = "${home}/${dest_dir}";
my $elab_db  = new BerkeleyDB::Hash( -Filename => "$elab_db_file", -Flags => DB_CREATE ) or die "Cannot open $elab_db_file: $!";
 
 
 
$design_db_file  = yp::lib::get_design_db_file;
 
my $design_db  = new BerkeleyDB::Hash( -Filename => "$design_db_file", -Flags => DB_CREATE ) or die "Cannot open $design_db_file: $!";
 
 
 
 
 
unless (defined $configuration && length $configuration > 0)
 
{
 
my $h_ven;
 
my $h_lib;
 
my $h_cmp;
 
my $h_ver;
 
my $h_config;
 
 
 
    my $config_key;
 
    my $config_index;
 
 
 
    if(defined $name)
 
    {
 
    $config_key ="instance_${vendor}_${library}_${component}_${version}_${name}_root";
 
     }
 
    else
 
    {
 
    $config_key ="instance_${vendor}_${library}_${component}_${version}_root";
 
     }
 
    $design_db->db_get($config_key, $config_index );
 
   ( ${h_ven},${h_lib},${h_cmp},${h_ver},${h_config}) = split( /\:/ , $config_index);
 
 
 
$configuration = $h_config;
 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
$dest_dir = yp::lib::get_io_ports();
 
my $path  = "${home}/${dest_dir}";
 
 
mkdir $path,0755      unless( -e $path );
mkdir $path,0755      unless( -e $path );
$path ="${path}/${vendor}__${library}";
$path ="${path}/${vendor}__${library}";
mkdir $path,0755    unless( -e $path );
mkdir $path,0755    unless( -e $path );
$path ="${path}/${component}";
$path ="${path}/${component}";
mkdir $path,0755    unless( -e $path );
mkdir $path,0755    unless( -e $path );
  unless( -e "${path}/${destination}" )
  unless( -e "${path}/${destination}" )
      {
      {
#      print "$path/${destination} does not exist... creating \n";
 
      my $cmd = "mkdir $path/${destination}  \n";
      my $cmd = "mkdir $path/${destination}  \n";
      if(system($cmd)){};
      if(system($cmd)){};
      }
      }
 
 
 
$destination ="${destination}/${configuration}";
 
 
if(defined $name)
 
 
  unless( -e "${path}/${destination}" )
{
{
$data_db_file  = "${home}/dbs/${vendor}_${library}_${component}_${version}_${name}.db";
      my $cmd = "mkdir $path/${destination}  \n";
 
      if(system($cmd)){};
}
}
else
 
 
 
 
  if( -e "${path}/${destination}/root" )
{
{
$data_db_file  = "${home}/dbs/${vendor}_${library}_${component}_${version}.db";
      exit;
 
      #print "${path}/${destination}/root exists \n";
 
 
}
}
 
 
#print "ELAB_XXXX gen_root $data_db_file  \n";
 
my $elab_db  = new BerkeleyDB::Hash( -Filename => "$data_db_file", -Flags => DB_CREATE ) or die "Cannot open $data_db_file: $!";
 
 
 
my $root                =      "root";
my $root                =      "root";
my $key;
my $key;
my $value;
my $value;
my @elab_list;
my @elab_list;
my $cursor = $elab_db ->db_cursor() ;
my $cursor = $elab_db ->db_cursor() ;
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
   {
   {
   ( ${key_type},@elab_list) = split( /\./ , $key);
   ( ${key_type},@elab_list) = split( /\./ , $key);
   if(($key_type eq "component___${root}"))
   if(($key_type eq "component___${root}"))
      {
      {
      build_hierarchy ($value,"${path}/${destination}",$root,@elab_list);
      build_hierarchy ($value,"${path}/${destination}",$root,@elab_list);
      }
      }
   }
   }
my $status = $cursor->c_close() ;
my $status = $cursor->c_close() ;
 
 
 
my @file_names = ();
 
my $file_name = "${path}/${destination}/${root}/Index.db";
 
push @file_names, $file_name;
 
 
 
 
 
 
 
 
 
$cursor = $elab_db ->db_cursor() ;
 
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
 
   {
 
   $_ = $key;
 
   if($key eq "component___root")
 
    {
 
 
 
    my $file_name = "${path}/${destination}/${root}/Index.db";
 
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
 
       $param_db->db_put( "PATH","root");
 
       $param_db->db_put( "VLNV","${value}");
 
       $param_db->db_close();
 
    }
 
   elsif (/component___root\.(\S+)/)
 
    {
 
 
 
    my $xpath = $1;
 
    my $ypath = $1;
 
    $xpath =~ s/\./\//g;
 
 
 
 
 
    my $file_name = "${path}/${destination}/root/${xpath}/Index.db";
 
    push @file_names, $file_name;
 
 
 
 
 
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
 
       $param_db->db_put( "PATH","root.${ypath}");
 
       $param_db->db_put( "VLNV","${value}");
 
       $param_db->db_close();
 
    }
 
   }
 
$status = $cursor->c_close() ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
$cursor = $elab_db ->db_cursor() ;
$cursor = $elab_db ->db_cursor() ;
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
   {
   {
   $_ = $key;
   $_ = $key;
   if(/parameter_${root}__(\S+)/)
   if(/parameter_${root}__(\S+)/)
    {
    {
    my $file_name = "${path}/${destination}/${root}/Index.db";
    my $file_name = "${path}/${destination}/${root}/Index.db";
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
       $param_db->db_put( "$key","${value}");
       $param_db->db_put( "$key","${value}");
       $param_db->db_close();
       $param_db->db_close();
    }
    }
   elsif (/parameter_${root}(\S+)__(\S+)/)
   elsif (/parameter_${root}(\S+)__(\S+)/)
    {
    {
    my $xpath = $1;
    my $xpath = $1;
 
    my $ypath = $1;
    $xpath =~ s/\./\//g;
    $xpath =~ s/\./\//g;
    my $file_name = "${path}/${destination}/${root}/${xpath}/Index.db";
    my $file_name = "${path}/${destination}/${root}${xpath}/Index.db";
 
    push @file_names, $file_name;
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
       $param_db->db_put( "$key","${value}");
       $param_db->db_put( "$key","${value}");
       $param_db->db_close();
       $param_db->db_close();
    }
    }
   }
   }
$status = $cursor->c_close() ;
$status = $cursor->c_close() ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
$cursor = $elab_db ->db_cursor() ;
$cursor = $elab_db ->db_cursor() ;
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
   {
   {
   $_ = $key;
   $_ = $key;
   if(/busInterface_${root}__(\S+)/)
   if(/busInterface_${root}__(\S+)/)
    {
    {
    my $file_name = "${path}/${destination}/${root}/Index.db";
    my $file_name = "${path}/${destination}/${root}/Index.db";
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
       $param_db->db_put( "$key","${value}");
       $param_db->db_put( "$key","${value}");
 
 
       $param_db->db_close();
       $param_db->db_close();
    }
    }
   elsif(/busInterface_${root}(\S+)__(\S+)/)
   elsif(/busInterface_${root}(\S+)__(\S+)/)
    {
    {
    my $xpath = $1;
    my $xpath = $1;
 
    my $ypath = $1;
    my $parname = $2;
    my $parname = $2;
    $xpath =~ s/\./\//g;
    $xpath =~ s/\./\//g;
    my $file_name = "${path}/${destination}/${root}/${xpath}/Index.db";
    my $file_name = "${path}/${destination}/${root}${xpath}/Index.db";
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
       $param_db->db_put( "$key","${value}");
       $param_db->db_put( "$key","${value}");
       $param_db->db_close();
       $param_db->db_close();
    }
    }
 
   }
 
$status = $cursor->c_close() ;
 
 
 
 
 
 # here we read the vlnv from param_db
 
 # open it's BUSSES.dbm
 
 # copy all contents
 
 # modify vector left:right by parsing parameters
 
 
 
# print "IIIIIIIIX  $VLNV_copy  \n";
 
 
 
 foreach my $param_c (@param_copy)
 
 {
 
 #print "IIIIIIIII  $param_c  \n";
   }
   }
$status = $cursor->c_close() ;
 
 
 
 
 
$elab_db->db_close();
$elab_db->db_close();
 
 
 
@file_names      = sys::lib::trim_sort(@file_names);
 
 foreach my $file_name (@file_names)
 
  {
 
  my $cmd ="./tools/verilog/tag_Index.db $file_name \n";
 
  if(system($cmd)){}
 
 
 
  }
 
 
#/*********************************************************************************************/
#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/
#/*********************************************************************************************/
sub build_hierarchy
sub build_hierarchy
   {
   {
   my @params     = @_;
   my @params     = @_;
   my $vlnv       = shift(@params);
   my $vlnv       = shift(@params);
   my $path       = shift(@params);
   my $path       = shift(@params);
   my $root       = shift(@params);
   my $root       = shift(@params);
   my $top        = shift(@params);
   my $top        = shift(@params);
   my $new_elab_db ;
   my $new_elab_db ;
   my $new_elab_db_file_name ;
   my $new_elab_db_file_name ;
 
 
 
 
 
 
#   print "Hier  $path \nHier- $root       $top    --- @params  \n";
 
   $path ="${path}/${root}";
   $path ="${path}/${root}";
   unless(-e $path)
   unless(-e $path)
     {
     {
     $cmd ="mkdir ${path} \n";
     $cmd ="mkdir ${path} \n";
     if(system($cmd)){}
     if(system($cmd)){}
#     print "Create Dir  ${path} \n";
 
     }
     }
   unless (-e "${path}/${top}")
   unless (-e "${path}/${top}")
     {
     {
     $cmd ="mkdir ${path}/${top} \n";
     $cmd ="mkdir ${path}/${top} \n";
     if(system($cmd)){}
     if(system($cmd)){}
     }
     }
   $new_elab_db_file_name  = "${path}/${top}/Index.db";
   $new_elab_db_file_name  = "${path}/${top}/Index.db";
   if(@params)
   if(@params)
     {
     {
     build_hierarchy ("$vlnv","${path}","${top}",@params);
     build_hierarchy ("$vlnv","${path}","${top}",@params);
     }
     }
   else
   else
     {
     {
#     print "CREATE $new_elab_db_file_name  \n";
 
     $new_elab_db  = new BerkeleyDB::Hash( -Filename => "$new_elab_db_file_name", -Flags => DB_CREATE ) or die "Cannot open $new_elab_db_file_name    : $!";
     $new_elab_db  = new BerkeleyDB::Hash( -Filename => "$new_elab_db_file_name", -Flags => DB_CREATE ) or die "Cannot open $new_elab_db_file_name    : $!";
     $new_elab_db->db_put( "VLNV","${vlnv}"  );
     $new_elab_db->db_put( "VLNV","${vlnv}"  );
#     print "VLNV  $vlnv \nVLNV -> $new_elab_db_file_name  \n";
 
 
     $new_elab_db->db_close();
     }
     }
   return(0);
   return(0);
   }
   }
 
 

powered by: WebSVN 2.1.0

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