hneemann / Digital

A digital logic designer and circuit simulator.
GNU General Public License v3.0
4.47k stars 450 forks source link

Higher dimension Karnaugh maps (5 and 6 variables) #536

Open maltaisn opened 4 years ago

maltaisn commented 4 years ago

The Karnaugh table concept can be extended with 5 and 6 variables, becoming some sort of Karnaugh cube. A cube isn't very practical for visualization though, so instead each layer can be shown in a separate 2D Karnaugh map. Extra variables headers are shown on the side.

I took a few hours to implement the concept with 5 variables, it looks like this: demo

I can extend it to 6 variables and send a pull request if you're interested.

One issue is that with 6 variables there's a maximum of 32 covers possible, so a lot a different colors are needed. Even with 5 variables I didn't bother, the 8 colors just get reused. I thought maybe I could add a color effect when a group is hovered to differentiate them?

Also the two vertical headers in the middle could be omitted since they are already present on both sides. The result would be single big table instead, like this: https://www.mathematik.uni-marburg.de/~thormae/lectures/ti1/code/karnaughmap/, and would support up to 8 variables.

hneemann commented 4 years ago

I am unhappy with the quality of the code of the current K-Map implementation. So I don't want to complicate the code any further before I have cleaned it up. Unfortunately I don't really have the time to do this at the moment. However, the idea is good and I also think that this would be a nice extension. But an extension to more than 5 or maybe 6 variables doesn't make much sense to me. No student will ever create such a K-Map by hand. If you want to minimize equations with so many variables by hand, you will rather use QMC. And to be honest, a student will probably implement QMC before he starts to do it by hand. I would have done that at least. :-)

callegar commented 1 year ago

Would also be nice to have an option to collect the zeros rather than the ones, in order to visualize minimal product-of-sums expressions too.

callegar commented 1 year ago

See also 1127