1. A method comprising: obtaining access to a truth table having a plurality of rows, each of said rows comprising a plurality of input bits and a plurality of output bits, at least some of said rows comprising don't-care inputs; clustering at least some of said rows into a plurality of multi-row clusters; assigning at least some of said multi-row clusters to ternary content-addressable memory modules of a prefabricated programmable memory array; and specifying in a data structure instructions for interconnecting said ternary content-addressable memory modules with a plurality of input pins of said prefabricated programmable memory array and a plurality of output pins of said prefabricated programmable memory array, in order to implement said truth table.