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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [geda/] [gen_gEDA_sym] - Blame information for rev 135

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 135 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
#/****************************************************************************/
4
#/*                                                                          */
5
#/*   SOCGEN Design for Reuse toolset                                        */
6
#/*                                                                          */
7
#/*   Version 1.0.0                                                          */
8
#/*                                                                          */
9
#/*   Author(s):                                                             */
10
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
11
#/*                                                                          */
12
#/****************************************************************************/
13
#/*                                                                          */
14
#/*                                                                          */
15
#/*             Copyright 2016 John T Eaton                                  */
16
#/*                                                                          */
17
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
18
#/* you may not use this file except in compliance with the License.         */
19
#/* You may obtain a copy of the License at                                  */
20
#/*                                                                          */
21
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
22
#/*                                                                          */
23
#/* Unless required by applicable law or agreed to in writing, software      */
24
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
25
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
26
#/* See the License for the specific language governing permissions and      */
27
#/* limitations under the License.                                           */
28
#/*                                                                          */
29
#/*                                                                          */
30
#/****************************************************************************/
31
 
32
 
33
############################################################################
34
# General PERL config
35
############################################################################
36
use Getopt::Long;
37
use English;
38
use File::Basename;
39
use Cwd;
40
use Scalar::Util qw(looks_like_number);
41
use XML::LibXML;
42
use lib './tools';
43
use sys::lib;
44
use yp::lib;
45
use BerkeleyDB;
46
 
47
 
48
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
49
 
50
 
51
############################################################################
52
### Process the options
53
############################################################################
54
Getopt::Long::config("require_order", "prefix=-");
55
GetOptions("h","help",
56
           "vendor=s"         => \$vendor,
57
           "library=s"        => \$library,
58
           "component=s"      => \$component,
59
           "version=s"        => \$version,
60
           "dest_dir=s"        => \$dest_dir,
61
           "destination=s"        => \$destination
62
) || die "(use '$program_name -h' for help)";
63
 
64
 
65
##############################################################################
66
## Help option
67
##############################################################################
68
if ( $opt_h  or $opt_help  )
69
  { print "\n gen_gEDA_sym  -vendor vendor_name -library library_name  -component component_name  -version version_name -dest_dir dest_dir -destination destination   \n";
70
    exit 1;
71
  }
72
 
73
#############################################################################
74
##
75
##
76
#############################################################################
77
 
78
$home = cwd();
79
 
80
 
81
 
82
my $variant;
83
 
84
if($version)       {$variant   = "${component}_${version}";}
85
else               {$variant   = "${component}";}
86
 
87
 
88
 
89
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
90
 
91
my $repo           = yp::lib::find_library_repo($vendor,$library);
92
 
93
 
94
 
95
unless (defined $destination && length $destination > 0)
96
{$destination = $main_module_name;}
97
 
98
 
99
 
100
print "---GEN_gEDA_sym    -vendor $vendor -library $library -component $component -version $version  -dest_dir  $dest_dir -destination  $destination   \n";
101
 
102
 
103
 
104
 
105
 
106
my $parser = XML::LibXML->new();
107
 
108
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
109
 
110
unless ($socgen_file)      { print "No socgen ip file   \n";};
111
 
112
my $doc_library_path = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:doc/socgen:library_path/text()")->to_literal;
113
 
114
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
115
 
116
print "$main_module_name     \n";
117
 
118
 
119
my $path  = "${home}${repo}/${vendor}/${library}${doc_library_path}";
120
mkdir $path,0755             unless( -e $path );
121
 
122
 
123
if (defined $dest_dir && length $dest_dir > 0)
124
   {
125
   $doc_library_path = "${doc_library_path}/${dest_dir}";
126
   }
127
 
128
 
129
 my $path  = "${home}${repo}/${vendor}/${library}${doc_library_path}";
130
 mkdir $path,0755             unless( -e $path );
131
 
132
 my $sym_path  = "${home}${repo}/${vendor}/${library}${doc_library_path}/sym";
133
 mkdir $sym_path,0755             unless( -e $sym_path );
134
 
135
 my $png_path  = "${home}${repo}/${vendor}/${library}${doc_library_path}/png";
136
 mkdir $png_path,0755             unless( -e $png_path );
137
 
138
 
139
 
140
 
141
 
142
 
143
 
144
 
145
 
146
 
147
 
148
 
149
 
150
my @symbol;
151
 
152
push @symbol , "v 20031231 1" ;
153
 
154
 
155
 
156
foreach my $graphic ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:reference"))
157
        {
158
        my $g_vendor                = $graphic->findnodes('./socgen:vendor/text()')->to_literal ;
159
        my $g_library               = $graphic->findnodes('./socgen:library/text()')->to_literal ;
160
        my $g_component             = $graphic->findnodes('./socgen:component/text()')->to_literal ;
161
        my $g_version               = $graphic->findnodes('./socgen:version/text()')->to_literal ;
162
        my $g_graphic               = $graphic->findnodes('./socgen:graphic/text()')->to_literal ;
163
        my $g_x_offset              = $graphic->findnodes('./socgen:x_offset/text()')->to_literal ;
164
        my $g_y_offset              = $graphic->findnodes('./socgen:y_offset/text()')->to_literal ;
165
        my $g_name                  = $graphic->findnodes('./socgen:name/text()')->to_literal ;
166
        my $g_visibility            = $graphic->findnodes('./socgen:visibility/text()')->to_literal ;
167
 
168
 
169
 
170
        unless (defined $g_vendor  & length $g_vendor > 0 ){$g_vendor = "no_name";}
171
        unless (defined $g_library & length $g_library > 0){$g_library = "no_name";}
172
        unless (defined $g_component & length $g_component > 0){$g_component = "no_name";}
173
        unless (defined $g_version & length $g_version > 0){$g_version = "no_name";}
174
        unless (defined $g_graphic & length $g_graphic > 0){$g_name = "no_name";}
175
        unless (defined $g_x_offset & length $g_x_offset > 0){$g_x_offset = "0";}
176
        unless (defined $g_y_offset & length $g_y_offset > 0){$g_y_offset = "0";}
177
        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
178
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}
179
 
180
 
181
        my @ref_symbol;
182
        @ref_symbol = parse_symbol ($g_vendor,  $g_library,  $g_component, $g_version,  $g_graphic, $g_x_offset,  $g_y_offset, $g_name, $g_visibility );
183
        foreach my $line (@ref_symbol)
184
          {
185
          push @symbol, $line;
186
          }
187
        }
188
 
189
 
190
 
191
 
192
 
193
 
194
 
195
 
196
 
197
 
198
 
199
 
200
foreach my $graphic ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:parameter/socgen:name"))
201
        {
202
        my $g_name            = $graphic->findnodes('./text()')->to_literal ;
203
        my $g_value           = $graphic->findnodes('../socgen:value/text()')->to_literal ;
204
        my $g_x               = $graphic->findnodes('../socgen:x/text()')->to_literal ;
205
        my $g_y               = $graphic->findnodes('../socgen:y/text()')->to_literal ;
206
        my $g_color           = $graphic->findnodes('../socgen:color/text()')->to_literal ;
207
        my $g_size            = $graphic->findnodes('../socgen:size/text()')->to_literal ;
208
        my $g_visibility      = $graphic->findnodes('../socgen:visibility/text()')->to_literal ;
209
        my $g_show_name_value = $graphic->findnodes('../socgen:show_name_value/text()')->to_literal ;
210
        my $g_angle           = $graphic->findnodes('../socgen:angle/text()')->to_literal ;
211
        my $g_alignment       = $graphic->findnodes('../socgen:alignment/text()')->to_literal ;
212
 
213
        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
214
        unless (defined $g_value & length $g_value > 0){$g_value = "none";}
215
        unless (defined $g_x & length $g_x > 0){$g_x = "0";}
216
        unless (defined $g_y & length $g_y > 0){$g_y = "0";}
217
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
218
        unless (defined $g_size & length $g_size > 0){$g_size = "0";}
219
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}
220
        unless (defined $g_show_name_value & length $g_show_name_value > 0){$g_show_name_value = "0";}
221
        unless (defined $g_angle & length $g_angle > 0){$g_angle = "0";}
222
        unless (defined $g_alignment & length $g_alignment > 0){$g_alignment = "0";}
223
 
224
        push @symbol , "T $g_x $g_y $g_color $g_size $g_visibility  $g_show_name_value  $g_angle  $g_alignment  1";
225
        push @symbol , "${g_name}=${g_value}" ;
226
        }
227
 
228
 
229
 
230
 
231
foreach my $graphic ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:port"))
232
        {
233
        my $g_name             = $graphic->findnodes('./socgen:name/text()')->to_literal ;
234
        my $g_type             = $graphic->findnodes('./socgen:type/text()')->to_literal ;
235
        my $g_x1               = $graphic->findnodes('./socgen:x1/text()')->to_literal ;
236
        my $g_y1               = $graphic->findnodes('./socgen:y1/text()')->to_literal ;
237
        my $g_x2               = $graphic->findnodes('./socgen:x2/text()')->to_literal ;
238
        my $g_y2               = $graphic->findnodes('./socgen:y2/text()')->to_literal ;
239
        my $g_color            = $graphic->findnodes('./socgen:color/text()')->to_literal ;
240
        my $g_pintype          = $graphic->findnodes('./socgen:pintype/text()')->to_literal ;
241
        my $g_whichend         = $graphic->findnodes('./socgen:whichend/text()')->to_literal ;
242
        my $g_visibility       = $graphic->findnodes('./socgen:visibility/text()')->to_literal ;
243
        my $g_inversion        = $graphic->findnodes('./socgen:inversion/text()')->to_literal ;
244
 
245
 
246
        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
247
        unless (defined $g_type & length $g_type > 0){$g_type = "none";}
248
        unless (defined $g_x1 & length $g_x1 > 0){$g_x1 = "0";}
249
        unless (defined $g_y1 & length $g_y1 > 0){$g_y1 = "0";}
250
        unless (defined $g_x2 & length $g_x2 > 0){$g_x2 = "0";}
251
        unless (defined $g_y2 & length $g_y2 > 0){$g_y2 = "0";}
252
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
253
        unless (defined $g_pintype & length $g_pintype > 0){$g_pintype = "0";}
254
        unless (defined $g_whichend & length $g_whichend > 0){$g_whichend = "0";}
255
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}
256
        unless (defined $g_inversion  & length $g_inversion > 0){$g_inversion = "0";}
257
 
258
 
259
 
260
 
261
        push @symbol,"P $g_x1 $g_y1 $g_x2 $g_y2 $g_color  $g_pintype $g_whichend";
262
 
263
        push @symbol,"{";
264
        if($g_whichend eq "0")
265
         {
266
         push @symbol , "T $g_x2 $g_y2 5 10 $g_visibility  1  0  1  1";
267
         push @symbol , "PINNAME=${g_name}" ;
268
         push @symbol , "T $g_x2 $g_y2 0 8 0  1  0  6  1";
269
         push @symbol , "DIR=${g_type}" ;
270
 
271
 
272
 
273
         }
274
        else
275
         {
276
         push @symbol , "T $g_x1 $g_y1 5 10 $g_visibility  1  0  7  1";
277
         push @symbol , "PINNAME=${g_name}" ;
278
         push @symbol , "T $g_x1 $g_y1 0 8 0  1  0  0  1";
279
         push @symbol , "DIR=${g_type}" ;
280
         }
281
 
282
 
283
 
284
}
285
 
286
 
287
 
288
 
289
 
290
 
291
foreach my $graphic ($spirit_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name"))
292
        {
293
        my $g_name                   = $graphic->findnodes('./text()')->to_literal ;
294
        my $sym_file;
295
        my $png_file;
296
 
297
 
298
        if($g_name eq $main_module_name)
299
          {
300
          $sym_file ="${path}/sym/${destination}.sym";
301
          $png_file ="${path}/png/${destination}_sym.png";
302
          }
303
        else
304
          {
305
          $sym_file ="${path}/sym/${destination}_${g_name}.sym";
306
          $png_file ="${path}/png/${destination}_${g_name}_sym.png";
307
          }
308
 
309
        open SYMBOL,">$sym_file" or die "unable to open $sym_file";
310
 
311
 
312
 
313
 
314
 
315
       my @graph_symbol;
316
 
317
 
318
        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"))
319
        {
320
        my $g_vendor                = $graphic_view->findnodes('./socgen:vendor/text()')->to_literal ;
321
        my $g_library               = $graphic_view->findnodes('./socgen:library/text()')->to_literal ;
322
        my $g_component             = $graphic_view->findnodes('./socgen:component/text()')->to_literal ;
323
        my $g_version               = $graphic_view->findnodes('./socgen:version/text()')->to_literal ;
324
        my $g_graphic                  = $graphic_view->findnodes('./socgen:graphic/text()')->to_literal ;
325
        my $g_x_offset              = $graphic_view->findnodes('./socgen:x_offset/text()')->to_literal ;
326
        my $g_y_offset              = $graphic_view->findnodes('./socgen:y_offset/text()')->to_literal ;
327
        my $g_name                  = $graphic_view->findnodes('./socgen:name/text()')->to_literal ;
328
        my $g_visibility            = $graphic_view->findnodes('./socgen:visibility/text()')->to_literal ;
329
 
330
        unless (defined $g_vendor  & length $g_vendor > 0 ){$g_vendor = "no_name";}
331
        unless (defined $g_library & length $g_library > 0){$g_library = "no_name";}
332
        unless (defined $g_component & length $g_component > 0){$g_component = "no_name";}
333
        unless (defined $g_version & length $g_version > 0){$g_version = "no_name";}
334
        unless (defined $g_graphic & length $g_graphic > 0){$g_name = "no_name";}
335
        unless (defined $g_x_offset & length $g_x_offset > 0){$g_x_offset = "0";}
336
        unless (defined $g_y_offset & length $g_y_offset > 0){$g_y_offset = "0";}
337
        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
338
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}
339
 
340
        my @ref_symbol;
341
        @ref_symbol = parse_symbol ($g_vendor,  $g_library,  $g_component, $g_version,  $g_graphic, $g_x_offset,  $g_y_offset, $g_name, $g_visibility );
342
        foreach my $line (@ref_symbol)
343
          {
344
          push @graph_symbol, $line;
345
          }
346
        }
347
 
348
 
349
 
350
 
351
 
352
 
353
 
354
        foreach my $sym (@symbol)  { print  SYMBOL  "$sym \n"; }
355
        foreach my $sym (@graph_symbol)  { print  SYMBOL  "$sym \n"; }
356
 
357
 
358
 
359
        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"))
360
            {
361
            my $g_x1               = $graphic_view->findnodes('./socgen:x1/text()')->to_literal ;
362
            my $g_y1               = $graphic_view->findnodes('./socgen:y1/text()')->to_literal ;
363
            my $g_x2               = $graphic_view->findnodes('./socgen:x2/text()')->to_literal ;
364
            my $g_y2               = $graphic_view->findnodes('./socgen:y2/text()')->to_literal ;
365
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
366
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
367
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
368
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
369
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
370
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
371
 
372
            unless (defined $g_x1 & length $g_x1 > 0){$g_x1 = "0";}
373
            unless (defined $g_y1 & length $g_y1 > 0){$g_y1 = "0";}
374
            unless (defined $g_x2 & length $g_x2 > 0){$g_x2 = "0";}
375
            unless (defined $g_y2 & length $g_y2 > 0){$g_y2 = "0";}
376
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
377
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
378
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
379
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
380
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
381
            print  SYMBOL "L   $g_x1 $g_y1 $g_x2 $g_y2 $g_color  $g_width $g_capstyle  $g_dashstyle  $g_dashlength  $g_dashspace   \n";
382
            }
383
 
384
 
385
 
386
        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"))
387
            {
388
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
389
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
390
            my $g_radius               = $graphic_view->findnodes('./socgen:radius/text()')->to_literal ;
391
            my $g_startangle               = $graphic_view->findnodes('./socgen:startangle/text()')->to_literal ;
392
            my $g_sweepangle               = $graphic_view->findnodes('./socgen:sweepangle/text()')->to_literal ;
393
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
394
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
395
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
396
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
397
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
398
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
399
 
400
            unless (defined $g_x & length $g_x > 0){$g_x = "0";}
401
            unless (defined $g_y & length $g_y > 0){$g_y = "0";}
402
            unless (defined $g_radius & length $g_radius > 0){$g_radius = "0";}
403
            unless (defined $g_startangle & length $g_startangle > 0){$g_startangle = "0";}
404
            unless (defined $g_sweepangle & length $g_sweepangle > 0){$g_sweepangle = "0";}
405
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
406
            unless (defined $g_width & length $g_width > 0){$g_width = "0";}
407
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
408
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
409
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
410
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
411
            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";
412
            }
413
 
414
 
415
 
416
 
417
        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"))
418
            {
419
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
420
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
421
            my $g_radius               = $graphic_view->findnodes('./socgen:radius/text()')->to_literal ;
422
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
423
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
424
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
425
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
426
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
427
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
428
            my $g_filltype               = $graphic_view->findnodes('./socgen:filltype/text()')->to_literal ;
429
            my $g_fillwidth               = $graphic_view->findnodes('./socgen:fillwidth/text()')->to_literal ;
430
            my $g_angle1               = $graphic_view->findnodes('./socgen:angle1/text()')->to_literal ;
431
            my $g_pitch1               = $graphic_view->findnodes('./socgen:pitch1/text()')->to_literal ;
432
            my $g_angle2               = $graphic_view->findnodes('./socgen:angle2/text()')->to_literal ;
433
            my $g_pitch2               = $graphic_view->findnodes('./socgen:pitch2/text()')->to_literal ;
434
 
435
            unless (defined $g_x & length $g_x > 0){$g_x = "0";}
436
            unless (defined $g_y & length $g_y > 0){$g_y = "0";}
437
            unless (defined $g_radius & length $g_radius > 0){$g_radius = "0";}
438
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
439
            unless (defined $g_width & length $g_width > 0){$g_width = "0";}
440
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
441
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
442
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
443
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
444
            unless (defined $g_filltype & length $g_filltype > 0){$g_filltype = "0";}
445
            unless (defined $g_fillwidth & length $g_fillwidth > 0){$g_fillwidth = "0";}
446
            unless (defined $g_angle1 & length $g_angle1 > 0){$g_angle1 = "0";}
447
            unless (defined $g_pitch1 & length $g_pitch1 > 0){$g_pitch1 = "0";}
448
            unless (defined $g_angle2 & length $g_angle2 > 0){$g_angle2 = "0";}
449
            unless (defined $g_pitch2 & length $g_pitch2 > 0){$g_pitch2 = "0";}
450
            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";
451
            }
452
 
453
 
454
 
455
 
456
 
457
my $cmd ="gaf export -c -s auto -m 5px  --dpi  600  --no-color -o  $png_file $sym_file \n";
458
print "$cmd";
459
if (system($cmd)) {}
460
print "$cmd";
461
 
462
 
463
 
464
 
465
        }
466
 
467
 
468
 
469
 
470
#/*********************************************************************************************/
471
#/                                                                                            */
472
#/                                                                                            */
473
#/                                                                                            */
474
#/                                                                                            */
475
#/                                                                                            */
476
#/                                                                                            */
477
#/*********************************************************************************************/
478
 
479
 
480
 
481
 
482
sub parse_symbol
483
   {
484
   my @params        = @_;
485
   my $s_visibility  = pop(@params);
486
   my $s_name        = pop(@params);
487
   my $s_y_offset    = pop(@params);
488
   my $s_x_offset    = pop(@params);
489
   my $s_graphic     = pop(@params);
490
   my $s_version     = pop(@params);
491
   my $s_component   = pop(@params);
492
   my $s_library     = pop(@params);
493
   my $s_vendor      = pop(@params);
494
 
495
# prevent overload issues
496
   my   $h_x_offset = lc  $s_x_offset;
497
   my   $h_y_offset = lc  $s_y_offset;
498
 
499
   my @ref_symbol;
500
   print "REF  $s_vendor  $s_library  $s_component $s_version   $s_graphic $s_x_offset  $s_y_offset  $s_name $s_visibility \n";
501
 
502
   my $file = yp::lib::find_ipxact_component($s_vendor,$s_library,$s_component,$s_version);
503
   print "REFILE $s_vendor,$s_library,$s_component,$s_version  $file  \n";
504
   my $symbol_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($s_vendor,$s_library,$s_component,$s_version));
505
 
506
 
507
 
508
foreach my $graphic ($symbol_component_file->findnodes("//ipxact:component/ipxact:vendorExtensions/socgen:gEDA_symbol/socgen:graphics/socgen:graphic/socgen:name"))
509
        {
510
        my $g_name                   = $graphic->findnodes('./text()')->to_literal ;
511
        if($g_name eq $s_graphic)
512
          {
513
          print "Graphic  $g_name\n";
514
          }
515
 
516
        }
517
 
518
 
519
 
520
 
521
 
522
 
523
        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"))
524
            {
525
            my $g_x1               = $graphic_view->findnodes('./socgen:x1/text()')->to_literal ;
526
            my $g_y1               = $graphic_view->findnodes('./socgen:y1/text()')->to_literal ;
527
            my $g_x2               = $graphic_view->findnodes('./socgen:x2/text()')->to_literal ;
528
            my $g_y2               = $graphic_view->findnodes('./socgen:y2/text()')->to_literal ;
529
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
530
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
531
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
532
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
533
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
534
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
535
 
536
            unless (defined $g_x1 & length $g_x1 > 0){$g_x1 = "0";}
537
            unless (defined $g_y1 & length $g_y1 > 0){$g_y1 = "0";}
538
            unless (defined $g_x2 & length $g_x2 > 0){$g_x2 = "0";}
539
            unless (defined $g_y2 & length $g_y2 > 0){$g_y2 = "0";}
540
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
541
            unless (defined $g_width & length $g_width > 0){$g_width = "0";}
542
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
543
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
544
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
545
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
546
 
547
            my   $h_x1 = lc  $g_x1;
548
            my   $h_y1 = lc  $g_y1;
549
            my   $h_x2 = lc  $g_x2;
550
            my   $h_y2 = lc  $g_y2;
551
 
552
 
553
            $h_x1  =   $h_x1  + $h_x_offset;
554
            $h_y1  =   $h_y1  + $h_y_offset;
555
            $h_x2  =   $h_x2  + $h_x_offset;
556
            $h_y2  =   $h_y2  + $h_y_offset;
557
 
558
 
559
            push @ref_symbol,   "L   $h_x1 $h_y1 $h_x2 $h_y2 $g_color  $g_width $g_capstyle  $g_dashstyle  $g_dashlength  $g_dashspace  ";
560
            }
561
 
562
 
563
 
564
 
565
 
566
 
567
 
568
        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"))
569
            {
570
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
571
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
572
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
573
            my $g_height           = $graphic_view->findnodes('./socgen:height/text()')->to_literal ;
574
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
575
            my $g_linewidth            = $graphic_view->findnodes('./socgen:linewidth/text()')->to_literal ;
576
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
577
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
578
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
579
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
580
            my $g_filltype               = $graphic_view->findnodes('./socgen:filltype/text()')->to_literal ;
581
            my $g_fillwidth               = $graphic_view->findnodes('./socgen:fillwidth/text()')->to_literal ;
582
            my $g_angle1               = $graphic_view->findnodes('./socgen:angle1/text()')->to_literal ;
583
            my $g_pitch1               = $graphic_view->findnodes('./socgen:pitch1/text()')->to_literal ;
584
            my $g_angle2               = $graphic_view->findnodes('./socgen:angle2/text()')->to_literal ;
585
            my $g_pitch2               = $graphic_view->findnodes('./socgen:pitch2/text()')->to_literal ;
586
 
587
            unless (defined $g_x & length $g_x > 0){$g_x = "0";}
588
            unless (defined $g_y & length $g_y > 0){$g_y = "0";}
589
            unless (defined $g_width & length $g_width > 0){$g_width = "0";}
590
            unless (defined $g_height & length $g_height > 0){$g_height = "0";}
591
            unless (defined $g_color & length $g_color > 0){$g_color = "0";}
592
            unless (defined $g_linewidth & length $g_linewidth > 0){$g_linewidth = "0";}
593
            unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
594
            unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
595
            unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
596
            unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
597
            unless (defined $g_filltype & length $g_filltype > 0){$g_filltype = "0";}
598
            unless (defined $g_fillwidth & length $g_fillwidth > 0){$g_fillwidth = "0";}
599
            unless (defined $g_angle1 & length $g_angle1 > 0){$g_angle1 = "0";}
600
            unless (defined $g_pitch1 & length $g_pitch1 > 0){$g_pitch1 = "0";}
601
            unless (defined $g_angle2 & length $g_angle2 > 0){$g_angle2 = "0";}
602
            unless (defined $g_pitch2 & length $g_pitch2 > 0){$g_pitch2 = "0";}
603
 
604
            my   $h_x = lc  $g_x;
605
            my   $h_y = lc  $g_y;
606
            $h_x  =   $h_x  + $h_x_offset;
607
            $h_y  =   $h_y  + $h_y_offset;
608
            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 ";
609
            }
610
 
611
 
612
 
613
 
614
 
615
 
616
 
617
 
618
 
619
 
620
 
621
 
622
 
623
 
624
 
625
 
626
 
627
 
628
 
629
 
630
 
631
 
632
 
633
 
634
 
635
 
636
 
637
 
638
 
639
 
640
 
641
 
642
 
643
 
644
 
645
 
646
 
647
 
648
 
649
 
650
 
651
 
652
 
653
 
654
        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"))
655
            {
656
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
657
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
658
            my $g_radius               = $graphic_view->findnodes('./socgen:radius/text()')->to_literal ;
659
            my $g_startangle               = $graphic_view->findnodes('./socgen:startangle/text()')->to_literal ;
660
            my $g_sweepangle               = $graphic_view->findnodes('./socgen:sweepangle/text()')->to_literal ;
661
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
662
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
663
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
664
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
665
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
666
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
667
 
668
        unless (defined $g_x & length $g_x > 0){$g_x = "0";}
669
        unless (defined $g_y & length $g_y > 0){$g_y = "0";}
670
        unless (defined $g_radius & length $g_radius > 0){$g_radius = "0";}
671
        unless (defined $g_startangle & length $g_startangle > 0){$g_startangle = "0";}
672
        unless (defined $g_sweepangle & length $g_sweepangle > 0){$g_sweepangle = "0";}
673
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
674
        unless (defined $g_width & length $g_width > 0){$g_width = "0";}
675
        unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
676
        unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
677
        unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
678
        unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
679
 
680
 
681
 
682
 
683
          my   $h_x = lc  $g_x;
684
          my   $h_y = lc  $g_y;
685
 
686
 
687
 
688
             $h_x  =   $h_x  + $h_x_offset;
689
             $h_y  =   $h_y  + $h_y_offset;
690
 
691
 
692
 
693
 
694
 
695
            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";
696
            }
697
 
698
 
699
 
700
 
701
        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"))
702
            {
703
            my $g_x               = $graphic_view->findnodes('./socgen:x/text()')->to_literal ;
704
            my $g_y               = $graphic_view->findnodes('./socgen:y/text()')->to_literal ;
705
            my $g_radius               = $graphic_view->findnodes('./socgen:radius/text()')->to_literal ;
706
            my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
707
            my $g_width            = $graphic_view->findnodes('./socgen:width/text()')->to_literal ;
708
            my $g_capstyle         = $graphic_view->findnodes('./socgen:capstyle/text()')->to_literal ;
709
            my $g_dashstyle        = $graphic_view->findnodes('./socgen:dashstyle/text()')->to_literal ;
710
            my $g_dashlength       = $graphic_view->findnodes('./socgen:dashlength/text()')->to_literal ;
711
            my $g_dashspace        = $graphic_view->findnodes('./socgen:dashspace/text()')->to_literal ;
712
            my $g_filltype               = $graphic_view->findnodes('./socgen:filltype/text()')->to_literal ;
713
            my $g_fillwidth               = $graphic_view->findnodes('./socgen:fillwidth/text()')->to_literal ;
714
            my $g_angle1               = $graphic_view->findnodes('./socgen:angle1/text()')->to_literal ;
715
            my $g_pitch1               = $graphic_view->findnodes('./socgen:pitch1/text()')->to_literal ;
716
            my $g_angle2               = $graphic_view->findnodes('./socgen:angle2/text()')->to_literal ;
717
            my $g_pitch2               = $graphic_view->findnodes('./socgen:pitch2/text()')->to_literal ;
718
 
719
 
720
 
721
        unless (defined $g_x & length $g_x > 0){$g_x = "0";}
722
        unless (defined $g_y & length $g_y > 0){$g_y = "0";}
723
        unless (defined $g_radius & length $g_radius > 0){$g_radius = "0";}
724
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
725
        unless (defined $g_width & length $g_width > 0){$g_width = "0";}
726
        unless (defined $g_capstyle & length $g_capstyle > 0){$g_capstyle = "0";}
727
        unless (defined $g_dashstyle & length $g_dashstyle > 0){$g_dashstyle = "0";}
728
        unless (defined $g_dashlength & length $g_dashlength > 0){$g_dashlength = "0";}
729
        unless (defined $g_dashspace & length $g_dashspace > 0){$g_dashspace = "0";}
730
        unless (defined $g_filltype & length $g_filltype > 0){$g_filltype = "0";}
731
        unless (defined $g_fillwidth & length $g_fillwidth > 0){$g_fillwidth = "0";}
732
        unless (defined $g_angle1 & length $g_angle1 > 0){$g_angle1 = "0";}
733
        unless (defined $g_pitch1 & length $g_pitch1 > 0){$g_pitch1 = "0";}
734
        unless (defined $g_angle2 & length $g_angle2 > 0){$g_angle2 = "0";}
735
        unless (defined $g_pitch2 & length $g_pitch2 > 0){$g_pitch2 = "0";}
736
 
737
 
738
          my   $h_x = lc  $g_x;
739
          my   $h_y = lc  $g_y;
740
 
741
 
742
 
743
             $h_x  =   $h_x  + $h_x_offset;
744
             $h_y  =   $h_y  + $h_y_offset;
745
 
746
 
747
 
748
            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";
749
             }
750
 
751
 
752
 
753
        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"))
754
 
755
        {
756
        my $g_name             = $graphic_view->findnodes('./socgen:name/text()')->to_literal ;
757
        my $g_type             = $graphic_view->findnodes('./socgen:type/text()')->to_literal ;
758
 
759
        my $g_x1               = $graphic_view->findnodes('./socgen:x1/text()')->to_literal ;
760
        my $g_y1               = $graphic_view->findnodes('./socgen:y1/text()')->to_literal ;
761
        my $g_x2               = $graphic_view->findnodes('./socgen:x2/text()')->to_literal ;
762
        my $g_y2               = $graphic_view->findnodes('./socgen:y2/text()')->to_literal ;
763
        my $g_color            = $graphic_view->findnodes('./socgen:color/text()')->to_literal ;
764
        my $g_pintype          = $graphic_view->findnodes('./socgen:pintype/text()')->to_literal ;
765
        my $g_whichend         = $graphic_view->findnodes('./socgen:whichend/text()')->to_literal ;
766
        my $g_visibility       = $graphic_view->findnodes('./socgen:visibility/text()')->to_literal ;
767
        my $g_inversion        = $graphic_view->findnodes('./socgen:inversion/text()')->to_literal ;
768
 
769
 
770
        unless (defined $g_name & length $g_name > 0){$g_name = "no_name";}
771
        unless (defined $g_type & length $g_type > 0){$g_type = "none";}
772
        unless (defined $g_x1 & length $g_x1 > 0){$g_x1 = "0";}
773
        unless (defined $g_y1 & length $g_y1 > 0){$g_y1 = "0";}
774
        unless (defined $g_x2 & length $g_x2 > 0){$g_x2 = "0";}
775
        unless (defined $g_y2 & length $g_y2 > 0){$g_y2 = "0";}
776
        unless (defined $g_color & length $g_color > 0){$g_color = "0";}
777
        unless (defined $g_pintype & length $g_pintype > 0){$g_pintype = "0";}
778
        unless (defined $g_whichend & length $g_whichend > 0){$g_whichend = "0";}
779
        unless (defined $g_visibility & length $g_visibility > 0){$g_visibility = "0";}
780
        unless (defined $g_inversion & length $g_inversion > 0){$g_inversion = "0";}
781
 
782
 
783
 
784
 
785
          my   $h_x1 = lc  $g_x1;
786
          my   $h_y1 = lc  $g_y1;
787
          my   $h_x2 = lc  $g_x2;
788
          my   $h_y2 = lc  $g_y2;
789
 
790
 
791
             $h_x1  =   $h_x1  + $h_x_offset;
792
             $h_y1  =   $h_y1  + $h_y_offset;
793
             $h_x2  =   $h_x2  + $h_x_offset;
794
             $h_y2  =   $h_y2  + $h_y_offset;
795
 
796
        my $color;
797
        my $width;
798
  if($g_pintype eq 1)
799
{
800
      $color = 10;
801
      $width = 30;
802
}
803
else
804
{
805
      $color = 4;
806
      $width = 10;
807
}
808
 
809
 
810
 
811
 
812
        if($g_whichend eq "0")
813
         {
814
         if($g_inversion eq "1")
815
           {
816
           my $spot = $h_x2 -50;
817
           my $spot2 = $h_x2 -100;
818
           push @ref_symbol,   "V   $spot $h_y2 50 6 0 0 0  -1  -1  0 0  -1  -1 -1 -1 ";
819
           push @ref_symbol,   "L   $h_x1 $h_y1 $spot2 $h_y2 $color  $width 0  0  -1  -1  ";
820
           }
821
         else
822
           {
823
           push @ref_symbol,   "L   $h_x1 $h_y1 $h_x2 $h_y2 $color  $width 0  0  -1  -1  ";
824
           }
825
         push @ref_symbol,"P $h_x1 $h_y1 $h_x1 $h_y1 $g_color  $g_pintype $g_whichend";
826
         push @ref_symbol,"{";
827
         push @ref_symbol , "T $h_x2 $h_y2 5 10 $s_visibility  1  0  1  1";
828
         push @ref_symbol , "PINNAME=${s_name}" ;
829
         push @ref_symbol , "T $h_x2 $h_y2 0 8 0  1  0  6  1";
830
         push @ref_symbol , "DIR=${g_type}" ;
831
       }
832
        else
833
         {
834
         if($g_inversion eq "1")
835
           {
836
           my $spot = $h_x1 +50;
837
           my $spot2 = $h_x1 +100;
838
           push @ref_symbol,   "L   $spot2 $h_y1 $h_x2 $h_y2 $color  $width 0  0  -1  -1  ";
839
           push @ref_symbol,   "V   $spot $h_y1 50 6 0 0 0  -1  -1  0 0  -1  -1 -1 -1 ";
840
           }
841
         else
842
           {
843
           push @ref_symbol,   "L   $h_x1 $h_y1 $h_x2 $h_y2 $color  $width 0  0  -1  -1  ";
844
           }
845
         push @ref_symbol,"P $h_x2 $h_y2 $h_x2 $h_y2 $g_color  $g_pintype $g_whichend";
846
         push @ref_symbol,"{";
847
         push @ref_symbol , "T $h_x1 $h_y1 5 10 $s_visibility  1  0  7  1";
848
         push @ref_symbol , "PINNAME=${s_name}" ;
849
         push @ref_symbol , "T $h_x1 $h_y1 0 8 0  1  0  0  1";
850
         push @ref_symbol , "DIR=${g_type}" ;
851
         }
852
       push @ref_symbol,"}";
853
 
854
      }
855
 
856
 
857
 
858
 
859
 
860
return (@ref_symbol);
861
 
862
}
863
 
864
 
865
 
866
 
867
1
868
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.