URL
https://opencores.org/ocsvn/socgen/socgen/trunk
Subversion Repositories socgen
[/] [socgen/] [trunk/] [tools/] [busdefs/] [gen_busdef] - 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",
"vendor=s" => \$vendor,
"library=s" => \$library,
"version=s" => \$version,
"component=s" => \$component,
"debug","verbose"
) || die "(use '$program_name -h' for help)";
##############################################################################
## Help option
##############################################################################
if ( $opt_h or $opt_help )
{ print "\n gen_busdef -vendor vendor_name -library library_name -component component_name -version version_name ";
print "\n";
exit 1;
}
#############################################################################
##
##
#############################################################################
$home = cwd();
my $variant;
my $parser = XML::LibXML->new();
#print "\n GEN_busdef $vendor $library $component $version \n";
my $io_ports = yp::lib::get_io_ports() ;
my $path = "${io_ports}";
mkdir $path,0755 unless( -e $path );
$path = "${io_ports}/${vendor}__${library}";
mkdir $path,0755 unless( -e $path );
$path = "${io_ports}/${vendor}__${library}/${component}";
mkdir $path,0755 unless( -e $path );
$filename ="${io_ports}/${vendor}__${library}/${component}/${component}_${version}_ABSDEF.dbm";
if(-e ${filename} )
{
print " $filename Exists, exiting \n";
exit 0;
}
$absDef_db = new BerkeleyDB::Hash( -Filename => $filename, -Flags => DB_CREATE ) or die "Cannot open file: $!";
my $spirit_file = yp::lib::find_ipxact_abstractionDefinition($vendor,$library,$component,$version);
# print "\tFilename: ${spirit_file}\n";
unless ($spirit_file) {print "Error absDef $vendor $library $component $version file does not exist";}
my $spirit_absDef_file = $parser->parse_file($spirit_file);
foreach my $absDef ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:vendor"))
{
my($bd_vendor) = $absDef->findnodes('./text()')->to_literal ;
my($bd_library) = $absDef->findnodes('../ipxact:library/text()')->to_literal ;
my($bd_name) = $absDef->findnodes('../ipxact:name/text()')->to_literal ;
my($bd_version) = $absDef->findnodes('../ipxact:version/text()')->to_literal ;
# print "\tVLNV-ad ${bd_vendor}_${bd_library}_${bd_name}_${bd_version}\n";
my %systemGroupNames = ();
foreach my $bus_type ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:busType"))
{
my($bt_vendor) = $bus_type->findnodes('./@vendor')->to_literal ;
my($bt_library) = $bus_type->findnodes('./@library')->to_literal ;
my($bt_name) = $bus_type->findnodes('./@name')->to_literal ;
my($bt_version) = $bus_type->findnodes('./@version')->to_literal ;
# print "\tVLNV-bt ${bt_vendor}_${bt_library}_${bt_name}_${bt_version}\n";
my $spirit_file = yp::lib::find_ipxact_busDefinition($bt_vendor,$bt_library,$bt_name,$bt_version);
unless ($spirit_file) {print "ERROR: No bus definition ${bd_vendor}:${bd_library}:${bd_name}:${bd_version} \n";}
else
{
my $spirit_busDef_file = $parser->parse_file($spirit_file);
foreach my $i_name ($spirit_busDef_file->findnodes("//ipxact:busDefinition/ipxact:systemGroupNames/ipxact:systemGroupName"))
{
my($sysgroup_name) = $i_name ->findnodes('./text()')->to_literal;
# print "\t SystemGroup Name $sysgroup_name \n";
$systemGroupNames{$sysgroup_name} = 1;
}
}
}
foreach my $absDef ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:ports/ipxact:port/ipxact:logicalName"))
{
my($logical_name) = $absDef->findnodes('./text()')->to_literal ;
my($is_clock) = $absDef->findnodes('../ipxact:wire/ipxact:qualifier/ipxact:isClock/text()')->to_literal ;
my($is_reset) = $absDef->findnodes('../ipxact:wire/ipxact:qualifier/ipxact:isReset/text()')->to_literal ;
my($is_address) = $absDef->findnodes('../ipxact:wire/ipxact:qualifier/ipxact:isAddress/text()')->to_literal ;
my($is_data) = $absDef->findnodes('../ipxact:wire/ipxact:qualifier/ipxact:isData/text()')->to_literal ;
my($requires_driver) = $absDef->findnodes('../ipxact:wire/ipxact:requiresDriver/text()')->to_literal ;
my($driver_type) = $absDef->findnodes('../ipxact:wire/ipxact:requiresDriver/@ipxact:driverType')->to_literal ;
my($default_value) = $absDef->findnodes('../ipxact:wire/ipxact:defaultValue/text()')->to_literal ;
# print "\nPort: ${logical_name} ";
my $Key = "port__${logical_name}" ;
my @info = ("$logical_name","$is_clock","$is_reset","$is_address","$is_data","$requires_driver","$driver_type","$default_value" );
$absDef_db->db_put( $Key, join(':', @info) );
my $master_presence;
my $master_width;
my $master_direction;
foreach my $onMaster ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:ports/ipxact:port/ipxact:logicalName[text() = '$logical_name']/../ipxact:wire/ipxact:onMaster/ipxact:direction"))
{
$master_direction = $onMaster->findnodes('./text()')->to_literal ;
$master_width = $onMaster->findnodes('../ipxact:width/text()')->to_literal ;
$master_presence = $onMaster->findnodes('../ipxact:presence/text()')->to_literal ;
#print " onMaster presence $master_presence \n";
#unless($master_width) {$master_width = 1;}
#print "\n";
if($master_direction eq "in") {$master_direction = "input";}
if($master_direction eq "out"){$master_direction = "output";}
my $Key = "master__${logical_name}" ;
my @info = ("$logical_name","$master_presence","$master_width","$master_direction" );
$absDef_db->db_put( $Key, join(':', @info) );
#print "PUT $Key @info \n";
}
my $slave_presence;
my $slave_width;
my $slave_direction;
foreach my $onSlave ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:ports/ipxact:port/ipxact:logicalName[text() = '$logical_name']/../ipxact:wire/ipxact:onSlave/ipxact:direction"))
{
$slave_direction = $onSlave->findnodes('./text()')->to_literal ;
$slave_width = $onSlave->findnodes('../ipxact:width/text()')->to_literal ;
$slave_presence = $onSlave->findnodes('../ipxact:presence/text()')->to_literal ;
#print " onSlave presence $slave_presence \n";
#unless($slave_width) {$slave_width = 1;}
#print "\n";
if($slave_direction eq "in") {$slave_direction = "input";}
if($slave_direction eq "out"){$slave_direction = "output";}
my $Key = "slave__${logical_name}" ;
my @info = ("$logical_name","$slave_presence","$slave_width","$slave_direction" );
$absDef_db->db_put( $Key, join(':', @info) );
#print "PUT $Key @info \n";
}
my %systemGroupPresence= ();
my %systemGroupWidth= ();
my %systemGroupDirection= ();
foreach my $onSystem ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:ports/ipxact:port/ipxact:logicalName[text() = '$logical_name']/../ipxact:wire/ipxact:onSystem/ipxact:group"))
{
my($system_group) = $onSystem->findnodes('./text()')->to_literal ;
my($presence) = $onSystem->findnodes('../ipxact:presence/text()')->to_literal ;
my($width) = $onSystem->findnodes('../ipxact:width/text()')->to_literal ;
my($direction) = $onSystem->findnodes('../ipxact:direction/text()')->to_literal ;
#print " onSystem Group $system_group \n";
#print " onSystem presence $presence \n";
#unless($width) {$width = 1;}
#print "\n";
my $Key = "system__${logical_name}" ;
my @info = ("$logical_name","$system_group","$presence","$width","$direction" );
$absDef_db->db_put( $Key, join(':', @info) );
#print "PUT $Key @info \n";
$systemGroupPresence{$system_group} =$presence ;
$systemGroupWidth{$system_group} =$width ;
$systemGroupDirection{$system_group} =$direction ;
}
# insert DRC checks here
}
}
$absDef_db->db_close();
#print "\n";