#!/usr/bin/perl -w
my $now = `date +%y_%m_%d_%Hh%Mm`;
open(FH, "<./eco_changes.tcl") or die "Cant open file $!";
open (OUT,">tempus_from_pt.tcl");
print OUT "report_resource\n";
print OUT "setEcoMode -updateTiming false\n";
print OUT "setEcoMode -refinePlace false -prefixName ECO_FIX_group5 -batchMode true -honorDontUse false -honorFixedStatus false\n";
my $flag = 0;
my $hinst = "";
while (<FH>) {
chomp;
my $line = $_;
next if $line =~ /^#/;
next if $line =~ /^\s*$/;
if ($line =~ /^current_instance$/) {
$flag = 1;
$hinst = "";
} elsif ($line =~ /^current_instance\s\{(\S+)\}$/) {
$flag = 0;
$hinst = $1;
} elsif ($flag == 1 || $hinst ne "") {
if ($line =~ /^insert_buffer \[get_pins \{(\S+)\}\] (\S+) -new_net_names \{(\S+)\} -new_cell_names \{(\S+)\}/) {
my $term = $1;
my $cell = $2;
my $new_net = $3;
my $new_inst = $4;
if ($hinst ne "") {
$term = "$hinst/$term";
#$new_net = "$hinst/$new_net";
#$new_inst = "$hinst/$new_inst";
print OUT "ecoAddRepeater -cell $cell -term $term -name $new_inst -hinstGuide $hinst -newNetName $new_net\n";
} else {
print OUT "ecoAddRepeater -cell $cell -term $term -name $new_inst -newNetName $new_net\n";
}
} elsif ($line =~ /^size_cell\s+\{(\S+)\} \{(\S+)\}/) {
my $inst = $1;
my $cell = $2;
if ($hinst ne "") {
$inst = "$hinst/$inst";
print OUT "## module: $hinst\n";
print OUT "ecoChangeCell -inst $inst -cell $cell\n";
} else {
print OUT "ecoChangeCell -inst $inst -cell $cell\n";
}
} elsif ($line =~ /^insert_buffer \[get_pins \{(\S+)\}\] (\S+) -inverter_pair -new_net_names \{(\S+) (\S+)\} -new_cell_names \{(\S+) (\S+)\}/) {
my $term = $1;
my $cell = $2;
my $new_net1 = $3;
my $new_net2 = $4;
my $new_inst1 = $5;
my $new_inst2 = $6;
if ($hinst ne "") {
$term = "$hinst/$term";
print OUT "ecoAddRepeater -cell $cell -term $term -name {{ $new_inst1 $new_inst2}} -hinstGuide $hinst -newNetName {{$new_net1 $new_net2}}\n";
#print OUT "ecoAddRepeater -cell $cell -term $term -name $new_inst2 -hinstGuide $hinst -newNetName $new_net2\n";
} else {
print OUT "ecoAddRepeater -cell $cell -term $term -name {{ $new_inst1 $new_inst2}} -newNetName {{$new_net1 $new_net2}}\n";
#print OUT "ecoAddRepeater -cell $cell -term $term -name $new_inst2 -newNetName $new_net2\n";
}
} elsif ($line =~ /^add_buffer_on_route \[get_net -of \{(\S+)\}\] -user_specified_buffers \{ (.*)\} -no_legalize/) {
my $term = $1;
my $buffer_tmp = $2;
$buffer_tmp =~ s/\s0//g;
my @buffers = reverse split (/ /,$buffer_tmp);
if ($hinst ne "") {
$term = "$hinst/$term";
}
foreach my $b (@buffers) {
push @tmp, $b;
if ($b =~ /PhyEco.*/) {
if ($hinst ne "") {
print OUT "ecoAddRepeater -cell $tmp[2] -name $tmp[3] -net \[get_object_name \[get_net -of $term\]\] -loc $tmp[1] $tmp[0] -hinstGuide $hinst\n";
} else {
print OUT "ecoAddRepeater -cell $tmp[2] -name $tmp[3] -net \[get_object_name \[get_net -of $term\]\] -loc $tmp[1] $tmp[0]\n";
}
@tmp = qw//;
}
}
} else {
print "## exceptions: $line\n";
}
} else {
print "## exceptions: $line\n";
}
}
print OUT "report_resource\n";
print OUT "setEcoMode -reset\n";
print OUT "report_resource\n";
close FH;
close OUT;