blob: 706db4a8d8aff2d25c35f8f5a86bdc98f3f9015e [file] [log] [blame]
#!/usr/bin/perl
use warnings;
use strict;
use feature "switch";
#use experimental qw( switch );
open (LIB, $ARGV[1]) ;
my $prefix = $ARGV[0];
my @cells = (
# conb - 1
'conb_1',
# AND - 9
'and2_1','and2_2','and2_4',
'and3_1','and3_2','and3_4',
'and4_1','and4_2','and4_4',
# Buffer - 5
'buf_1','buf_2','buf_4','buf_8','buf_16',
# Clock Buffer - 5
'clkbuf_1','clkbuf_2','clkbuf_4','clkbuf_8','clkbuf_16',
# Inverters - 5
'inv_1','inv_2','inv_4','inv_8','inv_16',
# Majority - 3
'maj3_1','maj3_2','maj3_4',
# Multiplexors - 10
'mux2_1','mux2_2','mux2_4','mux2_8',
'mux2i_1','mux2i_2','mux2i_4',
'mux4_1','mux4_2','mux4_4',
# NAND - 10
'nand2_1','nand2_2','nand2_4','nand2_8',
'nand3_1','nand3_2','nand3_4',
'nand4_1','nand4_2','nand4_4',
# NOR - 10
'nor2_1','nor2_2','nor2_4','nor2_8',
'nor3_1','nor3_2','nor3_4',
'nor4_1','nor4_2','nor4_4',
# OR - 9
'or2_1','or2_2','or2_4',
'or3_1','or3_2','or3_4',
'or4_1','or4_2','or4_4',
# XOR - 4
'xor2_1','xor2_2','xor2_4',
'xor3_1',
# XNOR - 4
'xnor2_1','xnor2_2','xnor2_4',
'xnor3_1',
# OA & OAI - 24
'o41a_1', 'o41a_2', 'o41a_4',
'o41ai_1', 'o41ai_2', 'o41ai_4',
'o32a_1', 'o32a_2', 'o32a_4',
'o32ai_1', 'o32ai_2', 'o32ai_4',
#'o22a_1',
'o22a_2', 'o22a_4',
#'o22ai_1',
'o22ai_2', 'o22ai_4',
#'o21a_1',
'o21a_2', 'o21a_4',
#'o21ai_1',
'o21ai_2', 'o21ai_4',
# AO & AOI - 48
'a41o_1', 'a41o_2', 'a41o_4',
'a41oi_1', 'a41oi_2', 'a41oi_4',
'a32o_1', 'a32o_2', 'a32o_4',
'a32oi_1', 'a32oi_2', 'a32oi_4',
'a22o_1', 'a22o_2', 'a22o_4',
'a22oi_1', 'a22oi_2', 'a22oi_4',
'a21o_1', 'a21o_2', 'a21o_4',
'a21bo_1', 'a21bo_2', 'a21bo_4',
'a21oi_1', 'a21oi_2', 'a21oi_4',
'a21boi_1', 'a21boi_2', 'a21boi_4',
'a2111o_1', 'a2111o_2', 'a2111o_4',
'a2111oi_1', 'a2111oi_2', 'a2111oi_4',
'a211o_1', 'a211o_2', 'a211o_4',
'a211oi_1', 'a211oi_2', 'a211oi_4',
'a2bb2oi_1', 'a2bb2oi_2', 'a2bb2oi_4'.
'a2bb2o_1', 'a2bb2o_2', 'a2bb2o_4'.
# FF - 20
'dfrtn_1',
'dfbbn_1', 'dfbbn_2',
'dfbbp_1',
'dfxbp_1', 'dfxbp_2',
'edfxbp_1',
'dfxtp_1', 'dfxtp_2', 'dfxtp_4',
'dfrbp_1', 'dfrbp_2',
'dfrtp_1', 'dfrtp_2', 'dfrtp_4',
'dfsbp_1', 'dfsbp_2',
'dfstp_1', 'dfstp_2', 'dfstp_4',
);
#if (grep { $_ eq 'flour' } @ingredients) { ... }
my $state = 0;
my $count = 0;
while(my $line=<LIB>){
given ($state) {
when ($state==0){
#print $line;
if ($line =~ /cell\s*\(\"?${prefix}_(.*?)\"?\)/) {
#print "$1\n";
if (grep { $_ eq $1 } @cells) {
$state = 1;
print $line;
} else {
$state = 2;
print "/* removed $1 */\n"
}
$count = 1;
} else {
print $line;
}
}
when($state==1){
$count++ if ($line =~ /\{/);
$count-- if ($line =~ /\}/);
$state = 0 if($count==0);
print $line;
}
when($state==2){
$count++ if ($line =~ /\{/);
$count-- if ($line =~ /\}/);
$state = 0 if($count==0);
}
}
}