#A component of the add-ports script, used to split an EDIF file #somewhere in its interface list BEGIN { s = 0; }; #Look for a cell declaration # for EDIF with the cellname on the next line there will be only one word /\(cell/ { if ( length($1)==5 && s==0 ) { if ( NF==1 ) { s = 6 } else if(($2 ~ ent) && (length($2)==length(ent)) ) { s = 1; printf("got entity %s\n",ent) } } } /\(interface/ { if (s == 1) { print ("(interface ") > out1; printf ("in interface of %s\n",ent); for (i = 2; i<=NF; i++) { printf ("%s ",$i) > out2 }; printf ("\n") > out2; #flag to 2 to show we have done the first section s= 2 } } #any reserved ports already added are dropped by setting the flag to 4 #so they are not printed, both rsv00001z and RSV00020z style names /[rR][sS][vV][0-9]+[zZ]/ { s = 4 } # we are expecting an entity-name //{ if(s<2) { print > out1 } else if (s==2 || s==4 ) { s = 3 } else if (s==3) { print > out2 } else if (s==6) { print > out1 ;s= 5 } else if (s==5) { print > out1; # need protection against strings containing "(" if ((NF >= 1) && substr($1,1,1) !~ "\(" && ent ~ $1) { s = 1; printf("got entity %s\n",ent) } else { s = 0 } } }