/usr/bin/pads_backannotate is in geda-utils 1:1.6.2-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | #!/usr/bin/perl -w
#
# $Id$
#
# Copyright (C) 2003 Dan McMahill
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# This script is used to process PADS PowerPCB .eco files to backannotate
# changes to gEDA schematics. Not all ECO file sections are implemented,
# and this program is relatively untested. Please proceed with caution.
#
# for parsing input options
use Getopt::Long;
# for ceil function
use POSIX;
# don't allow -he to be interpreted as --help
$Getopt::Long::autoabbrev=0;
&GetOptions( ("help" => \&usage,
"nocopy" => \$nocopy,
"verbose" => \$verbose,
"version" => \&version
) );
usage() if $Getopt::Long::error;
usage() unless @ARGV;
# ECO file name
$eco = shift( @ARGV );
# if no schematic names follow, exit
usage() unless @ARGV;
# make sure the input netlist exists and we can open it
$i = 0;
while( @ARGV ) {
$fname[$i] = shift( @ARGV );
die "Schematic file $fname[$i] does not exist or can not be read"
unless -r $fname[$i];
$i++;
}
$filecnt = $i;
if( $verbose ){ print "Loading ECO file: $eco\n"; }
$eco_state="DEFAULT";
$got_end=0;
open( ECO, "$eco" ) or die "Can't open ECO file $eco !\n";
$line = <ECO>;
if( $line =~ /^\*PADS-ECO-V3\.0\*[\n\r]*$/ ) {
print "Read ECO header line\n" if $verbose ;
} elsif( $line =~ /^\*PADS-ECO-\*/ ) {
print "Unknown ECO file version: $line\n";
exit 1;
} else {
print "Invalid ECO file header: $line\n";
exit 1;
}
while( $line = <ECO> ) {
# if( $verbose ){ print "$line\n"; }
if( $line =~ /^\*CHGPART\*/ ) {
# change type of part (forward annotation)
$eco_state="CHGPART";
next;
} elsif( $line =~ /^\*DEL_ATTRIBUTE\*/ ) {
# delete object attribute (forward annotation)
$eco_state="DEL_ATTRIBUTE";
next;
} elsif( $line =~ /^\*DELPART\*/ ) {
# delete part from the design (forward annotation)
$eco_state="DELPART";
next;
} elsif( $line =~ /^\*DELPIN\*/ ) {
# delete pins from net (forward annotation)
$eco_state="DELPIN";
next;
} elsif( $line =~ /^\*END\*/ ) {
# end of ECO file
$eco_state="END";
$got_end=1;
next;
} elsif( $line =~ /^\*JOINNET\*/ ) {
# join two nets together (forward annotation)
$eco_state="JOINNET";
next;
} elsif( $line =~ /^\*NET\*/ ) {
# add pin to net (forward annotation)
$eco_state="NET";
next;
} elsif( $line =~ /^\*PART\*/ ) {
# add part to the design (forward annotation)
$eco_state="PART";
next;
} elsif( $line =~ /^\*REMARK\*/ ) {
# don't change state on comment lines
print "Skipping *REMARK* line\n" if $verbose;
next;
} elsif( $line =~ /^\*RENNET\*/ ) {
# rename netname (forward annotation)
$eco_state="RENNET";
next;
} elsif( $line =~ /^\*RENPART\*/ ) {
# rename part in design (forward/backward annotation)
$eco_state="RENPART";
print "Starting *RENPART* (Refdes Renumber) section\n" if $verbose;
next;
} elsif( $line =~ /^\*SET_ATTRIBUTE\*/ ) {
# set object attribute (forward annotation)
$eco_state="SET_ATTRIBUTE";
next;
} elsif( $line =~ /^\*SIGNAL\*/ ) {
# part of *NET* and also *SPLITNET* (forward annotation)
$eco_state="SIGNAL";
next;
} elsif( $line =~ /^\*SPLITNET\*/ ) {
# split net into two new nets (forward annotation)
$eco_state="SPLITNET";
next;
} elsif( $line =~ /^\*SWPGATES\*/ ) {
$eco_state="SWPGATES";
print "Starting *SWPGATES* (Gate Swapping) section\n" if $verbose;
next;
} elsif( $line =~ /^\*SWPPINS\*/ ) {
$eco_state="SWPPINS";
print "Starting *SWPPINS* (Pin Swapping) section\n" if $verbose;
next;
} elsif( $line =~ /^\*/ ) {
print "WARNING: Unknown command line:\n";
print " $line\n";
$eco_state="DEFAULT";
next;
} else {
# this must be a data line
#if( $verbose ){ print "Processing data line: $line"; }
}
if( $eco_state =~ "RENPART" ) {
parseRENPART($line);
} elsif( $eco_state =~ "SWPGATES" ) {
parseSWPGATES($line);
} elsif( $eco_state =~ "SWPPINS" ) {
parseSWPPINS($line);
} else {
print "Skipping lines in $eco_state section\n" if $verbose;
}
}
close( ECO );
for($i=0; $i < $filecnt; $i++) {
print "Processing schematic file #", $i+1, ": $fname[$i]\n";
open(NETLIST,"$fname[$i]") or
die "Can't open schematic $fname[$i]: $!\n";
# open output netlist
$outfname="$fname[$i].new";
open(OUTSCH,">$outfname") or die "Can't open $outfname: $!\n";
while($line = <NETLIST>) {
$line = executeRENPART($line);
print OUTSCH "$line";
}
close(NETLIST);
close(OUTSCH);
if( $nocopy ) {
print "Leaving page #",$i+1," output in $outfname\n";
}
else {
system("mv $outfname $fname[$i]");
}
}
print "\n---- Gate Swapping ----\n";
executeSWPGATES();
print "\n---- Pin Swapping ----\n";
executeSWPPINS();
print "\nBackannotation finished ", scalar localtime, "\n";
exit;
#######################################################################
#
# Subroutines
#
#######################################################################
#---------------------------------
# executeRENPART(line)
#---------------------------------
sub executeRENPART {
my $line = shift(@_);
return $line unless defined %cmd_rename;
return $line unless $line =~ /^refdes=/;
# pick out the reference designator
$refdes = $line;
$refdes =~ s/^refdes=//;
$refdes =~ s/[\r\n]*$//;
# see if its listed in our hash of reference designators to be
# renamed
return $line unless exists $cmd_rename{$refdes};
print "executeRENPART(): Renaming $refdes to $cmd_rename{$refdes}\n"
if $verbose;
return "refdes=$cmd_rename{$refdes}\n";
}
#---------------------------------
# executeSWPGATES()
#---------------------------------
sub executeSWPGATES {
my $key;
foreach $key (keys %cmd_swap_gates ) {
print "Please manually swap gates $key and $cmd_swap_gates{$key}\n";
}
}
#---------------------------------
# executeSWPPINS()
#---------------------------------
sub executeSWPPINS {
my $key;
my @pins;
foreach $key (keys %cmd_swap_pins ) {
@pins = split '\.',,$cmd_swap_pins{$key};
print "Please manually swap pins $pins[0] and $pins[1] on $key\n";
}
}
#---------------------------------
# parseRENPART(line)
#---------------------------------
sub parseRENPART {
my $line = shift(@_);
my @refs;
@refs = split ' ',,$line;
print "parseRENPART(): Scheduling rename of $refs[0] to $refs[1]\n"
if $verbose;
$cmd_rename{$refs[0]} = $refs[1];
}
#---------------------------------
# parseSWPGATES(line)
#---------------------------------
sub parseSWPGATES {
my $line = shift(@_);
my @refs;
@refs = split ' ',,$line;
print "parseSWPGATES(): Scheduling swap of gate $refs[0] with $refs[1]\n"
if $verbose;
$cmd_swap_gates{$refs[0]} = $refs[1];
}
#---------------------------------
# parseSWPPINS(line)
#---------------------------------
sub parseSWPPINS {
my $line = shift(@_);
@refs = split ' ',,$line;
@pins = split '\.',,$refs[1];
print "parseSWPPINS(): Scheduling swap of pins on $refs[0] : pins ",
"$pins[0] and $pins[1]\n" if $verbose;
$cmd_swap_pins{$refs[0]} = $refs[1];
}
#---------------------------------
# usage()
#
# prints program usage
#---------------------------------
sub usage {
my $pname = $0;
$pname =~ s/.*\///g;
print "Usage:\n\n";
print "\t$pname [--nocopy] [--verbose] change.eco file1.sch [file2.sch [file3.sch ... ] ]\n";
print "\t$pname --help\n";
print "\t$pname --version\n";
print "\n";
print "$pname reads a PADS PowerPCB ECO file and backannotates changes\n";
print "to a gEDA schematic.\n";
print "\n";
print "$pname accepts the following options:\n";
print "\n";
print " --help Displays this help message.\n";
print "\n";
print " --nocopy If given, this flag leaves the modified files in new files\n";
print " whose names are generated by appending a \".new\" to the\n";
print " original file names. The default is to overwrite the original.\n";
print "\n";
print " --verbose Enables verbose output.\n";
print "\n";
print " --version Shows the version of this program.\n";
print "\n\n";
print "$pname was written by Dan McMahill <dmcmahill\@netbsd.org>\n";
print "\n\n";
exit;
}
#---------------------------------
# version()
#
# prints program version
#---------------------------------
sub version {
open(PROG,"$0") or die "Could not open \"$0\" to find version\n\n";
my $pname = $0;
$pname =~ s/.*\///g;
while($line = <PROG>) {
if( $line =~ /^#\s*\$Id.*\$/) {
@words = split ' ',,$line;
$version = $words[3];
$date = $words[4];
print "$pname ($0): Version $version, $date\n";
exit;
}
}
print "Could not determine version of \"$0\"\n\n";
exit;
}
# ----------------------------------------------
#
# Change Log
#
# $Log$
# Revision 1.1 2003-08-31 21:39:52 ahvezda
# Added pads_backannotate perl script
#
# Revision 1.4 2003/07/19 04:34:55 dan
# bring this program up to a usable state. Refdes renumbering is fully
# supported and pin/gate swapping while not supported, gives a report of
# the manual swaps needed.
#
# Revision 1.3 2003/03/03 03:44:26 dan
# Finish up code to handle the RENPART .eco directive. The output files
# are still not written, but everything else is in place to handle backannotation
# of reference designator renumbers.
#
# Revision 1.2 2003/02/21 12:30:30 dan
# fix perl path
#
# Revision 1.1 2003/02/19 23:31:50 dan
# start (non functional so far) of a pads to gschem backannotation tool
#
#
#
|