Previous in Forum: Grounding Problem   Next in Forum: Question About Rectifiers
Close
Close
Close
10 comments
Rate Comments: Nested
Participant

Join Date: Mar 2011
Posts: 4

How Does an ALU Work?

03/16/2011 11:27 PM

The Arithmetic Logic Unit (ALU) in a microprocessor. I'm a non-electrical engineer trying to understand this piece of the puzzle. I'm curious from a hardware perspective how does a processor calculate that 2<4 (00000010 < 00000100). I've found a diagram of the an 11 stage microprocessor, but the detail stops at the ALU component. Any explanations, links, or books would be greatly appreciated. Thanks in advance

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Anonymous Poster #1
#1

Re: How does an ALU work?

03/17/2011 2:51 AM

Try this book 8051 microcontroller -Ayala

Register to Reply
Guru

Join Date: May 2010
Location: Liverpool, NY
Posts: 961
Good Answers: 131
#2

Re: How Does an ALU Work?

03/17/2011 2:23 PM

If I remember correctly from my microcoding days back in college (too many years ago), a comparison like that is done by doing a subtraction (do the appropriate complement of one of the numbers and add), then look at the overflow. If the difference takes you into the negative, you subtracted the larger from the smaller. You can do a test for "equals" by doing an "exclusive or" of the two numbers and testing for the result being zero.

Most of the arithmetic operations are based on basic logic operations (invert, and, or, xor), shift, and addition.

__________________
To get the right answers, first you need to ask the right questions.
Register to Reply
Power-User

Join Date: May 2006
Posts: 142
Good Answers: 3
#4
In reply to #2

Re: How Does an ALU Work?

03/17/2011 10:50 PM

deleted

Register to Reply
Participant

Join Date: Mar 2011
Posts: 4
#5
In reply to #2

Re: How Does an ALU Work?

03/17/2011 11:03 PM

PeterT,

Thanks for the explanation for the </> part. I think I got the addition part understood. What I"m really looking for is a diagram/schematic for the internal ALU. I've found a few sites now that show the inputs output wiring schematic, but I'm really curious about the actual ALU hard wiring. Haven't found any sites showing that level of detail

Register to Reply
Associate
South Africa - Member - Member Shonver

Join Date: Apr 2008
Location: Cape Town, South Africa
Posts: 51
Good Answers: 2
#7
In reply to #5

Re: How Does an ALU Work?

03/18/2011 7:49 AM

This is quite a curious question. Why do you need to know how it works? Years ago electronics courses used to teach this, but today it is not required knowledge, as ALU operations are effectively transparent, due to how code-writing utilities have advanced.

Where/how will you use this knowledge?

__________________
DON'T PANIC
Register to Reply
Guru
Engineering Fields - Electrical Engineering - Hmmm...

Join Date: Jul 2010
Location: Maryland
Posts: 567
Good Answers: 29
#3

Re: How Does an ALU Work?

03/17/2011 6:42 PM

Look up a binary adder on the web. When two or more logical adders are cascaded, one can add multi-bit binary numbers. By using two's complement, one can also subtract. With a little creativity and a fair amount of logic, one can multiply and divide. The whole subject actually a good chunk of the curriculum for a course on microprocessors.

Typical ALU's have binary inputs for the variables and some control inputs to select the arithmetic function. Floating Point Processors are all the more complicated. Note that before 486's and Pentium's, the FPU was a separate chip when used with the 80286 and 80386, the predecessors of today's PC processors.

Wikipedia has some very good info on them as well.

Register to Reply
Guru

Join Date: Aug 2005
Location: Hemel Hempstead, UK
Posts: 5826
Good Answers: 322
#6

Re: How Does an ALU Work?

03/18/2011 6:21 AM

Wikipedia is good for this sort of thing; start here:-

http://en.wikipedia.org/wiki/Adder_(electronics)

__________________
If you spend all your time looking for people and things to complain about: trust me, you will find plenty to complain about.
Register to Reply
Guru
Popular Science - Weaponology - New Member Safety - ESD - New Member Hobbies - Fishing - New Member

Join Date: Sep 2006
Location: Near Frankfurt am Main, Germany. 50.390866N, 8.884827E
Posts: 17996
Good Answers: 200
#8

Re: How Does an ALU Work?

03/18/2011 8:47 AM
__________________
"What others say about you reveals more about them, than it does you." Anon.
Register to Reply
Power-User

Join Date: Oct 2007
Location: S. California, USA
Posts: 279
Good Answers: 12
#9

Re: How Does an ALU Work?

03/18/2011 1:31 PM

An ALU is just a bunch of digital logic gates hardwired to work in parallel to maximize speed. The logic functions that the ALU performs varies by application.

Comparing the values of two numbers such as your 2 & 4 requires a circuit called a digital magnitude comparator. The power point tutorial in the below link should provide the answer that you seek.

ece.gmu.edu/~clorie/Spring10/ECE-301/Lectures/Lecture_11.ppt

Register to Reply
Guru
Popular Science - Weaponology - New Member Fans of Old Computers - PDP 11 - New Member Technical Fields - Architecture - New Member Hobbies - HAM Radio - New Member

Join Date: Oct 2009
Location: Maine, USA
Posts: 2168
Good Answers: 71
#10

Re: How Does an ALU Work?

03/19/2011 9:52 AM

Well to answer the how of the "mechanical" part...it's basically a bunch of relays which are wired to be AND, OR, and XOR gates. Of course today they use transistors/ICs rather than mechanical relays.

When I was in high school I helped a friend of mine build a computer that used only relays, and a few tubes, and did only one task.

__________________
Tom - "Hoping my ship will come in before the dock rots!"
Register to Reply
Register to Reply 10 comments
Copy to Clipboard

Users who posted comments:

Andy Germany (1); Anonymous Poster (1); CONWAYMECH (1); conwaysci (1); Lo_Volt (1); PeterT (1); Randall (1); Shonver (1); Snave (1); Tom_Consulting (1)

Previous in Forum: Grounding Problem   Next in Forum: Question About Rectifiers

Advertisement