M-trie: an efficient approach to on-chip logic minimization