blob: 0c5a647ed63d07b9da570d40437433f7e5dc0fb4 [file] [log] [blame] [edit]
#!/usr/bin/perl
# Copyright (c) Efabless Corporation. All rights reserved.
# See LICENSE file in the project root for full license information.
use warnings;
use strict;
use feature "switch";
#use experimental qw( switch );
open (LIB, $ARGV[1]) ;
my $prefix = $ARGV[0];
my @cells = (
# "xnor2_4",
# "dfstp_2",
# "xor3_4",
# "or2b_2",
# "xnor3_2",
# "sdfbbn_2",
# "sdfxtp_2",
# "dfxtp_2",
# "xor2_2",
# "o311ai_2",
# "nand2_2",
# "sdfrtp_2",
# "and4_2",
# "dfsbp_2",
# "or4_2",
# "inv_2",
# "dfrbp_2",
# "buf_8",
# "dlymetal6s4s_1",
# "xor2_4",
# "inv_4",
# "o31ai_2",
# "bufbuf_16",
# "dlygate4sd3_1",
# "o22ai_2",
# "o32ai_2",
# "and3_2",
# "o2111ai_2",
# "dlrbp_2",
# "and4bb_2",
# "nand3b_2",
# "buf_6",
# "and4b_2",
# "a2bb2oi_2",
# "buf_12",
# "and2_2",
# "dlxbn_2",
# "dlrtp_2",
# "xor3_1",
# "a21oi_2",
# "inv_12",
# "o21ai_2",
# "a311oi_2",
# "buf_4",
# "o21bai_2",
# "nand3_2",
# "dlygate4sd2_1",
# "o211ai_2",
# "or4b_2",
# "and3b_2",
# "or4bb_2",
# "sdfrbp_2",
# "o2bb2ai_2",
# "bufinv_16",
# "xor3_2",
# "o41ai_2",
# "or3b_2",
# "inv_8",
# "or2_2",
# "dfrtp_2",
# "bufbuf_8",
# "bufinv_8",
# "buf_16",
# "buf_2",
# "inv_6",
# "xnor3_4",
# "inv_16",
# "and2b_2",
# "a2111oi_2",
# "dfxbp_2",
# "xnor3_1",
# "dlymetal6s6s_1",
# "dfbbn_2",
# "o221ai_2",
# "sdfstp_2",
# "a31oi_2",
# "a211oi_2",
# "nand2b_2",
# "a22oi_2",
# "dlymetal6s2s_1",
# "dlxtn_2",
# "a21boi_2",
# "dlrtn_2",
# "a221oi_2",
# "or3_2",
# "sdfsbp_2",
# "xnor2_2",
# "sdfxbp_2"
# conb - 1
'conb_1',
# AND - 9
'and2_4',
'and3_4',
'and4_4',
# Buffer - 5
'buf_8','buf_16',
# Clock Buffer - 5
#'clkbuf_1','clkbuf_2','clkbuf_4','clkbuf_8','clkbuf_16',
# Inverters - 5
'inv_8','inv_16',
# Majority - 3
'maj3_4',
# Multiplexors - 10
'mux2_8',
'mux2i_4',
'mux4_4',
# NAND - 10
'nand2_4','nand2_8',
'nand3_4',
'nand4_4',
# NOR - 10
'nor2_4','nor2_8',
'nor3_4',
'nor4_4',
# OR - 9
'or2_4',
'or3_4',
'or4_4',
# XOR - 4
'xor2_4',
# XNOR - 4
'xnor2_4',
# OA & OAI - 24
'o41a_4',
'o41ai_4',
'o32a_4',
'o32ai_4',
#'o22a_1',
'o22a_4',
#'o22ai_1',
'o22ai_4',
#'o21a_1',
'o21a_4',
#'o21ai_1',
'o21ai_4',
# AO & AOI - 48
'a41o_4',
'a41oi_4',
'a32o_4',
'a32oi_4',
'a22o_3',
'a22oi_4',
'a21o_4',
'a21bo_4',
'a21oi_4',
'a21boi_4',
'a2111o_4',
'a2111oi_4',
'a211o_4',
'a211oi_4',
'a2bb2oi_4'.
'a2bb2o_4'.
# FF - 20
'dfbbn_2',
'dfxbp_2',
'dfxtp_4',
'dfrbp_2',
'dfrtp_4',
'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);
}
}
}