Wednesday, March 11, 2009

Logic Design

The Binary System

Binary numbers are used to represent all information in the digital world. They’re similar to our decimal system, which uses the digits 0 to 9, except binary uses only 0 and 1.

Binary is handy because now we can easily use something physical to represent numbers. For instance we could use a laser. When it's on you know it means ‘1’ and when it’s off you know it means ‘0’.

When we write numbers in decimal, it's the position or place of the number that tells us what its real value is. With 246 for example, the 6 at the end is six ones, the 4 in the middle is four tens and the 2 is two hundreds. Each place or position is 10 times greater than the previous position.

The binary number system also uses place to give value, but as we have only 2 numbers to work with each place or position is only 2 times greater than the one before.

In binary code:

  • Decimal number 0 is binary 0
  • Decimal number 1 is binary 1
Binary Arithmetic

Arithmetic in binary is much like arithmetic in other numeral systems. Addition, subtraction, multiplication, and division can be performed on binary numerals.

Addition


The circuit diagram for a binary half adder, which adds two bits together, producing sum and carry bits.

The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:

0 + 0 → 0
0 + 1 → 1
1 + 0 → 1
1 + 1 → 0, carry 1 (since 1 + 1 = 0 + 1 × 10 in binary)

Adding two "1" digits produces a digit "0", while 1 will have to be added to the next column. This is similar to what happens in decimal when certain single-digit numbers are added together; if the result equals or exceeds the value of the radix (10), the digit to the left is incremented:

5 + 5 → 0, carry 1 (since 5 + 5 = 0 + 1 × 10)
7 + 9 → 6, carry 1 (since 7 + 9 = 6 + 1 × 10)

This is known as carrying. When the result of an addition exceeds the value of a digit, the procedure is to "carry" the excess amount divided by the radix (that is, 10/10) to the left, adding it to the next positional value. This is correct since the next position has a weight that is higher by a factor equal to the radix. Carrying works the same way in binary:

    1 1 1 1 1  (carried digits)
0 1 1 0 1
+ 1 0 1 1 1
-------------

Subtraction

Subtraction works in much the same way:

0 − 0 → 0
0 − 1 → 1, borrow 1
1 − 0 → 1
1 − 1 → 0

Subtracting a "1" digit from a "0" digit produces the digit "1", while 1 will have to be subtracted from the next column. This is known as borrowing. The principle is the same as for carrying. When the result of a subtraction is less than 0, the least possible value of a digit, the procedure is to "borrow" the deficit divided by the radix (that is, 10/10) from the left, subtracting it from the next positional value.

* * * * (starred columns are borrowed from)
1 1 0 1 1 1 0
− 1 0 1 1 1
----------------
= 1 0 1 0 1 1 1

Subtracting a positive number is equivalent to adding a negative number of equal absolute value; computers typically use two's complement notation to represent negative values. This notation eliminates the need for a separate "subtract" operation. Using two's complement notation subtraction can be summarized by the following formula:


= 1 0 0 1 0 0

Multiplication

Multiplication in binary is similar to its decimal counterpart. Two numbers A and B can be multiplied by partial products: for each digit in B, the product of that digit in A is calculated and written on a new line, shifted leftward so that its rightmost digit lines up with the digit in B that was used. The sum of all these partial products gives the final result.

Since there are only two digits in binary, there are only two possible outcomes of each partial multiplication:

  • If the digit in B is 0, the partial product is also 0
  • If the digit in B is 1, the partial product is equal to A

For example, the binary numbers 1011 and 1010 are multiplied as follows:

1 0 1 1 (A)
× 1 0 1 0 (B)
---------
0 0 0 0 ← Corresponds to a zero in B
+ 1 0 1 1 ← Corresponds to a one in B
+ 0 0 0 0
+ 1 0 1 1
---------------
= 1 1 0 1 1 1 0

3 Basic Logical Operation

The AND Gate

The AND gate implements the AND function. With the gate shown to the left, both inputs must have logic 1 signals applied to them in order for the output to be a logic 1. With either input at logic 0, the output will be held to logic 0.


The OR Gate

The OR gate is sort of the reverse of the AND gate. The OR function, like its verbal counterpart, allows the output to be true (logic 1) if any one or more of its inputs are true. Verbally, we might say, "If it is raining OR if I turn on the sprinkler, the lawn will be wet." Note that the lawn will still be wet if the sprinkler is on and it is also raining. This is correctly reflected by the basic OR function.


2-input OR gate

The NOT Gate, or Inverter

The inverter is a little different from AND and OR gates in that it always has exactly one input as well as one output. Whatever logical state is applied to the input, the opposite state will appear at the output.

The NOT function, as it is called, is necesasary in many applications and highly useful in others. A practical verbal application might be:

Inverter, or NOT gate
Boolean Algebra

    AND Operations (·)
    0·0 = 0      A·0  = 0
    1·0 = 0 A·1 = A
    0·1 = 0 A·A = A
    1·1 = 1 A·A' = 0
    OR Operations (+)
    0+0 = 0      A+0  = A
    1+0 = 1 A+1 = 1
    0+1 = 1 A+A = A
    1+1 = 1 A+A' = 1
    NOT Operations (')
    0' = 1       A''  = A
    1' = 0
The 2 Input Multiplexer
Two-Input Multiplexer
The multiplexer circuit is typically used to combine two or more
digital signals onto a single line, by placing them there at different
times. Technically, this is known as time-division
multiplexing
.


Demultiplexer
( one output many inputs )
- The opposite of the multiplexer circuit, logically enough, is the
demultiplexer. This circuit takes a single data input and one or
more address inputs, and selects which of multiple outputs will receive
the input signal. The same circuit can also be used as a decoder,
by using the address inputs as a binary number and producing an output
signal on the single output that matches the binary address input. In this
application, the data input line functions as a circuit enabler — if
the circuit is disabled, no output will show activity regardless of the
binary input number.
1-to-2-line decoder/demultiplexer

No comments:

Post a Comment