Re: ALU Implementation - the road traveled thus far
Posted by WBahn on Jun 05, 2019; 5:38pm
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/ALU-Implementation-the-road-traveled-thus-far-tp4033278p4033279.html
If you would, please edit your post to remove the Implementation portion of your part descriptions. In some cases it provides too much of a hint to people trying to figure out how to implement that part. Give them the opportunity to mull it over and struggle with it a bit.
While the table you are referring to (I'm assuming it's Figure 2.6) is a truth table, the output is given in functional form, so it's not a simple matter of writing an expression in canonical form.
Break the problem down into very small pieces -- you will find the ALU is almost trivial to implement if you do.
Take each of the control signals one by one and ask yourself what parts could you use to make just that part happen. Treat each as a black box. If you do that, you don't even need to have the last column of the truth table -- it just documents what you get if you do what each of the inputs tells you to do.
For instance, if the zx input is 0, you want a black box that takes the input x and simply passes it to the output, while if zx is 1 you want to present a 0 at the output. Make a part (or a couple lines of HDL code) to do that and you are done with that control signal.
One tricky part to watch out for is the description for nx is not actually referring to the original x input to the ALU, but rather to the x input as modified by the zx input (i.e., the output of the box described in the previous paragraph).
A better way of presenting this would have been to treat zx and nx as a pair of signals with the description:
nx zx out
0 0 x
0 1 0
1 0 !x
1 1 !0