Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Digital Fundamentals and Computer Architecture, Lecture notes of Computer Architecture and Organization

Digital Fundamentals Digital Fundamentals and Computer Architecture Digital Fundamentals and Computer Architecture

Typology: Lecture notes

2018/2019
On special offer
30 Points
Discount

Limited-time offer


Uploaded on 07/07/2019

prabhu3582
prabhu3582 🇺🇸

4.7

(3)

7 documents

1 / 28

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Pollachi College of Arts and Science
Poosaripatti, Pollachi
CLASS : I B.Sc. - CS & I - SEM
SUBJECT: DIGITAL FUNDAMENTALS AND COMPUTER ARCHITECTURE DATE: 27.07.2018
UNIT I
Number System and Binary Codes
The technique to represent and work with numbers is called number system. Decimal number
system is the most common number system. Other popular number systems include binary
number system, octal number system, hexadecimal number system, etc.
Decimal Number System
Decimal number system is a base 10 number system having 10 digits from 0 to 9. This means
that any numerical quantity can be represented using these 10 digits. Decimal number system is
also a positional value system. This means that the value of digits will depend on its position. Let
us take an example to understand this.
Say we have three numbers 734, 971 and 207. The value of 7 in all three numbers is different−
In 734, value of 7 is 7 hundreds or 700 or 7 × 100 or 7 × 102
In 971, value of 7 is 7 tens or 70 or 7 × 10 or 7 × 101
In 207, value 0f 7 is 7 units or 7 or 7 × 1 or 7 × 100
In digital systems, instructions are given through electric signals; variation is done by varying the
voltage of the signal. Having 10 different voltages to implement decimal number system in
digital equipment is difficult. So, many number systems that are easier to implement digitally
have been developed. Let’s look at them in detail.
Binary Number System
The easiest way to vary instructions through electric signals is two-state system on and off. On
is represented as 1 and off as 0, though 0 is not actually no signal but signal at a lower voltage.
The number system having just these two digits 0 and 1 is called binary number system.
Each binary digit is also called a bit. Binary number system is also positional value system,
where each digit has a value expressed in powers of 2, as displayed here.
In any binary number, the rightmost digit is called least significant bit (LSB) and leftmost digit is
called most significant bit (MSB).
And decimal equivalent of this number is sum of product of each digit with its positional value.
110102 = 1×24 + 1×23 + 0×22 + 1×21 + 0×20
= 16 + 8 + 0 + 2 + 0
= 2610
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
Discount

On special offer

Partial preview of the text

Download Digital Fundamentals and Computer Architecture and more Lecture notes Computer Architecture and Organization in PDF only on Docsity!

Pollachi College of Arts and Science

Poosaripatti, Pollachi

CLASS : I B.Sc. - CS & I - SEM SUBJECT: DIGITAL FUNDAMENTALS AND COMPUTER ARCHITECTURE DATE: 27.07.

UNIT – I

Number System and Binary Codes

The technique to represent and work with numbers is called number system. Decimal number system is the most common number system. Other popular number systems include binary number system, octal number system, hexadecimal number system, etc. Decimal Number System Decimal number system is a base 10 number system having 10 digits from 0 to 9. This means that any numerical quantity can be represented using these 10 digits. Decimal number system is also a positional value system. This means that the value of digits will depend on its position. Let us take an example to understand this. Say we have three numbers – 734, 971 and 207. The value of 7 in all three numbers is different− In 734, value of 7 is 7 hundreds or 700 or 7 × 100 or 7 × 10^2 In 971, value of 7 is 7 tens or 70 or 7 × 10 or 7 × 10^1 In 207, value 0f 7 is 7 units or 7 or 7 × 1 or 7 × 10^0 In digital systems, instructions are given through electric signals; variation is done by varying the voltage of the signal. Having 10 different voltages to implement decimal number system in digital equipment is difficult. So, many number systems that are easier to implement digitally have been developed. Let’s look at them in detail. Binary Number System The easiest way to vary instructions through electric signals is two-state system – on and off. On is represented as 1 and off as 0, though 0 is not actually no signal but signal at a lower voltage. The number system having just these two digits – 0 and 1 – is called binary number system. Each binary digit is also called a bit. Binary number system is also positional value system, where each digit has a value expressed in powers of 2, as displayed here.

In any binary number, the rightmost digit is called least significant bit (LSB) and leftmost digit is called most significant bit (MSB).

And decimal equivalent of this number is sum of product of each digit with its positional value. 110102 = 1×2^4 + 1×2^3 + 0×2^2 + 1×2^1 + 0×2^0 = 16 + 8 + 0 + 2 + 0 = 26 10

Octal Number System Octal number system has eight digits – 0, 1, 2, 3, 4, 5, 6 and 7. Octal number system is also a positional value system with where each digit has its value expressed in powers of 8, as shown here −

Decimal equivalent of any octal number is sum of product of each digit with its positional value. 7268 = 7×8^2 + 2×8^1 + 6×8^0 = 448 + 16 + 6 = 470 10 Hexadecimal Number System Octal number system has 16 symbols – 0 to 9 and A to F where A is equal to 10, B is equal to 11 and so on till F. Hexadecimal number system is also a positional value system with where each digit has its value expressed in powers of 16, as shown here −

Decimal equivalent of any hexadecimal number is sum of product of each digit with its positional value. 27FB 16 = 2×16^3 + 7×16^2 + 15×16^1 + 10×16^0 = 8192 + 1792 + 240 + = 10234 10 Number System Relationship The following table depicts the relationship between decimal, binary, octal and hexadecimal number systems.

HEXA DECIMAL

DECIMAL OCTAL BINARY

Binary to Decimal Convert 1101 2 to decimal. The same method can be used to convert binary number to decimal: = (1x2^3 )+(1x2^2 )+(0x2^1 )+(1x2^0 ) = 8 + 4 +0 + = 13 10 Therefore 1101 2 = 13 10.

Binary to Octal number To convert a binary number to octal number, these steps are followed − Starting from the least significant bit, make groups of three bits. If there is one or two bits less in making the groups, 0s can be added after the most significant bit Convert each group into its equivalent octal number Let’s take an example to understand this.

Binary to Hexadecimal To convert a binary number to hexadecimal number, these steps are followed − Starting from the least significant bit, make groups of four bits. If there are one or two bits less in making the groups, 0s can be added after the most significant bit. Convert each group into its equivalent octal number. Let’s take an example to understand this.

101101101012 = DB5 16

Octal number to binary To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent according to this table.

Octal Digit 0 1 2 3 4 5 6 7

Binary Equivalent 000 001 010 011 100 101 110 111

546738 = 101100110111011 2

Octal to Decimal For example the system radix of octal is 8, since any of the 8 values from 0 to 7 can be written as a single digit.

Convert 126 8 to decimal. Using the values of each column, (which in an octal integer are powers of 8) the octal value 1268 can also be written as: (1x8^2 ) + (2x8^1 ) + (6 x 8^0 ) As (8^2 = 64), (8^1 = 8) and (8^0 =1), this gives a multiplier value for each column. Multiply the digit in each column by the column multiplier value for that column to give: 1x64 = 64 2x8 =16 6x1 = 6 Then simply add these results to give the decimal value. 64 + 16 + 6 = 86 10 Therefore 126 8 = 86 10. Octal to Hexadecimal When converting from octal to hexadecimal, it is often easier to first convert the octal number into binary and then from binary into hexadecimal. For example, to convert 345 octal into hex:

  1. octal to hexadecimal

Octal = 3 4 5

Binary = 011 100 101 = 011100101 binary

Drop any leading zeros or pad with leading zeros to get groups of four binary digits (bits): Binary 011100101 = 1110 0101 Then 2) binary into hexadecimal

Binary = 1110 0101

Hexadecimal = E 5 = E5 hex

Therefore, through a two-step conversion process, octal 345 equals binary 011100101 equals hexadecimal E5. Hexadecimal to Binary Hexadecimal to Binary is a trivial conversion. Each hexadecimal digit can be directly converted to its four bit binary equivalent. For example the hex number FACE 16 can be converted by converting F to 1111, A to 1010, C to 1100 and E to 1110. The binary number is then simply 1111101011001110. FACE 16 = 1111101011001110 2 Hexadecimal to Decimal Convert B2D 16 to decimal. Using the same method to convert hexadecimal to decimal. = (Bx16^2 )+(2x16^1 )+(Dx16^0 ) = (11x16^2 )+(2x16^1 )+(13x16^0 ) = 2816 + 32 + = 2861 10 Therefore B2D 16 = 2861 10. Hexadecimal to Octal When converting from hexadecimal to octal, it is often easier to first convert the hexadecimal number into binary and then from binary into octal. For example, to convert A2DE hex into octal:

  1. hexadecimal number into binary

Hexadecimal = A 2 D E

Binary = 1010 0010 1101 1110 = 1010001011011110 binary

Add leading zeros or remove leading zeros to group into sets of three binary digits. Binary: 1010001011011110 = 001 010 001 011 011 110

Example − Addition

Binary Subtraction Subtraction and Borrow , these two words will be used very frequently for the binary subtraction. There are four rules of binary subtraction.

Example − Subtraction

Binary Multiplication Binary multiplication is similar to decimal multiplication. It is simpler than decimal multiplication because only 0s and 1s are involved. There are four rules of binary multiplication.

Example − Multiplication

Binary Division Binary division is similar to decimal division. It is called as the long division procedure.

Example − Division

Floating Point Representation

1. To convert the floating point into decimal, we have 3 elements in a 32-bit floating point representation: i)Sign ii)Exponent iii) Mantissa Sign bit is the first bit of the binary representation. '1' implies negative number and '0' implies positive number. Example: 11000001110100000000000000000000 This is negative number. Exponent is decided by the next 8 bits of binary representation. 127 is the unique number for 32 bit floating point representation. It is known as bias. It is determined by 2k-^1 - 1 where 'k' is the number of bits in exponent field. There are 2 exponent bits in 8-bit representation and 8 exponent bits in 32-bit representation. Thus bias = 3 for 8 bit conversion (2^2 -^1 - 1 = 4-1 = 3) bias = 127 for 32 bit conversion. (2^8 -^1 - 1 = 128-1 = 127) Example: 01000001110100000000000000000000 10000011 = (131) 2 131 - 127 = 4 Hence the exponent of 2 will be 4 i.e. 2^4 = 16. Mantissa is calculated from the remaining 24 bits of the binary representation. It consists of '1' and a fractional part which is determined by: Example: 01000001110100000000000000000000 The fractional part of mantissa is given by: 1(1/2) + 0(1/4) + 1(1/8) + 0(1/16) +……… = 0. Thus the mantissa will be 1 + 0.625 = 1. The decimal number hence given as: SignExponentMantissa = (-1)(16)(1.625) = - 26

Subtraction by 1’s Complement In subtraction by 1’s complement we subtract two binary numbers using carried by 1’s complement. The steps to be followed in subtraction by 1’s complement are: i) To write down 1’s complement of the subtrahend. ii) To add this with the minuend. iii) If the result of addition has a carryover then it is dropped and an 1 is added in the last bit. iv) If there is no carry over, then 1’s complement of the result of addition is obtained to get the final result and it is negative. Evaluate: (i) 110101 – 100101 Solution: 1’s complement of 10011 is 011010. Hence Minued - 1 1 0 1 0 1

1’s complement of subtrahend - 0 1 1 0 1 0

Carry over - 1 0 0 1 1 1 1

1

0 1 0 0 0 0 The required difference is 10000 (ii) 101011 – 111001 Solution: 1’s complement of 111001 is 000110. Hence Minued - 1 0 1 0 1 1

1’s complement - 0 0 0 1 1 0

1 1 0 0 0 1 Hence the difference is – 1 1 1 0 (iii) 1011.001 – 110. Solution: 1’s complement of 0110.100 is 1001.011 Hence Minued - 1 0 1 1. 0 0 1

1’s complement of subtrahend - 1 0 0 1. 0 1 1

Carry over - 1 0 1 0 0. 1 0 0

1

0 1 0 0. 1 0 1

Hence the required difference is 100.

(iv) 10110.01 – 11010. Solution: 1’s complement of 11010.10 is 00101. 1 0 1 1 0. 0 1

0 0 1 0 1. 0 1

1 1 0 1 1. 1 0 Hence the required difference is – 00100.01 i.e. – 100.

Subtraction by 2’s Complement With the help of subtraction by 2’s complement method we can easily subtract two binary numbers. The operation is carried out by means of the following steps: (i) At first, 2’s complement of the subtrahend is found. (ii) Then it is added to the minuend. (iii) If the final carry over of the sum is 1, it is dropped and the result is positive. (iv) If there is no carry over, the two’s complement of the sum will be the result and it is negative.

The following examples on subtraction by 2’s complement will make the procedure clear: Evaluate: (i) 110110 - 10110 Solution:

The numbers of bits in the subtrahend is 5 while that of minuend is 6. We make the number of bits in the subtrahend equal to that of minuend by taking a `0’ in the sixth place of the subtrahend.

Now, 2’s complement of 010110 is (101101 + 1) i.e.101010. Adding this with the minuend.

1 1 0 1 1 0 Minuend

1 0 1 0 1 0 2’s complement of subtrahend

Carry over 1 1 0 0 0 0 0 Result of addition After dropping the carry over we get the result of subtraction to be 100000. (ii) 10110 – 11010 Solution:

2’s complement of 11010 is (00101 + 1) i.e. 00110. Hence

Minuend - 1 0 1 1 0

2’s complement of subtrahend - 0 0 1 1 0

Result of addition - 1 1 1 0 0 As there is no carry over, the result of subtraction is negative and is obtained by writing the 2’s complement of 11100 i.e.(00011 + 1) or 00100. Hence the difference is – 100.

Now consider the sum of 5 and 8: The sum is 11012 = 13, but this result should be correctly represented as 0001 0011 in BCD notation. Fortunately, there is a simple way to find the correct result. We add 6 ( 01102 ) to the digit sum if it exceeds 9. Let's examine the following cases:

In both cases, by adding six we obtain the correct answer in BCD.

Binary to BCD Conversion

Steps

Step 1 -- Convert the binary number to decimal.

Step 2 -- Convert decimal number to BCD.

Example − convert (11101) 2 to BCD.

Step 1 − Convert to Decimal

Binary Number − 11101 2

Calculating Decimal Equivalent −

Step Binary Number

Decimal Number

Step 1 (^111012) ((1 × 2^4 ) + (1 × 2^3 ) + (1 × 2^2 ) + (0 × 2^1 )

  • (1 × 2^0 )) 10

Step 2 111012 (16 + 8 + 4 + 0 + 1) 10

Step 3 (^111012 )

Binary Number − 11101 2 = Decimal Number − 29 10

Step 2 − Convert to BCD

Decimal Number − 29 10

Calculating BCD Equivalent. Convert each digit into groups of four binary digits equivalent.

Step Decimal Number Conversion

Step 1 (^2910 00102 )

Step 2 (^2910 00101001) BCD

Result

(11101) 2 = (00101001)BCD

BCD to Binary Conversion

Steps

Step 1 -- Convert the BCD number to decimal.

Step 2 -- Convert decimal to binary.

Example − convert (00101001)BCD to Binary.

Step 1 - Convert to BCD

BCD Number − (00101001)BCD

Calculating Decimal Equivalent. Convert each four digit into a group and get decimal equivalent for each group.

Step BCD Number Conversion

Step 1 (00101001)BCD 00102 10012

Step 2 (00101001)BCD 210 910

Step 3 (00101001)BCD 2910

BCD Number − (00101001)BCD = Decimal Number − (^2910)

Step 2 - Convert to Binary

Used long division method for decimal to binary conversion.

Decimal Number − 29 10

BCD to Excess-

Steps

Step 1 -- Convert BCD to decimal.

Step 2 -- Add (3) 10 to this decimal number.

Step 3 -- Convert into binary to get excess-3 code.

Example − convert (1001)BCD to Excess-3.

Step 1 − Convert to decimal

(1001)BCD = 9 10

Step 2 − Add 3 to decimal

(9) 10 + (3) 10 = (12) 10

Step 3 − Convert to Excess-

(12) 10 = (1100) 2

Result

(1001)BCD = (1100)XS-

Excess-3 to BCD Conversion

Steps

Step 1 -- Subtract (0011) 2 from each 4 bit of excess-3 digit to obtain the corresponding BCD code.

Example − convert (10011010)XS-3 to BCD.

Given XS-3 number = 1 0 0 1 1 0 1 0 Subtract (0011) 2 = 1 0 0 1 0 1 1 1


BCD = 0 1 1 0 0 1 1 1 Result

(10011010)XS-3 = (01100111)BCD

Gray Code

It is the non-weighted code and it is not arithmetic codes. That means there are no specific weights assigned to the bit position. It has a very special feature that, only one bit will change each time the decimal number is incremented as shown in fig. As only one bit changes at a time, the gray code is called as a unit distance code. The gray code is a cyclic code. Gray code cannot be used for arithmetic operation.

Application of Gray code Gray code is popularly used in the shaft position encoders. A shaft position encoder produces a code word which represents the angular position of the shaft.

Binary to Gray Code Conversion Binary to gray code conversion is a very simple process. There are several steps to do this types of conversions. Steps given below elaborate on the idea on this type of conversion.

  1. The M.S.B. of the gray code will be exactly equal to the first bit of the given binary number.
  2. Now the second bit of the code will be exclusive-or of the first and second bit of the given binary number, i.e if both the bits are same the result will be 0 and if they are different the result will be 1.
  3. The third bit of gray code will be equal to the exclusive-or of the second and third bit of the given binary number. Thus the Binary to gray code conversion goes on. One example given below can make your idea clear on this type of conversion.

Thus the equivalent gray code is 01101. Now concentrate on the example where the M.S.B. of the binary is 0 so for it will be 0 for the most significant gray bit. Next, the XOR of the first and the second bit is done. The bits are different so the resultant gray bit will be 1. Again move to the next step, XOR of second and third bit is again 1 as they are different. Next, XOR of third and fourth bit is 0 as both the bits are same. Lastly the XOR of fourth and fifth bit is 1 as they are different. That is how the result of binary to gray code conversion of 01001 is done whose equivalent gray code is 01101.

The OR gate gets its name from the fact that it behaves after the fashion of the logical inclusive "or." The output is "true" if either or both of the inputs are "true." If both inputs are "false," then the output is "false."

OR gate

Input 1 Input 2 Output 0 0 0 0 1 1 1 0 1 1 1 1

A logical inverter , sometimes called a NOT gate to differentiate it from other types of electronic inverter devices, has only one input. It reverses the logic state.

Inverter or NOT gate

Input Output 1 0 0 1

The NAND gate operates as an AND gate followed by a NOT gate. It acts in the manner of the logical operation "and" followed by negation. The output is "false" if both inputs are "true." Otherwise, the output is "true."

NAND gate

Input 1 Input 2 Output 0 0 1 0 1 1 1 0 1 1 1 0

The NOR gate is a combination OR gate followed by an inverter. Its output is "true" if both inputs are "false." Otherwise, the output is "false."

NOR gate

Input 1 Input 2 Output 0 0 1 0 1 0 1 0 0 1 1 0 The XOR ( exclusive-OR ) gate acts in the same way as the logical "either/or." The output is "true" if either, but not both, of the inputs are "true." The output is "false" if both inputs are "false" or if both inputs are "true." Another way of looking at this circuit is to observe that the output is 1 if the inputs are different, but 0 if the inputs are the same.

XOR gate

Input 1

Input 2

Output

The XNOR (exclusive-NOR) gate is a combination XOR gate followed by an inverter. Its output is "true" if the inputs are the same, and"false" if the inputs are different.

XNOR gate

Input 1

Input 2

Output

Half Adder

A logic circuit block used for adding two one bit numbers or simply two bits is called as a half adder circuit. This circuit has two inputs which accept the two bits and two outputs, with one producing sum output and other produce carry output. As we discussed above that binary addition is commonly performed by Ex-OR gate, but for the first three rules , it performs the binary addition and when the two inputs are logic 1, it does not develop any carry.