A bit-counting comparator (BCC) is a logic circuit that takes some number of counting inputs
A1, A2, A3, ..., An as well as inputs
B1, B2, B4, B8, ... representing a number. It then returns
1 if the total number of
A inputs that are on is greater than the number represented in binary by the
B inputs (e.g.
B8 would make the number
For example, for a bit-counting comparator that takes
5 inputs, of which
B2 are set to
1, will return
1 because there are 3
A inputs that are on, which is greater than
2 (the number represented by only
B2 being on).
Your task is to create a bit-counting comparator that takes a total of 16
A inputs and 4
B inputs (representing bits from
8), using only two-input NAND gates, and using as few NAND gates as possible. To simplify things, you may use AND, OR, NOT, and XOR gates in your diagram, with the following corresponding scores:
Each of these scores corresponds to the number of NAND gates that it takes to construct the corresponding gate.
The logic circuit that uses the fewest NAND gates to produce a correct construction wins.