Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | #!/usr/bin/perl |
| 2 | # This version of add_ports is used only with EDIF files |
||
| 3 | |||
| 4 | #A component of the add-ports script, used to split an EDIF file |
||
| 5 | #somewhere in its interface list |
||
| 6 | 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"; |
||
| 7 | if ( 3 > @ARG ) { |
||
| 8 | print "add_ports entity acf_file edf_file\n"; |
||
| 9 | exit 0; |
||
| 10 | } |
||
| 11 | $entity=@ARGV[0]; |
||
| 12 | $acf=@ARGV[1]; |
||
| 13 | $edif=@ARGV[2]; |
||
| 14 | $edif_new="$edif.new"; |
||
| 15 | $edif_bak="$edif.bak"; |
||
| 16 | $s = 0; |
||
| 17 | |||
| 18 | $rsv_pat="[Rr][Ss][Vv][0-9]+[Zz]"; |
||
| 19 | |||
| 20 | |||
| 21 | open(IN1, "<$acf"); |
||
| 22 | open(IN, "<$edif"); |
||
| 23 | open(OUT, ">$edif_new"); |
||
| 24 | |||
| 25 | |||
| 26 | system("rm -f $edif_bak"); |
||
| 27 | system("cp $edif $edif_bak"); |
||
| 28 | |||
| 29 | |||
| 30 | print "looking for entity '$entity'\n"; |
||
| 31 | print "in file '$acf' to edit '$edif'\n"; |
||
| 32 | |||
| 33 | $s=0; |
||
| 34 | $cnt = 0; |
||
| 35 | while( <IN1> ) { |
||
| 36 | if (/CHIP $entity/) { |
||
| 37 | print "Located entity '$entity' in '$acf'\n"; |
||
| 38 | $s=1; |
||
| 39 | break; |
||
| 40 | } |
||
| 41 | if($s==1 && /END;/) |
||
| 42 | { |
||
| 43 | $s=0; |
||
| 44 | break; |
||
| 45 | } |
||
| 46 | |||
| 47 | if( $s==1 && /($rsv_pat)/ ) { |
||
| 48 | @rsv[$cnt++] = $1; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | #for ($i=0;$i<$cnt;$i++) { |
||
| 53 | # print @rsv[$i],"\n"; |
||
| 54 | # } |
||
| 55 | |||
| 56 | $s=0; |
||
| 57 | |||
| 58 | $del = 0; |
||
| 59 | while ( <IN> ) { |
||
| 60 | |||
| 61 | |||
| 62 | # trash all previously reserved pins first |
||
| 63 | if (s/\(port ($rsv_pat) \( direction INPUT\)\)//g ) { |
||
| 64 | $del++; |
||
| 65 | } |
||
| 66 | |||
| 67 | #kill all blank lines |
||
| 68 | if ( length($_)<= 1) { |
||
| 69 | break; |
||
| 70 | } |
||
| 71 | else { |
||
| 72 | #Look for a cell declaration |
||
| 73 | #Match entity |
||
| 74 | if( /\(cell\s*$entity/m) { |
||
| 75 | $s = 1; |
||
| 76 | print "located '$entity' in '$edif'\n"; |
||
| 77 | } |
||
| 78 | #not match entity |
||
| 79 | elsif ( /\(cell\s*/ ) { |
||
| 80 | $s = 0; |
||
| 81 | } |
||
| 82 | |||
| 83 | if( $s==1 && /\(interface\s*(.*)/) { |
||
| 84 | $remainder = $1; |
||
| 85 | # printf ("in interface of %s\n",$entity); |
||
| 86 | print OUT "(interface\n"; |
||
| 87 | for($i=0;$i<$cnt;$i++) { |
||
| 88 | print OUT "(port $rsv[$i] ( direction INPUT))\n"; |
||
| 89 | } |
||
| 90 | print OUT "$remainder\n"; |
||
| 91 | $s= 0; |
||
| 92 | } |
||
| 93 | else { |
||
| 94 | print OUT $_; |
||
| 95 | } |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | |||
| 100 | print "inserted $cnt reservations, removed $del reservations from $entity\n"; |
||
| 101 | |||
| 102 | # sort out file names |
||
| 103 | system("mv $edif_new $edif"); |