cjdrake / pyeda

Python EDA
BSD 2-Clause "Simplified" License
304 stars 54 forks source link

Restrict table or/and/xor operations to tables with matching inputs #104

Open cjdrake opened 9 years ago

cjdrake commented 9 years ago

Truth tables and implicant tables are not a good form for symbolic Boolean algebra. When the columns of two tables don't match, performing algebraic operations is extremely expensive. For example, the current TruthTable implementation performs a union of the support of both tables, and then does a restrict for every point in the matching space.

It is far cheaper to require two tables to have matching columns, and then perform the operator directly on the underlying data.

For example, take these two tables: OneHot(a, b, c) : "01101000" Majority(a, b, c) : "00010111"

Using the current algorithm, to perform an OR would require eight individual OR operations on the underlying bits. This proposal would just OR the two 16-bit (b/c of PC notation) words together, which is a single CPU op. If you attempt to do algebraic operators on two tables with mismatched columns, just throw a ValueError.