# Digital LogicTutorial

## Basic ALU

So we can add, subtract, negate, and, or, not or any combination of the above. Let's put it all together in an ALU. This is a big one, so I hope there is space on your computers screen. Be sure to click Settings, gate design, US and close the panel of modules on the left by clicking the left pointing triangle at the top of the dividing line. Once you can see the entire circuit, we can walk through the parts:

The inputs are the two digits in one box in the upper left. The first digit is B, the second is A (it just worked out that way). The buttons below the digits control the function that the ALU will perform on those two numbers.

The functions are listed under the circuit. The numbers next to each function represent the settings of the switches. For example, when all the switches are off or 0, the ALU will invert A, invert B and OR those two values together. Notice that this is the same as ANDing A and B then inverting the result. When the top two switches are off and the bottom two are on, the ALU will ignore A, and return B+1. This is handy for incrementing.

Let's walk through the blocks used. Keep in mind these blocks are all just made up of collections of NAND gates wired into modules. Most of them have been explained earlier in this tutorial, so if you don't remember what is inside one of them just go back and review:
- INPUT just passes the lines from the left thru to the right. It defines the inputs that will be available when we use the AUL itself as a block.
- mux4 selects the first 4 inputs or the second 4 inputs to go through to the 4 outputs. Which set is selected is decided by the bottom input. 1 selects the top, 0 selects the bottom.
- buf4en passes the top 4 inputs thru to the output, or just outputs zeros depending on the bottom two inputs. If either of those is 1, the output is all 0.
- noten passes the top 4 inputs thru as is, or inverts them depending on the bottom input. 1 means invert, 0 means pass as is.
- add4 adds the top 4 inputs to the next 4 inputs and adds in the carry input from the bottom. The resulting sum is the top 4 outputs, and the bottom output is the carry out.
- nand4 is really simple: It just NAND's the top 4 inputs with the next 4 inputs and outputs that result. We just crammed those gates into a module block to make room.
- xor. The xor gate (just about the center of the circuit) is one when it's inputs match (both 0 or both 1). It can also be made of NANDS but we needed the space here.
- OUTPUT just passed the outputs on to the display and a couple of LED's. This, like INPUT, also defines the outputs to make the ALU a module block for future use.

Here is a tricky bit: Anything that has a little circle is being inverted. In other words, if you see a circle on an input or output, know that the value is actually the opposite. An input with a circle that looks likes it's getting a 1, is actually getting a 0; getting a 0, is actually getting a 1.

Remember: It's all done with NANDs!

## Next

 file: /Techref/logic/ALU4b.htm, 4KB, , updated: 2017/3/29 20:59, local time: 2018/12/15 13:56, TOP NEW HELP FIND:  35.175.190.77:LOG IN

 ©2018 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?Please DO link to this page! Digg it! / MAKE! /  Digital Logic Tutorial - Basic ALU

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
 Did you find what you needed? "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant" "No. But I'm interested. me at when this page is expanded."

 PICList 2018 contributors: o List host: MIT, Site host massmind.org, Top posters @20181215 RussellMc, Van Horn, David, Sean Breheny, David C Brown, Neil, Isaac M. Bavaresco, Bob Blick, Harold Hallikainen, AB Pearce - UKRI STFC, John Gardner, * Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr.

.