URL
https://opencores.org/ocsvn/socgen/socgen/trunk
Subversion Repositories socgen
[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_root] - 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,"configuration=s" => \$configuration,"dest_dir=s" => \$dest_dir,"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 -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);if($name){$destination = "${destination}";}else{$destination = "${destination}";}my $root = "root";if($version) {$variant = "${component}_${version}";}else {$variant = "${component}";}print "GEN_ROOT -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 $elab_db_file;if(defined $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");}my $elab_db = new BerkeleyDB::Hash( -Filename => "$elab_db_file", -Flags => DB_CREATE ) or die "Cannot open $elab_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: $!";unless (defined $configuration && length $configuration > 0){my $h_ven;my $h_lib;my $h_cmp;my $h_ver;my $h_config;my $config_key;my $config_index;if(defined $name){$config_key ="instance_${vendor}_${library}_${component}_${version}_${name}_root";}else{$config_key ="instance_${vendor}_${library}_${component}_${version}_root";}$design_db->db_get($config_key, $config_index );( ${h_ven},${h_lib},${h_cmp},${h_ver},${h_config}) = split( /\:/ , $config_index);$configuration = $h_config;}$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}" ){my $cmd = "mkdir $path/${destination} \n";if(system($cmd)){};}$destination ="${destination}/${configuration}";unless( -e "${path}/${destination}" ){my $cmd = "mkdir $path/${destination} \n";if(system($cmd)){};}if( -e "${path}/${destination}/root" ){exit;#print "${path}/${destination}/root exists \n";}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() ;my @file_names = ();my $file_name = "${path}/${destination}/${root}/Index.db";push @file_names, $file_name;$cursor = $elab_db ->db_cursor() ;while ($cursor->c_get($key, $value, DB_NEXT) == 0){$_ = $key;if($key eq "component___root"){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( "PATH","root");$param_db->db_put( "VLNV","${value}");$param_db->db_close();}elsif (/component___root\.(\S+)/){my $xpath = $1;my $ypath = $1;$xpath =~ s/\./\//g;my $file_name = "${path}/${destination}/root/${xpath}/Index.db";push @file_names, $file_name;my $param_db = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";$param_db->db_put( "PATH","root.${ypath}");$param_db->db_put( "VLNV","${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(/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;my $ypath = $1;$xpath =~ s/\./\//g;my $file_name = "${path}/${destination}/${root}${xpath}/Index.db";push @file_names, $file_name;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 $ypath = $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() ;# here we read the vlnv from param_db# open it's BUSSES.dbm# copy all contents# modify vector left:right by parsing parameters# print "IIIIIIIIX $VLNV_copy \n";foreach my $param_c (@param_copy){#print "IIIIIIIII $param_c \n";}$elab_db->db_close();@file_names = sys::lib::trim_sort(@file_names);foreach my $file_name (@file_names){my $cmd ="./tools/verilog/tag_Index.db $file_name \n";if(system($cmd)){}}#/*********************************************************************************************/#/ */#/ */#/ */#/ */#/ */#/ */#/*********************************************************************************************/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 ;$path ="${path}/${root}";unless(-e $path){$cmd ="mkdir ${path} \n";if(system($cmd)){}}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{$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}" );$new_elab_db->db_close();}return(0);}1
