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

Subversion Repositories socgen

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

Compare with Previous | Blame | View Log

eval 'exec `which perl` -S $0 ${1+"$@"}'
   if 0;
#/****************************************************************************/
#/*                                                                          */
#/*   SOCGEN Design for Reuse toolset                                        */
#/*                                                                          */
#/*   Version 1.0.0                                                          */
#/*                                                                          */
#/*   Author(s):                                                             */
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
#/*                                                                          */
#/****************************************************************************/
#/*                                                                          */
#/*                                                                          */
#/*             Copyright 2016 John T Eaton                                  */ 
#/*                                                                          */
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
#/* you may not use this file except in compliance with the License.         */
#/* You may obtain a copy of the License at                                  */
#/*                                                                          */
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
#/*                                                                          */
#/* Unless required by applicable law or agreed to in writing, software      */
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
#/* See the License for the specific language governing permissions and      */
#/* limitations under the License.                                           */
#/*                                                                          */
#/*                                                                          */
#/****************************************************************************/



############################################################################
# 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

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.