Subversion Repositories Vertical

Rev

Go to most recent revision | Details | 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
 
7
if (@ARGV < 3)
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
#Look for a cell declaration
63
# for EDIF with the cellname on the next line there will be only one word
64
# trash all previously reserved pins first 
65
if (s/\(port ($rsv_pat) \( direction INPUT\)\)//g ) {
66
  $del++;
67
  }  
68
 
69
if ( length($_)<= 1) {
70
  break;
71
  }
72
else {
73
  if( /\(cell\s*$entity/m) {
74
    $s = 1;
75
    print "located '$entity' in '$edif'\n";
76
    }
77
  elsif ( /\(cell\s*/ ) {
78
      $s = 0;
79
      }
80
 
81
  if( $s==1 && /\(interface\s*(.*)/) {
82
      $remainder = $1;
83
#      printf ("in interface of %s\n",$entity);
84
      print OUT "(interface\n";
85
      for($i=0;$i<$cnt;$i++) {
86
        print OUT "(port $rsv[$i] ( direction INPUT))\n";
87
        }
88
      print OUT "$remainder\n";
89
      $s= 0;
90
      }
91
  else  {
92
    print OUT $_;
93
    }
94
    }
95
    }
96
 
97
 
98
print "inserted $cnt reservations, removed $del reservations from $entity\n";
99
 
100
# sort out file names
101
system("mv $edif_new $edif");