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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [busdefs/] [check_busDefs] - Rev 131

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

use Getopt::Long;
use English;
use File::Basename;
use Cwd;
use XML::LibXML;
use lib './tools';
use sys::lib;
use yp::lib;
use BerkeleyDB;


$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.

my $parser = XML::LibXML->new();
my $home    = cwd();


#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/


my @abstractionDefinitions = yp::lib::find_abstractionDefinitions();

my $version;
my $component;
my $library;
my $vendor;


foreach my $abstractionDefinition (@abstractionDefinitions)
{
 ( $vendor,$library, $component ,$version) = split ':', $abstractionDefinition;

          print "${vendor}:${library}:${component}:${version}\n";
          print "\t--------------------------------------------------------------------------------------------------------\n";

          $filename ="tools/busdefs/Berkeley/${vendor}_${library}_${component}_${version}.dbm";

          $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 file does not exist";}

          my $spirit_absDef_file   = $parser->parse_file($spirit_file);
          foreach my $absDef ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:vendor")) 
                {
                my($bd_vendor)         = $absDef->findnodes('./text()')->to_literal ;
                my($bd_library)        = $absDef->findnodes('../spirit:library/text()')->to_literal ;
                my($bd_name)           = $absDef->findnodes('../spirit:name/text()')->to_literal ;
                my($bd_version)        = $absDef->findnodes('../spirit: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("//spirit:abstractionDefinition/spirit:busType")) 
                   {
                   my($bt_vendor)        = $bus_type->findnodes('./@spirit:vendor')->to_literal ;
                   my($bt_library)       = $bus_type->findnodes('./@spirit:library')->to_literal ;
                   my($bt_name)          = $bus_type->findnodes('./@spirit:name')->to_literal ;
                   my($bt_version)       = $bus_type->findnodes('./@spirit: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\n";}
                   else
                     {
                     my $spirit_busDef_file   = $parser->parse_file($spirit_file);
                     foreach  my   $i_name ($spirit_busDef_file->findnodes("//spirit:busDefinition/spirit:systemGroupNames/spirit: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("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName")) 
                   {
                   my($logical_name)         = $absDef->findnodes('./text()')->to_literal ;
                   my($is_clock)             = $absDef->findnodes('../spirit:wire/spirit:qualifier/spirit:isClock/text()')->to_literal ;
                   my($is_reset)             = $absDef->findnodes('../spirit:wire/spirit:qualifier/spirit:isReset/text()')->to_literal ;
                   my($is_address)           = $absDef->findnodes('../spirit:wire/spirit:qualifier/spirit:isAddress/text()')->to_literal ;
                   my($is_data)              = $absDef->findnodes('../spirit:wire/spirit:qualifier/spirit:isData/text()')->to_literal ;
                   my($requires_driver)      = $absDef->findnodes('../spirit:wire/spirit:requiresDriver/text()')->to_literal ;
                   my($driver_type)          = $absDef->findnodes('../spirit:wire/spirit:requiresDriver/@spirit:driverType')->to_literal ;
                   my($default_value)        = $absDef->findnodes('../spirit:wire/spirit: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) );




                   
                   if($is_clock)    
                     {
                     if($is_reset)  { print "  BOTH CLOCK and RESET  ";}
                     else           { print "  CLOCK ";}
                     }
                   elsif($is_reset) { print "  RESET ";}
                   else             { print "  ";}

                   if($is_address) { print "  ADDRESS ";}
                   if($is_data) { print "  DATA ";}


                   if($requires_driver) {print " Requires Driver  $driver_type   ";}
                   else                 {print "   ";}

                   if($default_value)   {print " Default Value   $default_value  \n";}
                   else                 {print " \n";}

                   my $master_presence;
                   my $master_width;
                   my $master_direction;

                   foreach my $onMaster ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$logical_name']/../spirit:wire/spirit:onMaster/spirit:presence")) 
                    {
                    $master_presence    = $onMaster->findnodes('./text()')->to_literal ;
                    $master_width       = $onMaster->findnodes('../spirit:width/text()')->to_literal ;
                    $master_direction   = $onMaster->findnodes('../spirit:direction/text()')->to_literal ;
                    print "  onMaster presence    $master_presence \n";
                    #unless($master_width)     {$master_width = 1;}
                    if($master_width)  {print "  onMaster width       $master_width \n";}
                    if($master_direction) {print "  onMaster direction   $master_direction \n";}
                    print "\n";

                    my $Key = "master__${logical_name}"    ;
                    my @info  = ("$logical_name","$master_presence","$master_width","$master_direction"     );
                    $absDef_db->db_put( $Key, join(':', @info) );

                    }

                   my $slave_presence;
                   my $slave_width;
                   my $slave_direction;

                   foreach my $onSlave ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$logical_name']/../spirit:wire/spirit:onSlave/spirit:presence")) 
                    {
                    $slave_presence   = $onSlave->findnodes('./text()')->to_literal ;
                    $slave_width      = $onSlave->findnodes('../spirit:width/text()')->to_literal ;
                    $slave_direction  = $onSlave->findnodes('../spirit:direction/text()')->to_literal ;
                    print "  onSlave  presence    $slave_presence \n";
                    #unless($slave_width)     {$slave_width = 1;}
                    if($slave_width) {print "  onSlave  width       $slave_width \n";}
                    if($slave_direction) {print "  onSlave  direction   $slave_direction \n";}
                    print "\n";

                    my $Key = "slave__${logical_name}"    ;
                    my @info  = ("$logical_name","$slave_presence","$slave_width","$slave_direction"     );
                    $absDef_db->db_put( $Key, join(':', @info) );


                    }


                   my %systemGroupPresence= ();
                   my %systemGroupWidth= ();
                   my %systemGroupDirection= ();



                   foreach my $onSystem  ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$logical_name']/../spirit:wire/spirit:onSystem/spirit:group")) 
                    {
                    my($system_group)        = $onSystem->findnodes('./text()')->to_literal ;
                    my($presence)            = $onSystem->findnodes('../spirit:presence/text()')->to_literal ;
                    my($width)               = $onSystem->findnodes('../spirit:width/text()')->to_literal ;
                    my($direction)           = $onSystem->findnodes('../spirit:direction/text()')->to_literal ;
                    print "  onSystem Group       $system_group \n";
                    print "  onSystem presence    $presence \n";
                    #unless($width)     {$width = 1;}
                    if($width){print "  onSystem width       $width \n";}
                    if($direction){print "  onSystem direction   $direction \n";}
                    print "\n";

                    my $Key = "syste,__${logical_name}"    ;
                    my @info  = ("$logical_name","$system_group","$presence","$width","$direction"     );
                    $absDef_db->db_put( $Key, join(':', @info) );


                    $systemGroupPresence{$system_group} =$presence  ;
                    $systemGroupWidth{$system_group} =$width  ;
                    $systemGroupDirection{$system_group} =$direction  ;
                    unless(   $systemGroupNames{$system_group}) {print "Group $system_group not defined in busDefinition \n"; }
                    }
# insert DRC checks here

                   }
                }

$absDef_db->db_close();
          print "\n";
          }

        
      


Go to most recent revision | 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.