URL
https://opencores.org/ocsvn/socgen/socgen/trunk
Subversion Repositories socgen
[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_root] - 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,
"configuration=s" => \$configuration,
"dest_dir=s" => \$dest_dir,
"env=s" => \$env,
"tool=s" => \$tool,
"unit=s" => \$unit,
"name=s" => \$name
) || die "(use '$program_name -h' for help)";
##############################################################################
## Help option
##############################################################################
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";
exit 1;
}
#############################################################################
##
##
#############################################################################
$home = cwd();
unless ($prefix)
{
$prefix = yp::lib::get_workspace();
$prefix = "/${prefix}";
}
my $variant;
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)
{
$destination = "${destination}_${name}";
}
else
{
# $name = $version;
$destination = "${destination}";
}
my $root = "root";
if($version) {$variant = "${component}_${version}";}
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";
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);
$dest_dir = yp::lib::get_io_ports();
my $path = "${home}/${dest_dir}";
mkdir $path,0755 unless( -e $path );
$path ="${path}/${vendor}__${library}";
mkdir $path,0755 unless( -e $path );
$path ="${path}/${component}";
mkdir $path,0755 unless( -e $path );
unless( -e "${path}/${destination}" )
{
# print "$path/${destination} does not exist... creating \n";
my $cmd = "mkdir $path/${destination} \n";
if(system($cmd)){};
}
if(defined $name)
{
$data_db_file = "${home}/dbs/${vendor}_${library}_${component}_${version}_${name}.db";
}
else
{
$data_db_file = "${home}/dbs/${vendor}_${library}_${component}_${version}.db";
}
#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 $key;
my $value;
my @elab_list;
my $cursor = $elab_db ->db_cursor() ;
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
{
( ${key_type},@elab_list) = split( /\./ , $key);
if(($key_type eq "component___${root}"))
{
build_hierarchy ($value,"${path}/${destination}",$root,@elab_list);
}
}
my $status = $cursor->c_close() ;
$cursor = $elab_db ->db_cursor() ;
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
{
$_ = $key;
if(/parameter_${root}__(\S+)/)
{
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( "$key","${value}");
$param_db->db_close();
}
elsif (/parameter_${root}(\S+)__(\S+)/)
{
my $xpath = $1;
$xpath =~ s/\./\//g;
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}: $!";
$param_db->db_put( "$key","${value}");
$param_db->db_close();
}
}
$status = $cursor->c_close() ;
$cursor = $elab_db ->db_cursor() ;
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
{
$_ = $key;
if(/busInterface_${root}__(\S+)/)
{
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( "$key","${value}");
$param_db->db_close();
}
elsif(/busInterface_${root}(\S+)__(\S+)/)
{
my $xpath = $1;
my $parname = $2;
$xpath =~ s/\./\//g;
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}: $!";
$param_db->db_put( "$key","${value}");
$param_db->db_close();
}
}
$status = $cursor->c_close() ;
$elab_db->db_close();
#/*********************************************************************************************/
#/ */
#/ */
#/ */
#/ */
#/ */
#/ */
#/*********************************************************************************************/
sub build_hierarchy
{
my @params = @_;
my $vlnv = shift(@params);
my $path = shift(@params);
my $root = shift(@params);
my $top = shift(@params);
my $new_elab_db ;
my $new_elab_db_file_name ;
# print "Hier $path \nHier- $root $top --- @params \n";
$path ="${path}/${root}";
unless(-e $path)
{
$cmd ="mkdir ${path} \n";
if(system($cmd)){}
# print "Create Dir ${path} \n";
}
unless (-e "${path}/${top}")
{
$cmd ="mkdir ${path}/${top} \n";
if(system($cmd)){}
}
$new_elab_db_file_name = "${path}/${top}/Index.db";
if(@params)
{
build_hierarchy ("$vlnv","${path}","${top}",@params);
}
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->db_put( "VLNV","${vlnv}" );
# print "VLNV $vlnv \nVLNV -> $new_elab_db_file_name \n";
}
return(0);
}
1
Go to most recent revision | Compare with Previous | Blame | View Log