Docsity

Analysis of sequential circuits, Exercises of Digital Logic Design and Programming

Toggle sidebar
bg1
A.F. Kana Digital Logic Design. Page 1
Digital Logic Design
Introduction
A digital computer stores data in terms of digits (numbers) and proceeds in discrete steps from one state to the next.
The states of a digital computer typically involve binary digits which may take the form of the presence or absence of
magnetic markers in a storage medium , on-off switches or relays. In digital computers, even letters, words and whole
texts are represented digitally.
Digital Logic is the basis of electronic systems, such as computers and cell phones. Digital Logic is rooted in
binary code, a series of zeroes and ones each having an opposite value. This system facilitates the design of
electronic circuits that convey information, including logic gates. Digital Logic gate functions include and, or
and not. The value system translates input signals into specific output. Digital Logic facilitates computing,
robotics and other electronic applications.
Digital Logic Design is foundational to the fields of electrical engineering and computer engineering. Digital
Logic designers build complex electronic components that use both electrical and computational
characteristics. These characteristics may involve power, current, logical function, protocol and user input.
Digital Logic Design is used to develop hardware, such as circuit boards and microchip processors. This
hardware processes user input, system protocol and other data in computers, navigational systems, cell phones
or other high-tech systems.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Analysis of sequential circuits and more Exercises Digital Logic Design and Programming in PDF only on Docsity!

Digital Logic Design

Introduction

A digital computer stores data in terms of digits (numbers) and proceeds in discrete steps from one state to the next. The states of a digital computer typically involve binary digits which may take the form of the presence or absence of magnetic markers in a storage medium , on-off switches or relays. In digital computers, even letters, words and whole texts are represented digitally.

Digital Logic is the basis of electronic systems, such as computers and cell phones. Digital Logic is rooted in

binary code, a series of zeroes and ones each having an opposite value. This system facilitates the design of

electronic circuits that convey information, including logic gates. Digital Logic gate functions include and, or

and not. The value system translates input signals into specific output. Digital Logic facilitates computing,

robotics and other electronic applications.

Digital Logic Design is foundational to the fields of electrical engineering and computer engineering. Digital

Logic designers build complex electronic components that use both electrical and computational

characteristics. These characteristics may involve power, current, logical function, protocol and user input.

Digital Logic Design is used to develop hardware, such as circuit boards and microchip processors. This

hardware processes user input, system protocol and other data in computers, navigational systems, cell phones

or other high-tech systems.

Data Representation and Number system

Numeric systems

The numeric system we use daily is the decimal system, but this system is not convenient for machines since the information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing the positional calculation which will allow us to express a number in any base where we need it.

Radix number systems

The numeric system we use daily is the decimal system, but this system is not convenient for machines since the information is handled codified in the shape of on or off bits; this way of codifying takes us to the necessity of knowing

the positional calculation which will allow us to express a number in any base where we need it.

A base of a number system or radix defines the range of values that a digit may have.

In the binary system or base 2, there can be only two values for each digit of a number, either a "0" or a "1".

In the octal system or base 8, there can be eight choices for each digit of a number:

In the decimal system or base 10, there are ten different values for each digit of a number:

In the hexadecimal system, we allow 16 values for each digit of a number:

"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", and "F".

Where “A” stands for 10, “B” for 11 and so on.

Conversion among radices

- Convert from Decimal to Any Base

Let’s think about what you do to obtain each digit. As an example, let's start with a decimal number 1234 and convert it

to decimal notation. To extract the last digit, you move the decimal point left by one digit, which means that you divide

the given number by its base 10.

The remainder of 4 is the last digit. To extract the next last digit, you again move the decimal point left by one digit and

see what drops out.

The remainder of 3 is the next last digit. You repeat this process until there is nothing left. Then you stop. In summary, you do the following:

Solution: Quotient Remainder


3315/16 = 207 3 ------+ 207/16 = 12 15 ----+ | 12/16 = 0 12 --+ | | (Stop when the quotient is 0) | | | C F 3 (HEX; Base 16)

(HEX; Base 16) Product Integer Part 0.4 C C C ... -------------------------------- | | | | 0.316 = 4 .8 4 ----+ | | | | | 0.816 = 12 .8 12 ------+ | | | | 0.816 = 12 .8 12 --------+ | | | 0.816 = 12 .8 12 ----------+ | | : ---------------------+ : Thus, 3315.3 (DEC) --> CF3.4CCC... (HEX)

- Convert From Any Base to Decimal

Let's think more carefully what a decimal number means. For example, 1234 means that there are four boxes (digits);

and there are 4 one's in the right-most box (least significant digit), 3 ten's in the next box, 2 hundred's in the next box,

and finally 1 thousand's in the left-most box (most significant digit). The total is 1234:

Original Number: 1 2 3 4 | | | | How Many Tokens: 1 2 3 4 Digit/Token Value: 1000 100 10 1 Value: 1000 + 200 + 30 + 4 = 1234

or simply, 11000 + 2100 + 310 + 41 = 1234

Thus, each digit has a value: 10^^0 =1 for the least significant digit, increasing to 10^^1 =10, 10^^2 =100, 10^^3 =1000, and so forth.

Likewise, the least significant digit in a hexadecimal number has a value of 16^^0 =1 for the least significant digit, increasing to 16^^1 =16 for the next digit, 16^^2 =256 for the next, 16^^3 =4096 for the next, and so forth. Thus, 1234 means that there are four boxes (digits); and there are 4 one's in the right-most box (least significant digit), 3 sixteen's in the next box, 2 256's in the next, and 1 4096's in the left-most box (most significant digit). The total is:

14096 + 2256 + 316 + 41 = 4660

In summary, the conversion from any base to base 10 can be obtained from the formulae

−

=−

1 1 0

n

i m

i

x di b Where b is the base, di the digit at position i, m the number of digit after the decimal point, n the number

of digits of the integer part and X 10 is the obtained number in decimal. This form the basic of the polynomial method of converting numbers from any base to decimal

Example. Convert 234.14 expressed in an octal notation to decimal.

28^2 + 38 1 + 48 0 +18 -1^ + 48 -2^ = 264 +38 +41 +1/8 +4/64 =156.

Example. Convert the hexadecimal number 4B3 to decimal notation. What about the decimal equivalent of the hexadecimal number 4B3.3?

Solution: Original Number: 4 B 3. 3 | | | | How Many Tokens: 4 11 3 3 Digit/Token Value: 256 16 1 0. Value: 1024 +176 + 3 + 0.1875 = 1203.

Example. Convert 234.14 expressed in an octal notation to decimal.

Solution:

Original Number: 2 3 4. 1 4 | | | | | How Many Tokens: 2 3 4 1 4 Digit/Token Value: 64 8 1 0.125 0. Value: 128 + 24 + 4 + 0.125 + 0.0625 = 156.

- Relationship between Binary - Octal and Binary-hexadecimal

As demonstrated by the table bellow, there is a direct correspondence between the binary system and the octal system,

with three binary digits corresponding to one octal digit. Likewise, four binary digits translate directly into one hexadecimal digit.

BIN OCT HEX DEC
1010 12 A 10
1011 13 B 11
1100 14 C 12
1101 15 D 13
1111 17 F 15

With such relationship, In order to convert a binary number to octal, we partition the base 2 number into groups of three starting from the radix point, and pad the outermost groups with 0’s as needed to form triples. Then, we convert each

triple to the octal equivalent.

For conversion from base 2 to base 16, we use groups of four.

Consider converting 10110 2 to base 8:

Notice that the leftmost two bits are padded with a 0 on the left in order to create a full triplet.

48032 (x)

  • 391 (y) becomes the sum: 48032 (x)
  • 99608 (nines' complement of y)
  • 1 (to get the ten's complement) ======= 147641 Dropping the "1" gives the answer: 47641 - Binary example

The method of complements is especially useful in binary (radix 2) since the ones' complement is very easily obtained by inverting each bit (changing '0' to '1' and vice versa). And adding 1 to get the two's complement can be done by simulating a carry into the least significant bit. For example:

01100100 (x, equals decimal 100)

  • 00010110 (y, equals decimal 22)

becomes the sum: 01100100 (x)

  • 11101001 (ones' complement of y)
  • 1 (to get the two's complement) ========== 101001110

Dropping the initial "1" gives the answer: 01001110 (equals decimal 78)

Signed fixed point numbers

Up to this point we have considered only the representation of unsigned fixed point numbers. The situation is quite different in representing signed fixed point numbers. There are four different ways of representing signed numbers that are commonly used: sign-magnitude, one’s complement, two’s complement, and excess notation. We will cover each in turn, using integers for our examples. The Table below shows for a 3-bit number how the various representations appear.

Decimal Unsigned Sign–Mag. 1’s Comp. 2’s Comp. Excess 4

7 111 – – – –

6 110 – – – –

5 101 – – – –

4 100 – – – –

3 011 011 011 011 111

2 010 010 010 010 110

1 001 001 001 001 101

+0 000 000 000 000 100

-0 – 100 111 000 100

-1 – 101 110 111 011

-2 – 110 101 110 010

-3 – 111 100 101 001

-4 – – – 100 000

Table1. 3 bit number representation

- Signed Magnitude Representation

The signed magnitude (also referred to as sign and magnitude) representation is most familiar to us as the base 10 number system. A plus or minus sign to the left of a number indicates whether the number is positive or negative as in +12 10 or − 1210. In the binary signed magnitude representation, the leftmost bit is used for the sign, which takes on a value of 0 or 1 for ‘+’ or ‘−’, respectively. The remaining bits contain the absolute magnitude.

Consider representing (+12) 10 and (−12) 10 in an eight-bit format:

The negative number is formed by simply changing the sign bit in the positive number from 0 to 1. Notice that there are both positive and negative representations for zero: +0= 00000000 and -0= 10000000.

- One’s Complement Representation

The one’s complement operation is trivial to perform: convert all of the 1’s in the number to 0’s, and all of the 0’s to 1’s. See the fourth column in Table1 for examples. We can observe from the table that in the one’s complement representation the leftmost bit is 0 for positive numbers and 1 for negative numbers, as it is for the signed magnitude representation. This negation, changing 1’s to 0’s and changing 0’s to 1’s, is known as complementing the bits. Consider again representing (+12)10 and (−12)10 in an eight-bit format, now using the one’s complement representation:

(+12)10 = (00001100)

Note again that there are representations for both +0 and −0, which are 00000000 and 11111111, respectively. As a result, there are only 2^8 − 1 = 255 different numbers that can be represented even though there are 2^8 different bit patterns.

The one’s complement representation is not commonly used. This is at least partly due to the difficulty in making comparisons when there are two representations for 0. There is also additional complexity involved in adding numbers.

- Two’s Complement Representation

The two’s complement is formed in a way similar to forming the one’s complement: complement all of the bits in the number, but then add 1, and if that addition results in a carry-out from the most significant bit of the number, discard the carry-out.

Examination of the fifth column of Table above shows that in the two’s complement representation, the leftmost bit is again 0 for positive numbers and is 1 for negative numbers. However, this number format does not have the unfortunate characteristic of signed-magnitude and one’s complement representations: it has only one representation for zero. To see that this is true, consider forming the negative of (+0) 10 , which has the bit pattern: (+0) 10 = (00000000) (^2)

Forming the one’s complement of (00000000) 2 produces (11111111) 2 and adding

1 to it yields (00000000) 2 , thus (−0) 10 = (00000000) 2. The carry out of the leftmost position is discarded in two’s complement addition (except when detecting an overflow condition). Since there is only one representation for 0, and since all bit patterns are valid, there are 28 = 256 different numbers that can be represented.

Consider again representing (+12) 10 and (−12) 10 in an eight-bit format, this time using the two’s complement representation. Starting with (+12) 10 =(00001100) (^) 2, complement, or negate the number, producing (11110011) 2.

Floating point representation

Floating point is a numerical representation system in which a string of digits represent a real number. The name floating point refers to the fact that the radix point (decimal point or more commonly in computers, binary point) can be placed anywhere relative to the digits within the string. A fixed point is of the form a × bn^ where a is the fixed point part often referred to as the mantissa, or significand of the number b represents the base and n the exponent. Thus a floating point number can be characterized by a triple of numbers: sign, exponent, and significand.

- Normalization

A potential problem with representing floating point numbers is that the same number can be represented in different ways, which makes comparisons and arithmetic operations difficult. For example, consider the numerically equivalent forms shown below:

3584.1 × 10 0 = 3.5841 × 103 = .35841 × 104.

In order to avoid multiple representations for the same number, floating point numbers are maintained in normalized form. That is, the radix point is shifted to the left or to the right and the exponent is adjusted accordingly until the radix point is to the left of the leftmost nonzero digit. So the rightmost number above is the normalized one. Unfortunately, the number zero cannot be represented in this scheme, so to represent zero an exception is made. The exception to this rule is that zero is represented as all 0’s in the mantissa.

If the mantissa is represented as a binary, that is, base 2, number, and if the normalization condition is that there is a leading “1” in the normalized mantissa, then there is no need to store that “1” and in fact, most floating point formats do not store it. Rather, it is “chopped off ” before packing up the number for storage, and it is restored when unpacking the number into exponent and mantissa. This results in having an additional bit of precision on the right of the number, due to removing the bit on the left. This missing bit is referred to as the hidden bit, also known as a hidden 1.

For example, if the mantissa in a given format is 1.1010 after normalization, then the bit pattern that is stored is 1010— the left-most bit is truncated, or hidden.

Possible floating point format.

In order to choose a possible floating point format for a given computer, the programmer must take into consideration the following:

The number of words used (i.e. the total number of bits used.) The representation of the mantissa (2s complement etc.) The representation of the exponent (biased etc.) The total number of bits devoted for the mantissa and the exponent The location of the mantissa (exponent first or mantissa first)

Because of the five points above, the number of ways in which a floating point number may be represented is legion. Many representation use the format of sign bit to represent a floating point where the leading bit represents the sign Sign Exponent Mantissa

- The IEEE standard for floating point

The IEEE (Institute of Electrical and Electronics Engineers) has produced a standard for floating point format arithmetic

in mini and micro computers.(i.e. ANSI/IEEE 754-1985). This standard specifies how single precision (32 bit) , double

precision (64 bit) and Quadruple (128 bit) floating point numbers are to be represented, as well as how arithmetic should

be carried out on them.

General layout

The three fields in an IEEE 754 float

Sign Exponent Fraction

Binary floating-point numbers are stored in a sign-magnitude form where the most significant bit is the sign bit, exponent is the biased exponent, and "fraction" is the significand without the most significant bit.

Exponent biasing

The exponent is biased by (2 e^ − 1) − 1, where e is the number of bits used for the exponent field (e.g. if e=8, then (2^8 − 1) − 1 = 128 − 1 = 127 ). Biasing is done because exponents have to be signed values in order to be able to represent both tiny and huge values, but two's complement, the usual representation for signed values, would make comparison harder. To solve this, the exponent is biased before being stored by adjusting its value to put it within an unsigned range suitable for comparison.

For example, to represent a number which has exponent of 17 in an exponent field 8 bits wide:

exponentfield = 17 + (2 8 − 1) − 1 = 17 + 128 − 1 = 144.

Single Precision

The IEEE single precision floating point standard representation requires a 32 bit word, which may be represented as

numbered from 0 to 31, left to right. The first bit is the sign bit, S, the next eight bits are the exponent bits, 'E', and the

final 23 bits are the fraction 'F':

S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF

To convert decimal 17.15 to IEEE Single format:

Convert decimal 17 to binary 10001. Convert decimal 0.15 to the repeating binary fraction 0.001001 Combine integer and fraction to obtain binary 10001.001001 Normalize the binary number to obtain 1.0001001001x2 4 Thus, M = m-1 =0001001001 and E = e+127 = 131 = 10000011.

The number is positive, so S=0. Align the values for M, E, and S in the correct fields.

0 10000011 00010010011001100110011

Note that if the exponent does not use all the field allocated to it, there will be leading 0’s while for the mantissa, the zero’s will be filled at the end.

Double Precision

The IEEE double precision floating point standard representation requires a 64 bit word, which may be represented as

numbered from 0 to 63, left to right. The first bit is the sign bit, S, the next eleven bits are the exponent bits, 'E', and the

final 52 bits are the fraction 'F':

S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Decimal Digit 8 4 2 1 8 4 -2 -1 2 4 2 1 Excess- Code code code code 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 0 0 2 0 0 1 0 0 1 1 0 0 0 1 0 0 1 0 1 3 0 0 1 1 0 1 0 1 0 0 1 1 0 1 1 0 4 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1 5 0 1 0 1 1 0 1 1 1 0 1 1 1 0 0 0 6 0 1 1 0 1 0 1 0 1 1 0 0 1 0 0 1 7 0 1 1 1 1 0 0 1 1 1 0 1 1 0 1 0 8 1 0 0 0 1 0 0 0 1 1 1 0 1 0 1 1 9 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0

it is very important to understand the difference between the conversion of a decimal number to binary and the binary coding of a decimal number. In each case, the final result is a series of bits. The bits obtained from conversion are binary digit. Bits obtained from coding are combinations of 1’s and 0’s arranged according to the rule of the code used. e.g. the binary conversion of 13 is 1101; the BCD coding of 13 is 00010011

  • Error-Detection Codes

Binary information may be transmitted through some communication medium, e.g. using wires or wireless media. A corrupted bit will have its value changed from 0 to 1 or vice versa. To be able to detect errors at the receiver end, the sender sends an extra bit (parity bit) with the original binary message.

A parity bit is an extra bit included with the n-bit binary message to make the total number of 1’s in this message (including the parity bit) either odd or even. If the parity bit makes the total number of 1’s an odd (even) number, it is called odd (even) parity. The table shows the required odd ( even ) parity for a 3-bit message

Three-Bit Message Odd Parity Bit Even Parity Bit X Y Z P P 0 0 0 1 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 0 1

No error is detectable if the transmitted message has 2 bits in error since the total number of 1’s will remain even (or odd) as in the original message.

In general, a transmitted message with even number of errors cannot be detected by the parity bit.

  • Gray code

The Gray code consist of 16 4-bit code words to represent the decimal Numbers 0 to 15. For Gray code, successive code words differ by only one bit from one to the next

Gray Code Decimal Equivalent 0 0 0 0 0 0 0 0 1 1 0 0 1 1 2 0 0 1 0 3 0 1 1 0 4 0 1 1 1 5 0 1 0 1 6 0 1 0 0 7 1 1 0 0 8 1 1 0 1 9 1 1 1 1 10 1 1 1 0 11 1 0 1 0 12 1 0 1 1 13 1 0 0 1 14 1 0 0 0 15

Character Representation

Even though many people used to think of computers as "number crunchers", people figured out long ago that it's just as

important to handle character data.

Character data isn't just alphabetic characters, but also numeric characters, punctuation, spaces, etc. Most keys on the central part of the keyboard (except shift, caps lock) are characters. Characters need to represented. In particular, they need to be represented in binary. After all, computers store and manipulate 0's and 1's (and even those 0's and 1's are just abstractions. The implementation is typically voltages).

Unsigned binary and two's complement are used to represent unsigned and signed integer respectively, because they have nice mathematical properties, in particular, you can add and subtract as you'd expect.

However, there aren't such properties for character data, so assigning binary codes for characters is somewhat arbitrary. The most common character representation is ASCII, which stands for American Standard Code for Information Interchange.

There are two reasons to use ASCII. First, we need some way to represent characters as binary numbers (or, equivalently, as bitstring patterns). There's not much choice about this since computers represent everything in binary.

If you've noticed a common theme, it's that we need representation schemes for everything. However, most importantly, we need representations for numbers and characters. Once you have that (and perhaps pointers), you can build up everything you need.

The other reason we use ASCII is because of the letter "S" in ASCII, which stands for "standard". Standards are good because they allow for common formats that everyone can agree on.

Unfortunately, there's also the letter "A", which stands for American. ASCII is clearly biased for the English language character set. Other languages may have their own character set, even though English dominates most of the computing world (at least, programming and software).

Even though character sets don't have mathematical properties, there are some nice aspects about ASCII. In particular, the lowercase letters are contiguous ('a' through 'z' maps to 97 10 through 122 (^) 10). The upper case letters are also contiguous ('A' through 'Z' maps to 65 10 through 9010). Finally, the digits are contiguous ('0' through '9' maps to 48 10 through 5710).

One problem with ASCII is that it's biased to the English language. This generally creates some problems. One common solution is for people in other countries to write programs in ASCII.

Other countries have used different solutions, in particular, using 8 bits to represent their alphabets, giving up to 256 letters, which is plenty for most alphabet based languages (recall you also need to represent digits, punctuation, etc).

However, Asian languages, which are word-based, rather than character-based, often have more words than 8 bits can represent. In particular, 8 bits can only represent 256 words, which is far smaller than the number of words in natural languages.

Thus, a new character set called Unicode is now becoming more prevalent. This is a 16 bit code, which allows for about 65,000 different representations. This is enough to encode the popular Asian languages (Chinese, Korean, Japanese, etc.). It also turns out that ASCII codes are preserved. What does this mean? To convert ASCII to Unicode, take all one byte ASCII codes, and zero-extend them to 16 bits. That should be the Unicode version of the ASCII characters.

The biggest consequence of using Unicode from ASCII is that text files double in size. The second consequence is that endianness begins to matter again. Endianness is the ordering of individually addressable sub-units (words, bytes, or even bits) within a longer data word stored in external memory. The most typical cases are the ordering of bytes within a 16-, 32-, or 64-bit word, where endianness is often simply referred to as byte order. The usual contrast is between most versus least significant byte first, called big-endian and little-endian respectively.

Big-endian places the most significant bit, digit, or byte in the first, or leftmost, position. Little-endian places the most significant bit, digit, or byte in the last, or rightmost, position. Motorola processors employ the big-endian approach, whereas Intel processors take the little-endian approach. Table bellow illustrates how the decimal value 47,572 would be expressed in hexadecimal and binary notation (two octets) and how it would be stored using these two methods.

Table : Endianess

Number Big-Endian Little-Endian

Hexadecimal

B9D4 B9D4 4D9B

Binary

With single bytes, there's no need to worry about endianness. However, you have to consider that with two byte quantities.

While C and C++ still primarily use ASCII, Java has already used Unicode. This means that Java must create a byte type, because char in Java is no longer a single byte. Instead, it's a 2 byte Unicode representation.

Exercise

  1. The state of a 12-bit register is 010110010111. what is its content if it represents : i. Decimal digits in BCD code ii. Decimal digits in excess-3 code

iii. Decimal digits in 8 4-2-1 code iv. Natural binary number

  1. The result of an experiment fall in the range -4 to +6. A scientist wishes to read the result into a computer and then process them. He decides to use a 4-bit binary code to represents each of the possible inputs. Devise a 4-bit binary code of representing numbers in the range of -4 to 6
  2. The (r-1)’s complement of a base-6 numbers is called the 5’s complement. Explain the procedure for obtaining the 5’s complement of base 6 numbers. Obtain the 5’s complement of (3210) (^6)
  3. Design a three bit code to represent each of the six digits of the base 6 number system.
  4. Represent the decimal number –234.125 using the IEEE 32- bit (single) format

Binary Logic

Introduction

Binary logic deals with variables that assume discrete values and with operators that assume logical meaning.

While each logical element or condition must always have a logic value of either "0" or "1", we also need to have ways to combine different logical signals or conditions to provide a logical result.

For example, consider the logical statement: "If I move the switch on the wall up, the light will turn on." At first glance, this seems to be a correct statement. However, if we look at a few other factors, we realize that there's more to it than this. In this example, a more complete statement would be: "If I move the switch on the wall up and the light bulb is good and the power is on, the light will turn on."

If we look at these two statements as logical expressions and use logical terminology, we can reduce the first statement to:

Light = Switch

This means nothing more than that the light will follow the action of the switch, so that when the switch is up/on/true/1 the light will also be on/true/1. Conversely, if the switch is down/off/false/0 the light will also be off/false/0.

Looking at the second version of the statement, we have a slightly more complex expression:

Light = Switch and Bulb and Power

When we deal with logical circuits (as in computers), we not only need to deal with logical functions; we also need some special symbols to denote these functions in a logical diagram. There are three fundamental logical operations, from which all other functions, no matter how complex, can be derived. These functions are named and , or , and not. Each of these has a specific symbol and a clearly-defined behaviour.

AND. The AND operation is represented by a dot(.) or by the absence of an operator. E.g. x.y=z xy=z are all read as x AND y=z. the logical operation AND is interpreted to mean that z=1 if and only if x=1 and y=1 otherwise z=

OR. The operation is represented by a + sign for example, x+y=z is interpreted as x OR y=z meaning that z=1 if x=1 or y=1 or if both x=1 and y=1. If both x and y are 0, then z=

NOT. This operation is represented by a bar or a prime. For example x′= x =z is interpreted as NOT x =z meaning that z

is what x is not

It should be noted that although the AND and the OR operation have some similarity with the multiplication and addition respectively in binary arithmetic , however one should note that an arithmetic variable may consist of many digits. A binary logic variable is always 0 or 1.

e.g. in binary arithmetic, 1+1=10 while in binary logic 1+1=

Basic Gate

The basic building blocks of a computer are called logical gates or just gates. Gates are basic circuits that have at least

one (and usually more) input and exactly one output. Input and output values are the logical values true and false. In computer architecture it is common to use 0 for false and 1 for true. Gates have no memory. The value of the output

depends only on the current value of the inputs. A useful way of describing the relationship between the inputs of gates

  • 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 truth table for an inverter looks like this:

x | y

0 | 1 1 | 0

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

The door is NOT locked = You may enter

In the inverter symbol, the triangle actually denotes only an amplifier, which in digital terms means that it "cleans up" the signal but does not change its logical sense. It is the circle at the output which denotes the logical inversion. The circle could have been placed at the input instead, and the logical meaning would still be the same

Combined gates

Sometimes, it is practical to combine functions of the basic gates into more complex gates, for instance in order to save space in circuit diagrams. In this section, we show some such combined gates together with their truth tables.

  • The nand -gate

The nand -gate is an and -gate with an inverter on the output. So instead of drawing several gates like this:

We draw a single and -gate with a little ring on the output like this:

The nand -gate, like the and -gate can take an arbitrary number of inputs.

The truth table for the nand -gate is like the one for the and -gate, except that all output values have been inverted:

x y | z

0 0 | 1 0 1 | 1 1 0 | 1 1 1 | 0 The truth table clearly shows that the NAND operation is the complement of the AND

  • The nor -gate

The nor -gate is an or -gate with an inverter on the output. So instead of drawing several gates like this:

We draw a single or -gate with a little ring on the output like this:

The nor -gate, like the or -gate can take an arbitrary number of inputs.

The truth table for the nor -gate is like the one for the or -gate, except that all output values have been inverted:

x y | z

0 0 | 1 0 1 | 0 1 0 | 0 1 1 | 0

  • The exclusive-or -gate

The exclusive-or -gate is similar to an or -gate. It can have an arbitrary number of inputs, and its output value is 1 if and

only if exactly one input is 1 (and thus the others 0). Otherwise, the output is 0.

We draw an exclusive-or -gate like this:

The truth table for an exclusive-or -gate with two inputs looks like this: