randras wrote

Hi, I made a little

table to check the ALU functionality. In the best case, its output matches 24 different formulas, thus it seems a bit redundant (40 redundant results). With using unique bitmasks, it would not be more optimal (=64 different formulas)?

There's a problem in your spreadsheet -- for example, look at 000001 which should be computing the NAND function, not constant -2. It looks like OO's AND function is not a bitwise and, but rather a C-like logical and.

It would certainly be possible to specify an ALU design that used the control bits more efficiently, for example 2 bits could be used to select functional units within the ALU -- arithmetic, logical, shift, one other -- and 4 bits to select which of 16 functions is computed by each functional unit. This ALU would be quite powerful, but would also be quite complex.

The most impressive thing about the Hack ALU is that such a simple design produces all the functions required to build a functional computer.

--Mark