0 Replies - 11081 Views - Last Post: 07 September 2014 - 03:27 PM Rate Topic: -----

#1 NeoTifa   User is offline

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon

Reputation: 4699
  • View blog
  • Posts: 19,578
  • Joined: 24-September 08

Computer Logic and Organization for Beginners pt. 1

Posted 07 September 2014 - 03:27 PM

Computer Logic and Organization for Beginners - Part 1

  • Introduction
  • Binary
  • Logic Gates
  • Boolean Algebra
  • Logic Maps


Hello, and welcome to part 1 of my Computer Logic and Organization series. I suppose you could call this a "N00blets" tutorial, but "beginners" sounds better. Many people often ask to themselves, and sometimes others, "how does a computer work?" Well, I am hoping to show you, from the most basic aspect up. This lesson will be on the most fundamental aspect of computer logic: binary and gates. Be warned, this is a hardware approach to learning the basics of computing, so if you're interesting in electrical an/or computer engineering, or just want to know what sort of wizardry makes the code run, then you are in for a treat (hopefully). I hope you enjoy this tutorial and find it useful in your adventures.

2.) Binary

Everybody knows that computers run on "1's and 0's", but what does it mean? I touched base with it in an earlier tutorial about what binary is and how to convert, so I'll just breeze through and you can peruse through that link for further information. Basically, 1's and 0's represent states of being within the machine, more specifically, on and off, respectively. On means there's current flowing through the gate or circuit or whatever, and off means there isn't any, or at least not enough to pass the engineering required threshold in order to register as being on (which is why it's sometimes seen as hi and low vs on and off). Being as how there are 2 states (on and off), it's only natural that the way computers represent data is in base 2. 0 = 0, 1 = 1, 10 = 2, 11 = 3, and so on (more details in linked tutorials). So how do these 1's and 0's interact with each other and change state? Gates!

3.) Logic Gates

There are 3 fundamental gates: AND, OR, and NOT. Gates take inputs and give an output dependent on the inputs' states. By using billions of combinations of these 3 gates together, you can partake in exotic adventures in Minecraft, write a dissertation in M$ Word (perhaps about said adventure because why not), do your taxes, or whatever your heart desires on computers. Pretty cool, huh? So how do they work? Like this:

AND - All inputs states have to be 1/true/on/high to output as 1/true/on/high
X Y | Z
0 0 | 0
0 1 | 0
1 0 | 0
1 1 | 1
This is of course the simplest case, as you can have 3, 4, 4000000000, etc. inputs, but the gate will only output 0 unless all inputs are 1.
Posted Image

OR - As long as at least 1 input is true, it will output as true
X Y | Z
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 1
Also the most simplest case. If there are a million inputs, and at least one is a 1, the output will be 1.
Posted Image

NOT - This simply takes an input and gives the reverse of it as output
X | Z
0 | 1
1 | 0
Posted Image

Of course, there are other gates that are a combination of these:
Posted Image

And speaking of Minecraft, why not?
Posted Image

4.) Boolean Algebra

This one is kinda tough just starting out. Usually university courses spend like 3 weeks MINIMUM on this, and I'm just breezing through it, so if you want a more in depth look or proofs, Google is your friend. The book I am using for reference is "Logic and Computer Design Fundamentals, 4th ed." by M. Morris Mano and Charles R. Kime. This book was like the Bible to me in my previous courses, and I knew many a professional engineer with the same book (not necessarily same edition) in their reference bookcase in their offices. There's also "Digital Design with RTL Design, VHDL, and Verilog, 2nd ed." by Frank Vahid. Oh, and by the way, this will help you in other courses too, as logic is universal. We used this heavily in my Statistics class last semester.

So you may have noticed by now that those gate pics had what looked like math symbols in them. This is because they can be easily represented like math equations. AND gates are usually denoted by multiplication, such as Z = XY. X AND Y could be thought of as a single term. OR gates can be represented with addition, such as Z = X + Y. X OR Y is usually thought of as 2 separate terms added together. See, just like math. Note: I am skipping over the minterms and maxterms because all they did for me was confuse me, and I pretty much already explained it implicitly in like 3 sentences.

Basic Identities:
  • X + 0 = X ~ If you look at the OR gate, since one is always false (0), the terms' truth depends entirely on X.
  • X + 1 = 1 ~ If you look at the OR gate, no matter what anything OR 1 is always 1, by definition of OR.
  • X * 1 = X ~ The one condition is true always (1) but whether the whole term is true depends on X.
  • X * 0 = 0 ~ Since one condition in the term is false, the whole term is automatically false.
  • X + X = X ~ They can either both be true, or both be false, therefore, whatever X is.
  • X * X = X ~ Same idea.
  • X + X' = 1 ~ Basically, the truth doesn't depend on X at all, so the term is 'cancelled' out.
  • X * X' = 0 ~ As with any AND gate, all inputs have to be true. If X is true, X' is false and vice versa.
  • X'' = X ~ Two negatives make a positive.

Of course, the other basic math identities hold as well:
  • Commutative: X + Y = Y + X as well as XY = YX
  • Associative: X + (Y + Z) = (X + Y) + Z as well as X(YZ) = (XY)Z
  • Distributive: X(Y + Z) = XY + XZ as well as X + YZ = (X + Y)(X + Z)
  • DeMorgan's: (X + Y)' = X'Y' as well as (XY)' = X' + Y'

DeMorgan's can be a little tricky when encountered the first time, especially in Statistics class, so here's a proof for funsies:
Posted Image

The basic rules of algebra apply here like the would any other math. For an example, I'll show you how to find the compliment of a function.
(Logic and Computer Design Fundamentals 4th ed. M. Morris Kano and Charles R. Kime, pg. 47)

F = X'YZ' + X'Y'Z
F' = (X'YZ' + X'Y'Z)'
= (X'YZ')' * (X'Y'Z)' -> DeMorgan's
= (X'' + Y' + Z'') * (X'' + Y'' + Z') -> DeMorgan's
= (X + Y' + Z)(X + Y + Z') -> Identity
= F'

It's totally easier to see on paper because you can use the horizontal bars. :(/>/>

5.) Logic Maps

Maps are a super easy way of churning out equations for your functions. Karnaugh maps, or K-maps, are sooooooooo handy, for up to, like, 4 variables. This, obviously, is easier explained with pictures. The basic idea is you map out the 1's and 0's (and hopefully don't-cares) to simplify the equations for you so you don't have to spend a bunch of time hurting your brain using algebra.

Here's a great representation for a 2 variable K-map:
Posted Image

Here's a 4 variable map:
Posted Image
Posted Image

The basic idea is that the 0's represent NOTs, so you can group them according to which variable is 'true'. This is why you see the dashed lines with A, B, C, and D next to them. You either have a non-optimized function or a truth table, and you just fill in the map with 1's and 0's appropriately. If there is a block or line, that means you can just use that whole line's variable's truth in your equation, because normally you'd have to spell out each 1 in that chart.

So for the example in the first drawing, the 1's have been grouped accordingly. Instead of having to write out ABCD + A'BCD + ABC'D + A'BC'D +... for each 1, we can group them. The vertical left-most row is circled, which is under the column marked CD 00. This correlates to C'D', so there's our first term. Now the second is a little tricky. It's a block of 4 on the left side split between the top and the bottom. If you notice the middle elements not circled are represented by B. This means that this term includes everything but B, meaning B', but is still on the left side, which is not in C, thus making this term B'C'. So far our equation is F = C'D' + B'C'. The third 2-cell block is perfectly within A, B, and C. Therefore, our equation is now F = ABC + B'C' + C'D'. It's easier to do it this way most times then use the distributive property to pull C' out, as it fits into gate logic easier.

So there you have it, a basic crash course on digital logic. Next is circuit stuff. Yay!

part 2

This post has been edited by modi123_1: 09 September 2014 - 06:26 PM

Is This A Good Question/Topic? 3
  • +

Page 1 of 1