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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_design] - Diff between revs 134 and 135

Only display areas with differences | Details | Blame | View Log

Rev 134 Rev 135
eval 'exec `which perl` -S $0 ${1+"$@"}'
eval 'exec `which perl` -S $0 ${1+"$@"}'
   if 0;
   if 0;
#/**********************************************************************/
#/****************************************************************************/
#/*                                                                    */
#/*                                                                    */
#/*             -------                                                */
#/*   SOCGEN Design for Reuse toolset                                        */
#/*            /   SOC  \                                              */
 
#/*           /    GEN   \                                             */
 
#/*          /    TOOL    \                                            */
 
#/*          ==============                                            */
 
#/*          |            |                                            */
 
#/*          |____________|                                            */
 
#/*                                                                    */
#/*                                                                    */
 
#/*   Version 1.0.0                                                          */
#/*                                                                    */
#/*                                                                    */
 
#/*   Author(s):                                                             */
 
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
#/*                                                                    */
#/*                                                                    */
 
#/****************************************************************************/
#/*                                                                    */
#/*                                                                    */
#/*  Author(s):                                                        */
 
#/*      - John Eaton, jt_eaton@opencores.org                          */
 
#/*                                                                    */
#/*                                                                    */
#/**********************************************************************/
#/*             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                                  */
#/*                                                                    */
#/*                                                                    */
#/*    Copyright (C) <2010-2011>                */
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
#/*                                                                    */
#/*                                                                    */
#/*  This source file may be used and distributed without              */
#/* Unless required by applicable law or agreed to in writing, software      */
#/*  restriction provided that this copyright statement is not         */
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
#/*  removed from the file and that any derivative work contains       */
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
#/*  the original copyright notice and the associated disclaimer.      */
#/* See the License for the specific language governing permissions and      */
#/*                                                                    */
#/* limitations under the License.                                           */
#/*  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
# 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,
           "name=s"      => \$name,
           "name=s"      => \$name,
           "dest_dir=s"  => \$dest_dir
           "dest_dir=s"  => \$dest_dir
) || 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_design -envidentifier {sim/syn}  -prefix /work -vendor vendor_name -library library_name  -component component_name  -version version_name      \n";
  { print "\n gen_design -envidentifier {sim/syn}  -prefix /work -vendor vendor_name -library library_name  -component component_name  -version version_name      \n";
    exit 1;
    exit 1;
  }
  }
#############################################################################
#############################################################################
##
##
##
##
#############################################################################
#############################################################################
$home = cwd();
$home = cwd();
my @elab_config_cmds = ();
my @elab_config_cmds = ();
unless ($prefix)
unless ($prefix)
 {
 {
 $prefix   = yp::lib::get_workspace();
 $prefix   = yp::lib::get_workspace();
 $prefix   =  "/${prefix}";
 $prefix   =  "/${prefix}";
 }
 }
my   $configuration;
my   $configuration;
my   $config_index;
my   $config_index;
my $DEST_file;
my $DEST_file;
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
my $destination         = "${main_module_name}";
my $destination         = "${main_module_name}";
if(defined $name)
if(defined $name)
{
{
$destination = "${destination}_${name}";
$destination = "${destination}_${name}";
}
}
my $root_name = "${vendor}_${library}_${component}_${version}";
my $root_name = "${vendor}_${library}_${component}_${version}";
my $root                =      "root";
my $root                =      "root";
print "gen_design  -vendor $vendor -library $library -component $component -version $version  -name $name    \n";
print "gen_design  -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 $path;
my $path;
my $dest_dir    = yp::lib::get_io_ports;
my $dest_dir    = yp::lib::get_io_ports;
$path  = "${home}/${dest_dir}";
$path  = "${home}/${dest_dir}";
mkdir $path,0755       unless( -e $path );
mkdir $path,0755       unless( -e $path );
my $elab_db_file;
my $elab_db_file;
if($name)
if($name)
{
{
 $elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,$name);
 $elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,$name);
}
}
else
else
{
{
 $elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,"default");
 $elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,"default");
}
}
#print "ELAB_XXXXX gen design $elab_db_file  \n";
#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 $elab_db  = new BerkeleyDB::Hash( -Filename => "$elab_db_file", -Flags => DB_CREATE ) or die "Cannot open $elab_db_file: $!";
my $repo_data;
my $repo_data;
$elab_db->db_get("VLNV___${vendor}:${library}:${component}:${version}", $repo_data );
$elab_db->db_get("VLNV___${vendor}:${library}:${component}:${version}", $repo_data );
#print "GEN_DESIGN  $elab_db_file $repo_data \n";
#print "GEN_DESIGN  $elab_db_file $repo_data \n";
$design_db_file  = yp::lib::get_design_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: $!";
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
# Grab the pointer to the last config used, if none then start it
$design_db->db_get("INDEX", $config_index );
$design_db->db_get("INDEX", $config_index );
unless(defined $config_index)
unless(defined $config_index)
{
{
$config_index = 1;
$config_index = 1;
}
}
$design_db->db_put( "INDEX","$config_index"  );
$design_db->db_put( "INDEX","$config_index"  );
# Provide a default for components with no parameters
# Provide a default for components with no parameters
$design_db->db_put( "CONFIG___","config_0"  );
$design_db->db_put( "CONFIG___","config_0"  );
my $key;
my $key;
my $value;
my $value;
$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)
   {
   {
   my $vlnv;
   my $vlnv;
   my $VLNV;
   my $VLNV;
   ( ${VLNV},${vlnv}) = split( /___/ , $key);
   ( ${VLNV},${vlnv}) = split( /___/ , $key);
   if($VLNV eq "VLNV")
   if($VLNV eq "VLNV")
     {
     {
     my $ven;
     my $ven;
     my $lib;
     my $lib;
     my $cmp;
     my $cmp;
     my $ver;
     my $ver;
   ( ${ven},${lib},${cmp},${ver}) = split( /:/ , $vlnv);
   ( ${ven},${lib},${cmp},${ver}) = split( /:/ , $vlnv);
   my $design_lib  = "${path}/${ven}__${lib}";
   my $design_lib  = "${path}/${ven}__${lib}";
   mkdir $design_lib,0755    unless(-e  $design_lib  );
   mkdir $design_lib,0755    unless(-e  $design_lib  );
   my $design_cmp  = "${path}/${ven}__${lib}/${cmp}";
   my $design_cmp  = "${path}/${ven}__${lib}/${cmp}";
   mkdir $design_cmp,0755  unless(-e  $design_cmp  );
   mkdir $design_cmp,0755  unless(-e  $design_cmp  );
   $main_module_name = yp::lib::get_module_name($ven,$lib,$cmp,$ver) ;
   $main_module_name = yp::lib::get_module_name($ven,$lib,$cmp,$ver) ;
   my $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";
   my $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";
   if("${vendor}_${library}_${component}_${version}" eq "${ven}_${lib}_${cmp}_${ver}")
   if("${vendor}_${library}_${component}_${version}" eq "${ven}_${lib}_${cmp}_${ver}")
      {
      {
      if(defined $name)
      if(defined $name)
         {
         {
         $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";
         $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";
         }
         }
      else
      else
         {
         {
         $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";
         $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";
         }
         }
      }
      }
   mkdir $design_ver,0755  unless(-e  $design_ver  );
   mkdir $design_ver,0755  unless(-e  $design_ver  );
   my @insts;
   my @insts;
   ( @insts) = split( /:::/ , $value);
   ( @insts) = split( /:::/ , $value);
  foreach my $inst (@insts)
  foreach my $inst (@insts)
     {
     {
     my @params;
     my @params;
     $P_cursor = $elab_db ->db_cursor() ;
     $P_cursor = $elab_db ->db_cursor() ;
     while ($P_cursor->c_get($key, $value, DB_NEXT) == 0)
     while ($P_cursor->c_get($key, $value, DB_NEXT) == 0)
       {
       {
       my $vlnv;
       my $vlnv;
       my $VLNV;
       my $VLNV;
       ( ${VLNV},${vlnv}) = split( /__/ , $key);
       ( ${VLNV},${vlnv}) = split( /__/ , $key);
       if(${VLNV}  eq "parameter_${inst}"   )
       if(${VLNV}  eq "parameter_${inst}"   )
         {
         {
         push @params, "${vlnv}--${value}";
         push @params, "${vlnv}--${value}";
         }
         }
       }
       }
     my $status = $P_cursor->c_close() ;
     my $status = $P_cursor->c_close() ;
     my $outfile = "${design_ver}/${root_name}_${inst}";
     my $outfile = "${design_ver}/${root_name}_${inst}";
     $outfile =~s/_root//;
     $outfile =~s/_root//;
     if(defined $name)
     if(defined $name)
       {
       {
       $outfile = "${outfile}_${name}";
       $outfile = "${outfile}_${name}";
       }
       }
     $DEST_file = $outfile;
     $DEST_file = $outfile;
     @params = sys::lib::trim_sort(@params);
     @params = sys::lib::trim_sort(@params);
     my $param_str;
     my $param_str;
     foreach my $param (@params)
     foreach my $param (@params)
       {
       {
       $param_str = "${param}:::${param_str}";
       $param_str = "${param}:::${param_str}";
       }
       }
     my $config_data = "none";
     my $config_data = "none";
     $design_db->db_get("CONFIG___${param_str}", $config_data );
     $design_db->db_get("CONFIG___${param_str}", $config_data );
     if( $config_data eq "none" )
     if( $config_data eq "none" )
       {
       {
       $config_index = $config_index + 1;
       $config_index = $config_index + 1;
       $design_db->db_put( "CONFIG___${param_str}","config_${config_index}"  );
       $design_db->db_put( "CONFIG___${param_str}","config_${config_index}"  );
       $config_data ="config_${config_index}"
       $config_data ="config_${config_index}"
       }
       }
     my $outfile = "${design_ver}/${config_data}";
     my $outfile = "${design_ver}/${config_data}";
     mkdir $outfile,0755       unless( -e $outfile );
     mkdir $outfile,0755       unless( -e $outfile );
     $Busses_file = "${design_ver}/${config_data}/BUSSES.db";
     $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}: $!";
    $Busses_db  = new BerkeleyDB::Hash( -Filename => "$Busses_file", -Flags => DB_CREATE ) or die "Cannot open ${Busses_file}: $!";
    foreach my $param (@params)
    foreach my $param (@params)
       {
       {
       my $name;
       my $name;
       my $value;
       my $value;
       ( ${name},${value}) = split( /--/ , $param);
       ( ${name},${value}) = split( /--/ , $param);
       $Busses_db->db_put( "Param_${name}","${value}");
       $Busses_db->db_put( "Param_${name}","${value}");
       }
       }
       $Busses_db->db_close();
       $Busses_db->db_close();
       $DEST_file = "${DEST_file}_${config_data}";
       $DEST_file = "${DEST_file}_${config_data}";
       open  DEST_FILE,">$DEST_file" or die "unable to open $DEST_file";
       open  DEST_FILE,">$DEST_file" or die "unable to open $DEST_file";
       print DEST_FILE " $param_str \n";
       print DEST_FILE " $param_str \n";
       close  DEST_FILE;
       close  DEST_FILE;
       my $cmd = "./tools/verilog/elab_config_verilog -vendor ${ven} -library ${lib} -component ${cmp} -version ${ver}  -configuration $config_data \n";
       my $cmd = "./tools/verilog/elab_config_verilog -vendor ${ven} -library ${lib} -component ${cmp} -version ${ver}  -configuration $config_data \n";
       push @elab_config_cmds, $cmd;
       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";
       my $cmd = "./tools/verilog/gen_root -vendor ${ven} -library ${lib} -component ${cmp} -version ${ver} -configuration $config_data -name  $config_data \n";
#       if(system($cmd)){};
#       if(system($cmd)){};
    $Index_file = "${design_ver}/Config.db";
    $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  = 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_put( "${config_data}","Config");
    $Index_db->db_close();
    $Index_db->db_close();
       if(defined $param_str)
       if(defined $param_str)
         {
         {
         if(defined $name)
         if(defined $name)
           {
           {
           $design_db->db_put( "instance_${root_name}_${name}_${inst}","${ven}:${lib}:${cmp}:${ver}:${config_data}"  );
           $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}"  );
           $design_db->db_put( "Params__${ven}_${lib}_${cmp}_${ver}__${param_str}"  ,"${root_name}_${name}_${inst}"  );
           }
           }
         else
         else
           {
           {
           $design_db->db_put( "instance_${root_name}_${inst}","${ven}:${lib}:${cmp}:${ver}:${config_data}"  );
           $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}"  );
           $design_db->db_put( "params__${ven}_${lib}_${cmp}_${ver}__${param_str}"  ,"${root_name}_${inst}"  );
           }
           }
         }
         }
      }
      }
     }
     }
   }
   }
   my $status = $cursor->c_close() ;
   my $status = $cursor->c_close() ;
   $design_db->db_put( "INDEX","${config_index}"  );
   $design_db->db_put( "INDEX","${config_index}"  );
   $elab_db     -> db_close();
   $elab_db     -> db_close();
   $design_db   -> db_close();
   $design_db   -> db_close();
   @elab_config_cmds = sys::lib::trim_sort(@elab_config_cmds);
   @elab_config_cmds = sys::lib::trim_sort(@elab_config_cmds);
foreach my $cmd (@elab_config_cmds)
foreach my $cmd (@elab_config_cmds)
{
{
       if(system($cmd)){};
       if(system($cmd)){};
}
}
1
1
 
 

powered by: WebSVN 2.1.0

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