Is the method used to make the Hack ALU an exception or the rule?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Is the method used to make the Hack ALU an exception or the rule?

Waakzaam Hert
I worked on project 02 over the last weeks and was able to finished it as suggested by the authors. The ALU Worksheet posted by ybakos was really helpful. After filling out the worksheet the scheme and the .hdl code came easy and I had my AHA moment!
After finishing it I scanned through most chapter 2 subjects in this Q&A forum to find out if the way the Hack ALU approach is a standard method used for most ALU's used in commercial CPU's or if it is the exception. Although elegant and apparently very efficient I have at the same time the idea that it is an approach out of the ordinary. For one reason or the other I have the feeling that the industry doesn't look for this type of elegant solutions, but just want to follow a standardized approach.
Thank for any insight and kind regards/
Reply | Threaded
Open this post in threaded view
|

Re: Is the method used to make the Hack ALU an exception or the rule?

cadet1620
Administrator
Yes, the Hack ALU is particularly elegant, making it quite easy to implement, and most (all?) comercial microprocessors have much more complex ALUs.

Mostly this is a case of "form follows function." The Intel 8080, which ushered in the PC revolution, supported the following functions in its ALU:
    Add
    Add with carry
    Subtract
    Subtract with borrow
    Compare
    Increment
    Decrement
    And
    Or
    Xor
    Rotate right
    Rotate right through carry
    Rotate left
    Rotate left through carry
    Decimal Adjust for Add (used with Add/Sub to do BCD)
This is a fairly complex mix of operations, and it's nowhere near the complexity of a modern microprocessor.

Industry looks for solutions optimized for speed and die-size. For the above list, off the top of my head, I see 4 functional units: arithmetic, logical, rotate and DAA. The arithmetic unit and the rotate unit will be able to have some good, possibly elegant optimizations. Logical and DAA not so much.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Is the method used to make the Hack ALU an exception or the rule?

Waakzaam Hert
Hello Mark, that is what I thought.

I have another related question. If we would "design" the Hack ALU in a "form follows function" approach would we use the same input controls zx, nx, ... or would we decide to use another set of controls? We need to implement 18 functions so we need only 5 control bits.
The control bits for the current ALU have an actual meaning (zx = zero the x input) but would control bits for a "form follows function" approach also have a meaning or would the API stipulates for instance: x + y <=> control bits = 10110 without any further detail?

Thanks for your quick response on my earlier question and have a nice day.
Reply | Threaded
Open this post in threaded view
|

Re: Is the method used to make the Hack ALU an exception or the rule?

cadet1620
Administrator
This post was updated on .
Let's assume that we're starting with nothing but the list of functions to be supported, and try a stream of conscience design...

There are two obvious functional groups; arithmetic and logical. One control bit will need to select between the two groups.

The logical group is straightforward so we should design the arithmetic group first. For now, we'll hope the constants fall out somewhere along the way.

We need to do addition, subtraction, increment and decrement. It's a minor reconfiguration of a full adder to do these four functions:
    adder configurations
We need to assign one control bit to select Y vs. FFFF and one bit to select the inverter / carry in.

We're missing reverse subtraction and inc/dec Y. I see that if we swap X and Y inputs we'll get those 3 functions too. We need another control bit to cause this swap.

At this point we have X+Y, X-Y, Y-X, X+1, Y+1, X-1 and Y-1. Not too bad for 3 control bits.

Missing are -X and -Y which are clearly arithmetic, and constant 1 which feels like it will need an arithmetic operation like 0+1 to generate it. I'm not sure how to add them at the moment.

It's time to work on the logical group. It will need to handle X&Y, X|Y, X, Y, !X and !Y. It would be nice if it can generate 0 and FFFF as well. Using the input swapper and Y vs. FFFF circuit as common input processing to both groups should be useful for generating the single variable functions.

I'll stop here for now and wait to hear from you, assuming that you might want to try your hand at finishing off this design.  I also need to think about the missing arithmetic functions!

I think I'll try building this in Logisim. (I highly recommend Logisim http://www.cburch.com/logisim/. The adder graphic came from it.)

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Is the method used to make the Hack ALU an exception or the rule?

Waakzaam Hert
Hello Mark,

I have seen your design.  I am away for work, but will be at home next week. I will definitely try to work on your design and hope to come up some answers to the question you asked. But I have first to grasp your work in all its details.

Regards
Reply | Threaded
Open this post in threaded view
|

Re: Is the method used to make the Hack ALU an exception or the rule?

cadet1620
Administrator
This is way beyond the scope of this course. You probably should work your way through chapter 5 before worrying about this alternate design.

That said, I did manage to come up with a design that can do the required computations using 5 control bits, but it uses more hardware and is harder to understand than the Hack ALU. I am quite impressed at the clarity and simplicity of the Hack architecture.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Is the method used to make the Hack ALU an exception or the rule?

Waakzaam Hert
Mark,

Hint accepted, I will first continue the course.

Kind regards

Op 6-jun-2013, om 13:56 heeft cadet1620 [via Nand2Tetris Questions and Answers Forum] het volgende geschreven:

This is way beyond the scope of this course. You probably should work your way through chapter 5 before worrying about this alternate design.

That said, I did manage to come up with a design that can do the required computations using 5 control bits, but it uses more hardware and is harder to understand than the Hack ALU. I am quite impressed at the clarity and simplicity of the Hack architecture.

--Mark


To unsubscribe from Is the method used to make the Hack ALU an exception or the rule?, click here.
NAML

Eddy MEYSMAN
ISO9001 & CEN16001 Lead Auditor

TELCONTAR BVBA
gsm +32 476 41 10 76
Achterstraat 219, b2
Sint Antonius Zoersel
Belgiƫ