ALU Worksheet

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

ALU Worksheet

ybakos
I created a worksheet to help guide my students to realize that combining four simple Boolean/binary operations (zeroing, bitwise negation, summing, anding) in a two's complement number system can yield eighteen functions (per figure 2.6).

This is to help assert the path of using the simple operations as mentioned in the implementation hint on page 39, as opposed to just diving in trying to implement the higher-level functions as they know them. For example, a student may try to use Inc16 to implement x+1 rather than using the combined simple operations in figure 2.6. Although this may be possible, I want to be sure the student embraces the underlying design of the ALU and has a nice "Aha!" moment.

I'll let you know how well this works in practice in February 2010.

alu_worksheet.pdf
Reply | Threaded
Open this post in threaded view
|

Re: ALU Worksheet

Omar
Can you explain what I'm supossed to do in this worksheet? Im quite confused.

Thank you.
djh
Reply | Threaded
Open this post in threaded view
|

Re: ALU Worksheet

djh
I had the same problem at first. (That's why I ended up here. )

After some time I finagled it out though:
Each "exercise" in the worksheet corresponds to one line in the ALU-truth-table.

So the first example, where the solution is given, corresponds to the line where f(x,y) is supposed to yield 0.
The next where f(x,y) yields 1 ... and so on.

(And rereading the text in the alu-worksheet it says so right from the beginning )


BTW: Like probably many others in the forum I'm going through the book all on my own - with no background knowledge in EE or such. I therefore absolutely depend on the forum. Without you guys I probably would have been lost already in ch. 1. So - thanks a lot for all the summaries, helpful hints, tables and other tools you come up with!!!
Reply | Threaded
Open this post in threaded view
|

Re: ALU Worksheet

philliph
In reply to this post by ybakos
This worksheet was indeed great for seeing the patterns in the input bits to perform the various operations. However, the subtraction math just isn't clicking for me. For example, to perform x-y I immediately thought you would change it to x+(-y). In other words, you would make y negative and then add it to x. Instead, we modify x (negate it bitwise) add it to y, and then negate the answer. I don't see how this set of steps maps to the 2's complement math described in the book.
Reply | Threaded
Open this post in threaded view
|

Re: ALU Worksheet

cadet1620
Administrator
Note: in what follows '~', '&' and '|' are binary operators NOT, AND, and OR. '-', '*' and '+' are arithmetic operators.

First, here's an identity for two's complement numbers that's very useful for proving ALU computations:
    -x = (~x)+1
and a corollary:
    ~x = (-x)-1 = -(x+1)

Here's how x-y works. The ALU computation is zx=0, nx=1, zy=0, ny=0, f=1, no=1, so the ALU computes
    out = ~(~x+y)

Here's the proof that out = x-y:

   out = ~(~x+y)
 = ~(-(x+1)+y)
 = ~(-x-1+y)
 = -(-x-1+y)-1
 = x+1-y-1
out = x-y

--Mark

Reply | Threaded
Open this post in threaded view
|

Re: ALU Worksheet

philliph
Mark, thanks a million for your quick and informative response.  The proof you provided for x-y could not have been clearer.  I never would have arrived at that myself, but it helps me a great deal to see it in action.

If the authors of the book are reading this, please include the following info that Mark gave in the next edition. It would make the steps of the operations MUCH clearer.

First, here's an identity for two's complement numbers that's very useful for proving ALU computations:
    -x = (~x)+1
and a corollary:
    ~x = (-x)-1 = -(x+1)
Reply | Threaded
Open this post in threaded view
|

Re: ALU Worksheet

KitN
In reply to this post by ybakos
Thanks again for sharing this. I just finished my ALU, but some of the operations could still be clearer in my head. This sheet should help!
Reply | Threaded
Open this post in threaded view
|

Re: ALU Worksheet

vegardw
Just want to second this, thanks for sharing, and a general thanks to both you and cadet1620 for the help you provide in the forum :)

As KitN, I also implemented the ALU without using the worksheet. I did it by just following the implementation comments in the stub HDL file in the order they were listed.

Looking at the other postings in this subforum, it seems like I have used the most common implementation (15 parts in total, 6 Mux16, four parts for the zr status)

However, I didn't really get all the nuances in the inner working of the ALU, I just followed the implementation comments and the resulting ALU passed the test. A lightbulb kind of lit up in my head when I read cadet1620's post in this thread about computing x-y. The work sheet will be a good tool in understanding how all the other computations are done in the ALU.

  --Vegard