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

Subversion Repositories socgen

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

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();
my @elab_config_cmds = ();

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


my   $configuration;
my   $config_index;


my $DEST_file;
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";


print "gen_design  -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 );

my $elab_db_file;

if($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");
}



#print "ELAB_XXXXX gen design $elab_db_file  \n";

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

my $repo_data;
$elab_db->db_get("VLNV___${vendor}:${library}:${component}:${version}", $repo_data );

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


$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: $!";


# Grab the pointer to the last config used, if none then start it


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

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

# Provide a default for components with no parameters

$design_db->db_put( "CONFIG___","config_0"  );

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}";
         }
      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 $status = $P_cursor->c_close() ;



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

 
     $DEST_file = $outfile;
     @params = sys::lib::trim_sort(@params);

     my $param_str;

     foreach my $param (@params)
       {
       $param_str = "${param}:::${param_str}";
       }

     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}"
       }



     my $outfile = "${design_ver}/${config_data}";
     mkdir $outfile,0755       unless( -e $outfile );

     $Busses_file = "${design_ver}/${config_data}/BUSSES.db"; 


    $Busses_db  = new BerkeleyDB::Hash( -Filename => "$Busses_file", -Flags => DB_CREATE ) or die "Cannot open ${Busses_file}: $!";

    foreach my $param (@params)
       {
       my $name;
       my $value;
 
       ( ${name},${value}) = split( /--/ , $param);

       $Busses_db->db_put( "Param_${name}","${value}");

       }


       $Busses_db->db_close();


       $DEST_file = "${DEST_file}_${config_data}";

       open  DEST_FILE,">$DEST_file" or die "unable to open $DEST_file";   
       print DEST_FILE " $param_str \n";

       close  DEST_FILE;

       my $cmd = "./tools/verilog/elab_config_verilog -vendor ${ven} -library ${lib} -component ${cmp} -version ${ver}  -configuration $config_data \n";

       push @elab_config_cmds, $cmd;

       my $cmd = "./tools/verilog/gen_root -vendor ${ven} -library ${lib} -component ${cmp} -version ${ver} -configuration $config_data -name  $config_data \n"; 
#       if(system($cmd)){};



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



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





       if(defined $param_str)
         {
         if(defined $name) 
           {
           $design_db->db_put( "instance_${root_name}_${name}_${inst}","${ven}:${lib}:${cmp}:${ver}:${config_data}"  );
           $design_db->db_put( "Params__${ven}_${lib}_${cmp}_${ver}__${param_str}"  ,"${root_name}_${name}_${inst}"  );
           }
         else
           {
           $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();

   @elab_config_cmds = sys::lib::trim_sort(@elab_config_cmds);


foreach my $cmd (@elab_config_cmds)
{

       if(system($cmd)){};

}




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.