#! /usr/local/bin/perl
$dir = "RESULT_DC_LIB_w_normalize_waveform";
mkdir $dir if (!-d $dir);
open (AA, "ls *.lib |") or die;
while (<AA>){
chomp;
push @libs, $_;
}
close AA;
foreach $lib (@libs){
chomp ($base_lib = `basename $lib`);
$out = $dir."/".$base_lib;
($libname = $base_lib) =~ s/\.lib//;
open (AA, $lib) or die;
open (BB, ">$out") or die;
while (<AA>){
if (/^library \(/){
print BB "library ($libname) {\n";
} elsif (/nom_temperature \: (\S+)\;/){
$p_temp = $1;
print BB;
} elsif (/nom_voltage \: (\S+)\;/){
$p_vol = $1;
print BB;
} elsif (/^ cell \((\S+)\)/){
$p cell = $1;
if ($p_cell =~ /DCAP/ or $p_cell =~ /ANTENNA/ or $p_cell =~/BHD/ or $p_cel1=~/BOUNDARY/ or $p_cell =~/FILL/ or $p_cell =~/TAPCELL/){
$arc=1;
while (<AA>){
if (/\{/) { $arc +=1; }
if (/\}/) { $arc -=1; }
last if ($arc==0);
}
} else {
print BB;
}
} elsif (/^\s*operating_conditions/) {
print BB " library_features (report_delay_calculation);\n";
print BB $_;
while (<AA>){
if (/^(\s*temperature)/){
$attr = $1;
print BB "$attr : $p_temp;\n";
} elsif (/^(\s*voltage)/){
$attr = $1;
print BB "$attr : $p_vol;\n";
} elsif (/\}/){
print BB;
last
} elsif (/process\s+\:\s+1/){
if ($libname=~/ssgnp/){
print BB " process : 1; /* SSGNPGlobalCorner_LocalMC_MOS_MOSCAP */\n";
} elsif ($libname=~/ffgnp/){
print BB " process : 1; /* FFGNPGlobalCorner_LocalMC_MOS_MOSCAP */\n";
} else {
print BB;
print "[Warning] Cannot judge process corner by judging library file name ($libname)\n";
}
} else {
print BB;
}
}
} elsif (/^\s*cell_footprint/){
#} elsif (/^\s*area \:/){
print BB $_;
if ($p_cell =~ /MB4LVLSRAN2LHCWWRD2BWP360H10P66PDLVT/){
print BB "pg_pin (VBB) {\n";
print BB " pg_type : pwell;\n";
print BB " voltage_name : VBB;\n";
print BB " physical_connection : device_layer;\n";
print BB "}\n";
print BB "pg_pin (VDD) {\n";
print BB " pg_type : primary_power;\n";
print BB " voltage_name : VDD;\n";
print BB " related_bias_pin : VPP;\n";
print BB "}\n";
print BB "pg_pin (VDDO) {\n";
print BB " pg_type : primary_power;\n";
print BB " voltage_name : VDDO;\n";
#print BB " related_bias_pin : VPP;\n";
print BB "}\n";
print BB "pg_pin (VPP) {\n";
print BB " pg_type : nwell;\n";
print BB " voltage_name : VPP;\n";
print BB " physical_connection : device_layer;\n";
print BB "}\n";
print BB "pg_pin (VSS) {\n";
print BB " pg_type : primary_ground;\n";
print BB " voltage_name : VSS;\n";
print BB " related_bias_pin : VBB;\n";
print BB "}\n";
} else {
print BB "pg_pin (VBB) {\n";
print BB " pg_type : pwell;\n";
print BB " voltage_name : VBB;\n";
print BB " physical_connection : device_layer;\n";
print BB "}\n";
print BB "pg_pin (VDD) {\n";
print BB " pg_type : primary_power;\n";
print BB " voltage_name : VDD;\n";
print BB " related_bias_pin : VPP;\n";
print BB "}\n";
#print BB "pg_pin (VDDI) {\n";
#print BB " pg_type : primary_power;\n";
#print BB " voltage_name : VDDI;\n";
#print BB " related_bias_pin : VPP;\n";
#print BB "}\n";
print BB "pg_pin (VPP) {\n";
print BB " pg_type : nwell;\n";
print BB " voltage_name : VPP;\n";
print BB " physical_connection : device_layer;\n";
print BB "}\n";
print BB "pg_pin (VSS) {\n";
print BB " pg_type : primary_ground;\n";
print BB " voltage_name : VSS;\n";
print BB " related_bias_pin : VBB;\n";
print BB "}\n";
}
} elsif (/^\s*pg_pin/){
while (<AA>){
last if (/\}/);
}
} else {
print BB;
}
}
close AA;
close BB;
}