Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!/usr/bin/perl
# This version of add_ports is used only with EDIF files
#A component of the add-ports script, used to split an EDIF file
#somewhere in its interface list
print "perl script ", q($Header: c:\\cygwin\\cvsroot/Vert03/scripts/add_ports,v 1.1.1.1 2003/11/04 23:35:00 mjames Exp $), "\n";
if ( 3 > @ARG ) {
print "add_ports entity acf_file edf_file\n";
exit 0;
}
$entity=@ARGV[0];
$acf=@ARGV[1];
$edif=@ARGV[2];
$edif_new="$edif.new";
$edif_bak="$edif.bak";
$s = 0;
$rsv_pat="[Rr][Ss][Vv][0-9]+[Zz]";
open(IN1, "<$acf");
open(IN, "<$edif");
open(OUT, ">$edif_new");
system("rm -f $edif_bak");
system("cp $edif $edif_bak");
print "looking for entity '$entity'\n";
print "in file '$acf' to edit '$edif'\n";
$s=0;
$cnt = 0;
while( <IN1> ) {
if (/CHIP $entity/) {
print "Located entity '$entity' in '$acf'\n";
$s=1;
break;
}
if($s==1 && /END;/)
{
$s=0;
break;
}
if( $s==1 && /($rsv_pat)/ ) {
@rsv[$cnt++] = $1;
}
}
#for ($i=0;$i<$cnt;$i++) {
# print @rsv[$i],"\n";
# }
$s=0;
$del = 0;
while ( <IN> ) {
# trash all previously reserved pins first
if (s/\(port ($rsv_pat) \( direction INPUT\)\)//g ) {
$del++;
}
#kill all blank lines
if ( length($_)<= 1) {
break;
}
else {
#Look for a cell declaration
#Match entity
if( /\(cell\s*$entity/m) {
$s = 1;
print "located '$entity' in '$edif'\n";
}
#not match entity
elsif ( /\(cell\s*/ ) {
$s = 0;
}
if( $s==1 && /\(interface\s*(.*)/) {
$remainder = $1;
# printf ("in interface of %s\n",$entity);
print OUT "(interface\n";
for($i=0;$i<$cnt;$i++) {
print OUT "(port $rsv[$i] ( direction INPUT))\n";
}
print OUT "$remainder\n";
$s= 0;
}
else {
print OUT $_;
}
}
}
print "inserted $cnt reservations, removed $del reservations from $entity\n";
# sort out file names
system("mv $edif_new $edif");