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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_design] - Rev 133

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

eval 'exec `which perl` -S $0 ${1+"$@"}'
   if 0;
#/**********************************************************************/
#/*                                                                    */
#/*             -------                                                */
#/*            /   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                          */
#/*                                                                    */
#/**********************************************************************/


############################################################################
# General PERL config
############################################################################
use Getopt::Long;
use English;
use File::Basename;
use Cwd;
use Scalar::Util qw(looks_like_number);
use XML::LibXML;
use lib './tools';
use sys::lib;
use yp::lib;
use BerkeleyDB;


$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.


############################################################################
### Process the options
############################################################################
Getopt::Long::config("require_order", "prefix=-");
GetOptions("h","help",
           "envidentifier=s" => \$envidentifier,
           "prefix=s"    => \$prefix,
           "vendor=s"    => \$vendor,
           "library=s"   => \$library,
           "component=s" => \$component,
           "version=s"   => \$version,
           "name=s"      => \$name,
           "dest_dir=s"  => \$dest_dir

) || die "(use '$program_name -h' for help)";



##############################################################################
## Help option
##############################################################################
if ( $opt_h  or $opt_help  ) 
  { print "\n gen_design -envidentifier {sim/syn}  -prefix /work -vendor vendor_name -library library_name  -component component_name  -version version_name      \n";
    exit 1;
  }



#############################################################################
## 
## 
#############################################################################

$home = cwd();


unless ($prefix)
 {
 $prefix   = yp::lib::get_workspace();
 $prefix   =  "/${prefix}";
 }


my   $variant;
my   $configuration;
my   $config_index;




my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
my $destination         = "${main_module_name}";

if(defined $name)
{
$destination = "${destination}_${name}";
}


my $root_name = "${vendor}_${library}_${component}_${version}";




my $root                =      "root";

if($version)       {$variant   = "${component}_${version}";}
else               {$variant   = "${component}";}

if($name)         {$variant   = "${variant}_${name}";}



#print "gen_design -prefix $prefix -vendor $vendor -library $library -component $component -version $version  -name $name    \n";


my $parser = XML::LibXML->new();


my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));

unless ($socgen_file)      { print "No socgen ip file   \n";};


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 $path;

my $dest_dir    = yp::lib::get_io_ports;

$path  = "${home}/${dest_dir}";

mkdir $path,0755       unless( -e $path );


$data_db_file  = "${home}/dbs/${vendor}_${library}_${variant}.db";



if(-e  $data_db_file  )
        {
#        print "$data_db_file  does exist  \n";

        }



#print "ELAB_XXXXX gen design $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 $repo_data;
$elab_db->db_get("VLNV___${vendor}:${library}:${component}:${version}", $repo_data );

#print "GEN_DESIGN  $data_db_file $repo_data \n";


$design_db_file  = "${home}/dbs/design.dbm";

my $design_db  = new BerkeleyDB::Hash( -Filename => "$design_db_file", -Flags => DB_CREATE ) or die "Cannot open $design_db_file: $!";

$design_db->db_get("INDEX", $config_index );

unless(defined $config_index)
{
$config_index = 1;
}
$design_db->db_put( "INDEX","$config_index"  );


my $key;
my $value;


   $cursor = $elab_db ->db_cursor() ;
   while ($cursor->c_get($key, $value, DB_NEXT) == 0) 
   {
   my $vlnv;
   my $VLNV;

   ( ${VLNV},${vlnv}) = split( /___/ , $key);
   if($VLNV eq "VLNV") 
     {
     my $ven;
     my $lib;
     my $cmp;
     my $ver;
   ( ${ven},${lib},${cmp},${ver}) = split( /:/ , $vlnv);

my $design_lib  = "${path}/${ven}__${lib}";


mkdir $design_lib,0755    unless(-e  $design_lib  );
my $design_cmp  = "${path}/${ven}__${lib}/${cmp}";

mkdir $design_cmp,0755  unless(-e  $design_cmp  );



$main_module_name = yp::lib::get_module_name($ven,$lib,$cmp,$ver) ;

my $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";



if("${vendor}_${library}_${component}_${version}" eq "${ven}_${lib}_${cmp}_${ver}") 
  {
  if(defined $name)
    {
    $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}_${name}";
    }
  else
    {
    $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";
    }
  }


mkdir $design_ver,0755  unless(-e  $design_ver  );


my @insts;


   ( @insts) = split( /:::/ , $value);
  foreach my $inst (@insts)
   {
   my @params;
   $P_cursor = $elab_db ->db_cursor() ;
   while ($P_cursor->c_get($key, $value, DB_NEXT) == 0) 
   {
   my $vlnv;
   my $VLNV;

   ( ${VLNV},${vlnv}) = split( /__/ , $key);
    if(${VLNV}  eq "parameter_${inst}"   )
     {
     push @params, "${vlnv}--${value}";
     }

   }

  my $design_name ="$${root_name}_${inst}";
     $design_name =~s/_root//;



  my $outfile = "${design_ver}/${root_name}_${inst}";
     $outfile =~s/_root//;
if(defined $name)
  {
  $outfile = "${outfile}_${name}";
  }

  open  DEST_FILE,">$outfile" or die "unable to open $outfile";   
  @params = sys::lib::trim_sort(@params);




my $param_str;

  foreach my $param (@params)
   {
   print DEST_FILE "${param}  \n";
   $param_str = "${param}:::${param_str}";
   }
   close  DEST_FILE;

   my $status = $P_cursor->c_close() ;







my $config_data = "none";

$design_db->db_get("CONFIG___${param_str}", $config_data );






if( $config_data eq "none" )
  {
  $config_index = $config_index + 1;
  $design_db->db_put( "CONFIG___${param_str}","config_${config_index}"  );
  $config_data ="config_${config_index}"
  }


if(defined $name)
  {
  $design_db->db_put( "TOP_${ven}__${lib}_${cmp}_${main_module_name}_${name}","$param_str"  );
  $design_db->db_put( "TAP_${ven}__${lib}_${cmp}_${main_module_name}_${name}","$config_data"  );
  }




$Index_file = "${design_ver}/Config.db"; 

if(-e"${design_ver}/root/Index.db" )
  {
#  print "TOP LEVEL  gen_design Config.db   $Index_file \n";
  }


    $Index_db  = new BerkeleyDB::Hash( -Filename => "$Index_file", -Flags => DB_CREATE ) or die "Cannot open ${Index_file}: $!";
    $Index_db->db_put( "CONFIG","${config_data}");
    $Index_db->db_close();




my $outfile = "${design_ver}/${config_data}";
open  DEST_FILE,">$outfile" or die "unable to open $outfile";   

  foreach my $param (@params)
   {
   print DEST_FILE "${param}  \n";
   }

close  DEST_FILE;





if($param_str)
 {
 $design_db->db_put( "instance_${root_name}_${inst}","${ven}:${lib}:${cmp}:${ver}:${config_data}"  );
 $design_db->db_put( "params__${ven}_${lib}_${cmp}_${ver}__${param_str}"  ,"${root_name}_${inst}"  );
 }
   }
     } 
   }

   my $status = $cursor->c_close() ;
   $design_db->db_put( "INDEX","${config_index}"  );
   $elab_db     -> db_close();
   $design_db   -> db_close();






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.