Hi all,
I have some code below that I wrote. Before you thow-up when you see it,
understand this is why I am posting it. I need to clean this up, even I
think it's bad. I would like to get something simpler and more elegant, but
not a 3 line replacement that only Larry could understand. Thanks so much
<cut here>
#!/bin/perl -w
# Ok here is a quick summary of what this thing is supposed to do.
# First we use the tool ./fh to go create the file hierachy file. This will
# return something that looks like the following:
# possibly the top cell
# topcell : 1
# subcell0 : 2
# subcell1 : 2
# subsubcell0 :3
# subcell0 : 2
# subcell2 : 2
# subcell0 : 3
# subcell1 : 3
# subsubcell0 : 4
# Now all I want to do is parse this file for individually created cells.
# 1. So, I need to remove the first line - it's always garbage.
# 2. I also need to remove any cells that contain "$" as they too aregarbage.
# 3. I also want to strip the ":" and anything that follows
# 4. Lastly, I don't want duplicates so I need to check them to make sure
# the names (subcells) don't already exist.
#
# Ideally, this will not rewrite this to the 2nd file, because I dont' need
# it, in fact I don't really even need the first one. All I need to be able
# to do is to clean up the output (format it) and print it to the screen.
#
my $FILEHIERTOOL = "./fh";
my $design = "FPD33684B1.gds" ;
print "..Examining the file $design for problems \n";
# Open up the list of cells..
system ("$FILEHIERTOOL -g $design -S > cells.list 2> /dev/null");
open (CELL, "cells.list") || die "Can't access cells.list\n";
open (LIST, ">cells.clean.list");
while (<CELL>) {
my $line = $_;
chop($line);
for ($line) {
# Remove the first line -->>CHEESY<<-- (Solves #1)
s/possibly.*/\ /;
# Remove all Cadence PCells (Solves #2)
s/\b.*\$.*//;
# Remove every level of hier (Solves #3)
s/\ :.*\n//;
print LIST "$list";
}
}
# Now this is all for the last step. It seems like overkill
close CELL;
close LIST;
open (LIST, "cells.clean.list");
while (<LIST>){
my $string = $_;
my $i;
my %h = map { $_ => $i++ } split(/[\b\s]+/,$string);
print join(" ", sort { $h{$a} <=> $h{$b} } keys %h);
print "\n";
}
close LIST;
<cut here>
--
Steven M. Klass
Physical Design Manager
National Semiconductor Corp
7400 W. Detroit Street
Suite 170
Chandler AZ 85226
Ph:480-753-2503
Fax:480-705-6407
[EMAIL PROTECTED]
http://www.nsc.com
fixfh.pl
Description: Perl program
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
