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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [geda/] [gen_gEDA_sym] - 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,
           "component=s"      => \$component,
           "version=s"        => \$version,
           "dest_dir=s"        => \$dest_dir,
           "destination=s"        => \$destination
) || die "(use '$program_name -h' for help)";


##############################################################################
## Help option
##############################################################################
if ( $opt_h  or $opt_help  ) 
  { print "\n gen_gEDA_sym  -vendor vendor_name -library library_name  -component component_name  -version version_name -dest_dir dest_dir -destination destination   \n";
    exit 1;
  }

#############################################################################
## 
## 
#############################################################################

$home = cwd();



my $variant;

if($version)       {$variant   = "${component}_${version}";}
else               {$variant   = "${component}";}



my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;

my $repo           = yp::lib::find_library_repo($vendor,$library);



unless (defined $destination && length $destination > 0)
{$destination = $main_module_name;}



print "---GEN_gEDA_sym    -vendor $vendor -library $library -component $component -version $version  -dest_dir  $dest_dir -destination  $destination   \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 $doc_library_path = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:doc/socgen:library_path/text()")->to_literal;

my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));

print "$main_module_name     \n";


my $path  = "${home}${repo}/${vendor}/${library}${doc_library_path}";
mkdir $path,0755             unless( -e $path );


if (defined $dest_dir && length $dest_dir > 0)
   { 
   $doc_library_path = "${doc_library_path}/${dest_dir}";
   }


 my $path  = "${home}${repo}/${vendor}/${library}${doc_library_path}";
 mkdir $path,0755             unless( -e $path );

 my $sym_path  = "${home}${repo}/${vendor}/${library}${doc_library_path}/sym";
 mkdir $sym_path,0755             unless( -e $sym_path );

 my $png_path  = "${home}${repo}/${vendor}/${library}${doc_library_path}/png";
 mkdir $png_path,0755             unless( -e $png_path );













my @symbol;

push @symbol , "v 20031231 1" ;



foreach my $graphic ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:reference"))
        {
        my $g_vendor                = $graphic->findnodes('./socgen:vendor/text()')->to_literal ;
        my $g_library               = $graphic->findnodes('./socgen:library/text()')->to_literal ;
        my $g_component             = $graphic->findnodes('./socgen:component/text()')->to_literal ;
        my $g_version               = $graphic->findnodes('./socgen:version/text()')->to_literal ;
        my $g_graphic               = $graphic->findnodes('./socgen:graphic/text()')->to_literal ;
        my $g_x_offset              = $graphic->findnodes('./socgen:x_offset/text()')->to_literal ;
        my $g_y_offset              = $graphic->findnodes('./socgen:y_offset/text()')->to_literal ;
        my $g_name                  = $graphic->findnodes('./socgen:name/text()')->to_literal ;
        my $g_visibility            = $graphic->findnodes('./socgen:visibility/text()')->to_literal ;



        unless (defined $g_vendor  & length $g_vendor > 0 ){$g_vendor = "no_name";}
        unless (defined $g_library & length $g_library > 0){$g_library = "no_name";}
        unless (defined $g_component & length $g_component > 0){$g_component = "no_name";}
        unless (defined $g_version & length $g_version > 0){$g_version = "no_name";}
        unless (defined $g_graphic & length $g_graphic > 0){$g_name = "no_name";}
        unless (defined $g_x_offset & length $g_x_offset > 0){$g_x_offset = "0";}
        unless (defined $g_y_offset & length $g_y_offset > 0){$g_y_offset = "0";}
        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}


        my @ref_symbol;
        @ref_symbol = parse_symbol ($g_vendor,  $g_library,  $g_component, $g_version,  $g_graphic, $g_x_offset,  $g_y_offset, $g_name, $g_visibility );
        foreach my $line (@ref_symbol)
          {
          push @symbol, $line;
          }
        }












foreach my $graphic ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:parameter/socgen:name"))
        {
        my $g_name            = $graphic->findnodes('./text()')->to_literal ;
        my $g_value           = $graphic->findnodes('../socgen:value/text()')->to_literal ;
        my $g_x               = $graphic->findnodes('../socgen:x/text()')->to_literal ;
        my $g_y               = $graphic->findnodes('../socgen:y/text()')->to_literal ;
        my $g_color           = $graphic->findnodes('../socgen:color/text()')->to_literal ;
        my $g_size            = $graphic->findnodes('../socgen:size/text()')->to_literal ;
        my $g_visibility      = $graphic->findnodes('../socgen:visibility/text()')->to_literal ;
        my $g_show_name_value = $graphic->findnodes('../socgen:show_name_value/text()')->to_literal ;
        my $g_angle           = $graphic->findnodes('../socgen:angle/text()')->to_literal ;
        my $g_alignment       = $graphic->findnodes('../socgen:alignment/text()')->to_literal ;

        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
        unless (defined $g_value & length $g_value > 0){$g_value = "none";}
        unless (defined $g_x & length $g_x > 0){$g_x = "0";}
        unless (defined $g_y & length $g_y > 0){$g_y = "0";}
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
        unless (defined $g_size & length $g_size > 0){$g_size = "0";}
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}
        unless (defined $g_show_name_value & length $g_show_name_value > 0){$g_show_name_value = "0";}
        unless (defined $g_angle & length $g_angle > 0){$g_angle = "0";}
        unless (defined $g_alignment & length $g_alignment > 0){$g_alignment = "0";}

        push @symbol , "T $g_x $g_y $g_color $g_size $g_visibility  $g_show_name_value  $g_angle  $g_alignment  1";
        push @symbol , "${g_name}=${g_value}" ;
        }




foreach my $graphic ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:port"))
        {
        my $g_name             = $graphic->findnodes('./socgen:name/text()')->to_literal ;
        my $g_type             = $graphic->findnodes('./socgen:type/text()')->to_literal ;
        my $g_x1               = $graphic->findnodes('./socgen:x1/text()')->to_literal ;
        my $g_y1               = $graphic->findnodes('./socgen:y1/text()')->to_literal ;
        my $g_x2               = $graphic->findnodes('./socgen:x2/text()')->to_literal ;
        my $g_y2               = $graphic->findnodes('./socgen:y2/text()')->to_literal ;
        my $g_color            = $graphic->findnodes('./socgen:color/text()')->to_literal ;
        my $g_pintype          = $graphic->findnodes('./socgen:pintype/text()')->to_literal ;
        my $g_whichend         = $graphic->findnodes('./socgen:whichend/text()')->to_literal ;
        my $g_visibility       = $graphic->findnodes('./socgen:visibility/text()')->to_literal ;
        my $g_inversion        = $graphic->findnodes('./socgen:inversion/text()')->to_literal ;


        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
        unless (defined $g_type & length $g_type > 0){$g_type = "none";}
        unless (defined $g_x1 & length $g_x1 > 0){$g_x1 = "0";}
        unless (defined $g_y1 & length $g_y1 > 0){$g_y1 = "0";}
        unless (defined $g_x2 & length $g_x2 > 0){$g_x2 = "0";}
        unless (defined $g_y2 & length $g_y2 > 0){$g_y2 = "0";}
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
        unless (defined $g_pintype & length $g_pintype > 0){$g_pintype = "0";}
        unless (defined $g_whichend & length $g_whichend > 0){$g_whichend = "0";}
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}
        unless (defined $g_inversion  & length $g_inversion > 0){$g_inversion = "0";}




        push @symbol,"P $g_x1 $g_y1 $g_x2 $g_y2 $g_color  $g_pintype $g_whichend";

        push @symbol,"{";
        if($g_whichend eq "0")
         {
         push @symbol , "T $g_x2 $g_y2 5 10 $g_visibility  1  0  1  1";
         push @symbol , "PINNAME=${g_name}" ;
         push @symbol , "T $g_x2 $g_y2 0 8 0  1  0  6  1";
         push @symbol , "DIR=${g_type}" ;



         }
        else
         {
         push @symbol , "T $g_x1 $g_y1 5 10 $g_visibility  1  0  7  1";
         push @symbol , "PINNAME=${g_name}" ;
         push @symbol , "T $g_x1 $g_y1 0 8 0  1  0  0  1";
         push @symbol , "DIR=${g_type}" ;
         }



}






foreach my $graphic ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name"))
        {
        my $g_name                   = $graphic->findnodes('./text()')->to_literal ;
        my $sym_file;
        my $png_file;


        if($g_name eq $main_module_name)
          {
          $sym_file ="${path}/sym/${destination}.sym";        
          $png_file ="${path}/png/${destination}_sym.png";        
          }
        else
          {
          $sym_file ="${path}/sym/${destination}_${g_name}.sym";        
          $png_file ="${path}/png/${destination}_${g_name}_sym.png";        
          }

        open SYMBOL,">$sym_file" or die "unable to open $sym_file";





       my @graph_symbol;


        foreach my $graphic_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name[./text() = '$g_name']/../socgen:reference")) 
        {
        my $g_vendor                = $graphic_view->findnodes('./socgen:vendor/text()')->to_literal ;
        my $g_library               = $graphic_view->findnodes('./socgen:library/text()')->to_literal ;
        my $g_component             = $graphic_view->findnodes('./socgen:component/text()')->to_literal ;
        my $g_version               = $graphic_view->findnodes('./socgen:version/text()')->to_literal ;
        my $g_graphic                  = $graphic_view->findnodes('./socgen:graphic/text()')->to_literal ;
        my $g_x_offset              = $graphic_view->findnodes('./socgen:x_offset/text()')->to_literal ;
        my $g_y_offset              = $graphic_view->findnodes('./socgen:y_offset/text()')->to_literal ;
        my $g_name                  = $graphic_view->findnodes('./socgen:name/text()')->to_literal ;
        my $g_visibility            = $graphic_view->findnodes('./socgen:visibility/text()')->to_literal ;

        unless (defined $g_vendor  & length $g_vendor > 0 ){$g_vendor = "no_name";}
        unless (defined $g_library & length $g_library > 0){$g_library = "no_name";}
        unless (defined $g_component & length $g_component > 0){$g_component = "no_name";}
        unless (defined $g_version & length $g_version > 0){$g_version = "no_name";}
        unless (defined $g_graphic & length $g_graphic > 0){$g_name = "no_name";}
        unless (defined $g_x_offset & length $g_x_offset > 0){$g_x_offset = "0";}
        unless (defined $g_y_offset & length $g_y_offset > 0){$g_y_offset = "0";}
        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}

        my @ref_symbol;
        @ref_symbol = parse_symbol ($g_vendor,  $g_library,  $g_component, $g_version,  $g_graphic, $g_x_offset,  $g_y_offset, $g_name, $g_visibility );
        foreach my $line (@ref_symbol)
          {
          push @graph_symbol, $line;
          }
        }







        foreach my $sym (@symbol)  { print  SYMBOL  "$sym \n"; }
        foreach my $sym (@graph_symbol)  { print  SYMBOL  "$sym \n"; }



        foreach my $graphic_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name[./text() = '$g_name']/../socgen:line")) 
            {
            my $g_x1               = $graphic_view->findnodes('./socgen:x1/text()')->to_literal ;
            my $g_y1               = $graphic_view->findnodes('./socgen:y1/text()')->to_literal ;
            my $g_x2               = $graphic_view->findnodes('./socgen:x2/text()')->to_literal ;
            my $g_y2               = $graphic_view->findnodes('./socgen:y2/text()')->to_literal ;
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;

            unless (defined $g_x1 & length $g_x1 > 0){$g_x1 = "0";}
            unless (defined $g_y1 & length $g_y1 > 0){$g_y1 = "0";}
            unless (defined $g_x2 & length $g_x2 > 0){$g_x2 = "0";}
            unless (defined $g_y2 & length $g_y2 > 0){$g_y2 = "0";}
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
            print  SYMBOL "L   $g_x1 $g_y1 $g_x2 $g_y2 $g_color  $g_width $g_capstyle  $g_dashstyle  $g_dashlength  $g_dashspace   \n";
            }



        foreach my $graphic_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name[./text() = '$g_name']/../socgen:arc")) 
            {
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
            my $g_radius               = $graphic_view->findnodes('./socgen:radius/text()')->to_literal ;
            my $g_startangle               = $graphic_view->findnodes('./socgen:startangle/text()')->to_literal ;
            my $g_sweepangle               = $graphic_view->findnodes('./socgen:sweepangle/text()')->to_literal ;
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;

            unless (defined $g_x & length $g_x > 0){$g_x = "0";}
            unless (defined $g_y & length $g_y > 0){$g_y = "0";}
            unless (defined $g_radius & length $g_radius > 0){$g_radius = "0";}
            unless (defined $g_startangle & length $g_startangle > 0){$g_startangle = "0";}
            unless (defined $g_sweepangle & length $g_sweepangle > 0){$g_sweepangle = "0";}
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
            unless (defined $g_width & length $g_width > 0){$g_width = "0";}
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
            print  SYMBOL "A   $g_x  $g_y  $g_radius $g_startangle   $g_sweepangle $g_color  $g_width $g_capstyle  $g_dashstyle  $g_dashlength  $g_dashspace   \n";
            }




        foreach my $graphic_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name[./text() = '$g_name']/../socgen:circle")) 
            {
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
            my $g_radius               = $graphic_view->findnodes('./socgen:radius/text()')->to_literal ;
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
            my $g_filltype               = $graphic_view->findnodes('./socgen:filltype/text()')->to_literal ;
            my $g_fillwidth               = $graphic_view->findnodes('./socgen:fillwidth/text()')->to_literal ;
            my $g_angle1               = $graphic_view->findnodes('./socgen:angle1/text()')->to_literal ;
            my $g_pitch1               = $graphic_view->findnodes('./socgen:pitch1/text()')->to_literal ;
            my $g_angle2               = $graphic_view->findnodes('./socgen:angle2/text()')->to_literal ;
            my $g_pitch2               = $graphic_view->findnodes('./socgen:pitch2/text()')->to_literal ;

            unless (defined $g_x & length $g_x > 0){$g_x = "0";}
            unless (defined $g_y & length $g_y > 0){$g_y = "0";}
            unless (defined $g_radius & length $g_radius > 0){$g_radius = "0";}
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
            unless (defined $g_width & length $g_width > 0){$g_width = "0";}
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
            unless (defined $g_filltype & length $g_filltype > 0){$g_filltype = "0";}
            unless (defined $g_fillwidth & length $g_fillwidth > 0){$g_fillwidth = "0";}
            unless (defined $g_angle1 & length $g_angle1 > 0){$g_angle1 = "0";}
            unless (defined $g_pitch1 & length $g_pitch1 > 0){$g_pitch1 = "0";}
            unless (defined $g_angle2 & length $g_angle2 > 0){$g_angle2 = "0";}
            unless (defined $g_pitch2 & length $g_pitch2 > 0){$g_pitch2 = "0";}
            print  SYMBOL "V   $g_x  $g_y  $g_radius  $g_color  $g_width $g_capstyle  $g_dashstyle  $g_dashlength  $g_dashspace    $g_filltype $g_fillwidth $g_angle1  $g_pitch1  $g_angle2 $g_pitch2  \n";
            }





my $cmd ="gaf export -c -s auto -m 5px  --dpi  600  --no-color -o  $png_file $sym_file \n";
print "$cmd";
if (system($cmd)) {}
print "$cmd";




        }




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




sub parse_symbol
   {
   my @params        = @_;
   my $s_visibility  = pop(@params);
   my $s_name        = pop(@params);
   my $s_y_offset    = pop(@params);
   my $s_x_offset    = pop(@params);
   my $s_graphic     = pop(@params);
   my $s_version     = pop(@params);
   my $s_component   = pop(@params);
   my $s_library     = pop(@params);
   my $s_vendor      = pop(@params);

# prevent overload issues
   my   $h_x_offset = lc  $s_x_offset;
   my   $h_y_offset = lc  $s_y_offset;

   my @ref_symbol;
   print "REF  $s_vendor  $s_library  $s_component $s_version   $s_graphic $s_x_offset  $s_y_offset  $s_name $s_visibility \n";

   my $file = yp::lib::find_ipxact_component($s_vendor,$s_library,$s_component,$s_version);
   print "REFILE $s_vendor,$s_library,$s_component,$s_version  $file  \n";
   my $symbol_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($s_vendor,$s_library,$s_component,$s_version));



foreach my $graphic ($symbol_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name"))
        {
        my $g_name                   = $graphic->findnodes('./text()')->to_literal ;
        if($g_name eq $s_graphic)
          {
          print "Graphic  $g_name\n";
          }

        }






        foreach my $graphic_view ($symbol_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name[./text() = '$s_graphic']/../socgen:line")) 
            {
            my $g_x1               = $graphic_view->findnodes('./socgen:x1/text()')->to_literal ;
            my $g_y1               = $graphic_view->findnodes('./socgen:y1/text()')->to_literal ;
            my $g_x2               = $graphic_view->findnodes('./socgen:x2/text()')->to_literal ;
            my $g_y2               = $graphic_view->findnodes('./socgen:y2/text()')->to_literal ;
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;

            unless (defined $g_x1 & length $g_x1 > 0){$g_x1 = "0";}
            unless (defined $g_y1 & length $g_y1 > 0){$g_y1 = "0";}
            unless (defined $g_x2 & length $g_x2 > 0){$g_x2 = "0";}
            unless (defined $g_y2 & length $g_y2 > 0){$g_y2 = "0";}
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
            unless (defined $g_width & length $g_width > 0){$g_width = "0";}
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}

            my   $h_x1 = lc  $g_x1;
            my   $h_y1 = lc  $g_y1;
            my   $h_x2 = lc  $g_x2;
            my   $h_y2 = lc  $g_y2;


            $h_x1  =   $h_x1  + $h_x_offset;    
            $h_y1  =   $h_y1  + $h_y_offset;    
            $h_x2  =   $h_x2  + $h_x_offset;    
            $h_y2  =   $h_y2  + $h_y_offset;    


            push @ref_symbol,   "L   $h_x1 $h_y1 $h_x2 $h_y2 $g_color  $g_width $g_capstyle  $g_dashstyle  $g_dashlength  $g_dashspace  ";
            }







        foreach my $graphic_view ($symbol_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name[./text() = '$s_graphic']/../socgen:box")) 
            {
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
            my $g_height           = $graphic_view->findnodes('./socgen:height/text()')->to_literal ;
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
            my $g_linewidth            = $graphic_view->findnodes('./socgen:linewidth/text()')->to_literal ;
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
            my $g_filltype               = $graphic_view->findnodes('./socgen:filltype/text()')->to_literal ;
            my $g_fillwidth               = $graphic_view->findnodes('./socgen:fillwidth/text()')->to_literal ;
            my $g_angle1               = $graphic_view->findnodes('./socgen:angle1/text()')->to_literal ;
            my $g_pitch1               = $graphic_view->findnodes('./socgen:pitch1/text()')->to_literal ;
            my $g_angle2               = $graphic_view->findnodes('./socgen:angle2/text()')->to_literal ;
            my $g_pitch2               = $graphic_view->findnodes('./socgen:pitch2/text()')->to_literal ;

            unless (defined $g_x & length $g_x > 0){$g_x = "0";}
            unless (defined $g_y & length $g_y > 0){$g_y = "0";}
            unless (defined $g_width & length $g_width > 0){$g_width = "0";}
            unless (defined $g_height & length $g_height > 0){$g_height = "0";}
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
            unless (defined $g_linewidth & length $g_linewidth > 0){$g_linewidth = "0";}
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
            unless (defined $g_filltype & length $g_filltype > 0){$g_filltype = "0";}
            unless (defined $g_fillwidth & length $g_fillwidth > 0){$g_fillwidth = "0";}
            unless (defined $g_angle1 & length $g_angle1 > 0){$g_angle1 = "0";}
            unless (defined $g_pitch1 & length $g_pitch1 > 0){$g_pitch1 = "0";}
            unless (defined $g_angle2 & length $g_angle2 > 0){$g_angle2 = "0";}
            unless (defined $g_pitch2 & length $g_pitch2 > 0){$g_pitch2 = "0";}

            my   $h_x = lc  $g_x;
            my   $h_y = lc  $g_y;
            $h_x  =   $h_x  + $h_x_offset;    
            $h_y  =   $h_y  + $h_y_offset;    
            push @ref_symbol,   "B   $h_x $h_y  $g_width   $g_height   $g_color  $g_linewidth $g_capstyle  $g_dashstyle  $g_dashlength  $g_dashspace $g_filltype $g_fillwidth  $g_angle1 $g_pitch1 $g_angle2 $g_pitch2 ";
            }












































        foreach my $graphic_view ($symbol_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name[./text() = '$s_graphic']/../socgen:arc")) 
            {
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
            my $g_radius               = $graphic_view->findnodes('./socgen:radius/text()')->to_literal ;
            my $g_startangle               = $graphic_view->findnodes('./socgen:startangle/text()')->to_literal ;
            my $g_sweepangle               = $graphic_view->findnodes('./socgen:sweepangle/text()')->to_literal ;
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;

        unless (defined $g_x & length $g_x > 0){$g_x = "0";}
        unless (defined $g_y & length $g_y > 0){$g_y = "0";}
        unless (defined $g_radius & length $g_radius > 0){$g_radius = "0";}
        unless (defined $g_startangle & length $g_startangle > 0){$g_startangle = "0";}
        unless (defined $g_sweepangle & length $g_sweepangle > 0){$g_sweepangle = "0";}
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
        unless (defined $g_width & length $g_width > 0){$g_width = "0";}
        unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
        unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
        unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
        unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}




          my   $h_x = lc  $g_x;
          my   $h_y = lc  $g_y;



             $h_x  =   $h_x  + $h_x_offset;    
             $h_y  =   $h_y  + $h_y_offset;    





            push @ref_symbol,  "A   $h_x  $h_y  $g_radius $g_startangle   $g_sweepangle $g_color  $g_width $g_capstyle  $g_dashstyle  $g_dashlength  $g_dashspace";
            }




        foreach my $graphic_view ($symbol_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name[./text() = '$s_graphic']/../socgen:circle")) 
            {
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
            my $g_radius               = $graphic_view->findnodes('./socgen:radius/text()')->to_literal ;
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
            my $g_filltype               = $graphic_view->findnodes('./socgen:filltype/text()')->to_literal ;
            my $g_fillwidth               = $graphic_view->findnodes('./socgen:fillwidth/text()')->to_literal ;
            my $g_angle1               = $graphic_view->findnodes('./socgen:angle1/text()')->to_literal ;
            my $g_pitch1               = $graphic_view->findnodes('./socgen:pitch1/text()')->to_literal ;
            my $g_angle2               = $graphic_view->findnodes('./socgen:angle2/text()')->to_literal ;
            my $g_pitch2               = $graphic_view->findnodes('./socgen:pitch2/text()')->to_literal ;



        unless (defined $g_x & length $g_x > 0){$g_x = "0";}
        unless (defined $g_y & length $g_y > 0){$g_y = "0";}
        unless (defined $g_radius & length $g_radius > 0){$g_radius = "0";}
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
        unless (defined $g_width & length $g_width > 0){$g_width = "0";}
        unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
        unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
        unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
        unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
        unless (defined $g_filltype & length $g_filltype > 0){$g_filltype = "0";}
        unless (defined $g_fillwidth & length $g_fillwidth > 0){$g_fillwidth = "0";}
        unless (defined $g_angle1 & length $g_angle1 > 0){$g_angle1 = "0";}
        unless (defined $g_pitch1 & length $g_pitch1 > 0){$g_pitch1 = "0";}
        unless (defined $g_angle2 & length $g_angle2 > 0){$g_angle2 = "0";}
        unless (defined $g_pitch2 & length $g_pitch2 > 0){$g_pitch2 = "0";}


          my   $h_x = lc  $g_x;
          my   $h_y = lc  $g_y;



             $h_x  =   $h_x  + $h_x_offset;    
             $h_y  =   $h_y  + $h_y_offset;    



            push @ref_symbol,   "V   $h_x  $h_y  $g_radius  $g_color  $g_width $g_capstyle  $g_dashstyle  $g_dashlength  $g_dashspace    $g_filltype $g_fillwidth $g_angle1  $g_pitch1   $g_angle2 $g_pitch2";
             }



        foreach my $graphic_view ($symbol_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name[./text() = '$s_graphic']/../socgen:port")) 

        {
        my $g_name             = $graphic_view->findnodes('./socgen:name/text()')->to_literal ;
        my $g_type             = $graphic_view->findnodes('./socgen:type/text()')->to_literal ;

        my $g_x1               = $graphic_view->findnodes('./socgen:x1/text()')->to_literal ;
        my $g_y1               = $graphic_view->findnodes('./socgen:y1/text()')->to_literal ;
        my $g_x2               = $graphic_view->findnodes('./socgen:x2/text()')->to_literal ;
        my $g_y2               = $graphic_view->findnodes('./socgen:y2/text()')->to_literal ;
        my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
        my $g_pintype          = $graphic_view->findnodes('./socgen:pintype/text()')->to_literal ;
        my $g_whichend         = $graphic_view->findnodes('./socgen:whichend/text()')->to_literal ;
        my $g_visibility       = $graphic_view->findnodes('./socgen:visibility/text()')->to_literal ;
        my $g_inversion        = $graphic_view->findnodes('./socgen:inversion/text()')->to_literal ;


        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
        unless (defined $g_type & length $g_type > 0){$g_type = "none";}
        unless (defined $g_x1 & length $g_x1 > 0){$g_x1 = "0";}
        unless (defined $g_y1 & length $g_y1 > 0){$g_y1 = "0";}
        unless (defined $g_x2 & length $g_x2 > 0){$g_x2 = "0";}
        unless (defined $g_y2 & length $g_y2 > 0){$g_y2 = "0";}
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
        unless (defined $g_pintype & length $g_pintype > 0){$g_pintype = "0";}
        unless (defined $g_whichend & length $g_whichend > 0){$g_whichend = "0";}
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}
        unless (defined $g_inversion & length $g_inversion > 0){$g_inversion = "0";}




          my   $h_x1 = lc  $g_x1;
          my   $h_y1 = lc  $g_y1;
          my   $h_x2 = lc  $g_x2;
          my   $h_y2 = lc  $g_y2;


             $h_x1  =   $h_x1  + $h_x_offset;    
             $h_y1  =   $h_y1  + $h_y_offset;    
             $h_x2  =   $h_x2  + $h_x_offset;    
             $h_y2  =   $h_y2  + $h_y_offset;    

        my $color;
        my $width;
  if($g_pintype eq 1)
{
      $color = 10;
      $width = 30;
}
else
{
      $color = 4;
      $width = 10;
}




        if($g_whichend eq "0")
         {
         if($g_inversion eq "1")
           {
           my $spot = $h_x2 -50;
           my $spot2 = $h_x2 -100;
           push @ref_symbol,   "V   $spot $h_y2 50 6 0 0 0  -1  -1  0 0  -1  -1 -1 -1 ";
           push @ref_symbol,   "L   $h_x1 $h_y1 $spot2 $h_y2 $color  $width 0  0  -1  -1  ";
           }
         else
           {
           push @ref_symbol,   "L   $h_x1 $h_y1 $h_x2 $h_y2 $color  $width 0  0  -1  -1  ";
           }
         push @ref_symbol,"P $h_x1 $h_y1 $h_x1 $h_y1 $g_color  $g_pintype $g_whichend";
         push @ref_symbol,"{";
         push @ref_symbol , "T $h_x2 $h_y2 5 10 $s_visibility  1  0  1  1";
         push @ref_symbol , "PINNAME=${s_name}" ;
         push @ref_symbol , "T $h_x2 $h_y2 0 8 0  1  0  6  1";
         push @ref_symbol , "DIR=${g_type}" ;
       }
        else
         {
         if($g_inversion eq "1")
           {
           my $spot = $h_x1 +50;
           my $spot2 = $h_x1 +100;
           push @ref_symbol,   "L   $spot2 $h_y1 $h_x2 $h_y2 $color  $width 0  0  -1  -1  ";
           push @ref_symbol,   "V   $spot $h_y1 50 6 0 0 0  -1  -1  0 0  -1  -1 -1 -1 ";
           }
         else
           {
           push @ref_symbol,   "L   $h_x1 $h_y1 $h_x2 $h_y2 $color  $width 0  0  -1  -1  ";
           }
         push @ref_symbol,"P $h_x2 $h_y2 $h_x2 $h_y2 $g_color  $g_pintype $g_whichend";
         push @ref_symbol,"{";
         push @ref_symbol , "T $h_x1 $h_y1 5 10 $s_visibility  1  0  7  1";
         push @ref_symbol , "PINNAME=${s_name}" ;
         push @ref_symbol , "T $h_x1 $h_y1 0 8 0  1  0  0  1";
         push @ref_symbol , "DIR=${g_type}" ;
         }
       push @ref_symbol,"}";

      }




   
return (@ref_symbol);

}




1

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.