BT0068

21
Winter 2011 Bachelor of Science in Information Technology (BScIT) – Semester 2/ Diploma in Information Technology (DIT) – Semester 2 BT0068 – Computer Organization and Architecture – 4 Credits (Book ID: B0952) Assignment Set – 1 (60 Marks) Answer all questions 10 x 6 = 60 1. Convert the following binary numbers to decimal: a. 101110 b. 1110101 c. 110110100 Ans. a. 101110 (101110) 2 =1*2 5 +0*2 4 +1*2 3 +1*2 2 +1*2 1 +0*2 0 = (46) 10 b. 1110101 (1110101) 2 =1*2 6 +1*2 5 +1*2 4 +0*2 3 +1*2 2 +0*2 1 +1*2 0 = (117) 10 c. 110110100 (110110100) 2 =1*2 8 +1*2 7 +0*2 6 +1*2 5 +1*2 4 +0*2 3 +1*2 2 +0*2 1 +0*2 0 =(436) 10 2. Explain the various arithmetic microoperations performed in registers. Ans. 2.5 Arithmetic Microoperations A microoperation is an elementary operation performed with the data stored in registers. The microoperations most often encountered in digital computers are classified into four categories:

Transcript of BT0068

Page 1: BT0068

Winter 2011 Bachelor of Science in Information Technology (BScIT) – Semester 2/ Diploma in Information Technology (DIT) – Semester 2 BT0068 – Computer Organization and Architecture – 4 Credits (Book ID: B0952) Assignment Set – 1 (60 Marks) Answer all questions 10 x 6 = 60

1. Convert the following binary numbers to decimal: a. 101110 b. 1110101 c. 110110100

Ans.a. 101110

(101110)2=1*25+0*24+1*23+1*22+1*21+0*20= (46)10

b. 1110101

(1110101)2=1*26+1*25+1*24+0*23+1*22+0*21+1*20= (117)10

c. 110110100

(110110100)2=1*28+1*27+0*26+1*25+1*24+0*23+1*22+0*21+0*20=(436)10

2. Explain the various arithmetic microoperations performed in registers.

Ans.

2.5 Arithmetic Microoperations A microoperation is an elementary operation performed with the data stored in registers. The microoperations most often encountered in digital computers are classified into four categories:

1. Register transfer microoperations transfer binary information from one register to another.

2. Arithmetic microoperations perform arithmetic operations on numeric data stored in registers.

3. Logic microoperations perform bit manipulation operations on non-numeric data stored in registers.

4. Shift microoperations perform shift operations on data stored in registers.

Page 2: BT0068

The register transfer microoperation was introduced in Sec.2.3. This type of microoperation does not change the information content when the binary information moves from the source register to the destination register. The other three types of microoperations change the information content during the transfer. In this section we introduce a set of arithmetic microoperations. In the next two sections we present the logic and shift microoperations.

3. Explain the functional units of a basic computer with a neat diagram.

Ans. computer is an entity that interacts in some or the other way with its external environment. All of its linkages to external environment are classified as peripheral devices or communication lines. In particular, the basic model of a computer is as shown in figure 3.3. It consists of four main components, Central Processing Unit (CPU), Memory, Input / Output and a Bus. Bus can also be a wire or a communication line or in general it can be referred to as a system interconnection.

CPU: This is the computational unit and is the computer's heart. This entity controls the operations of the computer and performs its data processing functions. It is usually referred to as a processor. All the actions of all components are controlled by the control unit of CPU. CPU comprises two units called Arithmetic Logic Unit (ALU), where all the arithmetic and logical operations are performed and the Control Unit (CU) which coordinates with all other units for proper system operation.

Memory: Memory is used to store the instructions, data and the result as well. Memory unit is an integral part of a computer system. The main function of a memory unit is to store the information needed by the system.

Page 3: BT0068

Input/output interface: They are used to move data from the computer and from its external environment. The external environment may be an input or an output device like Printer, displays, keyboard etc.

System interconnection: This constitutes some mechanism that provide for communication among CPU, Memory & I/O. These can be referred to as a system BUS. Traditionally the computer system consists of a single CPU. But some machines like multiprocessing involves the use of multiple CPU‟s and share a single memory.

4. Compare the register organizations of 8085, Z8000 and MC68000.

AnsThe Zilog Z8000 Figure 4.6 depicts the register organization of Z8000 machine. Here only purely internal registers structure is given and memory address registers are not shown.

Page 4: BT0068

Intel 8086 The approach taken by Intel for register organization is different than Z8000 machine and is as shown in Figure 4.7. Figure 4.7: Intel 8086 register organization In this machine every register is a special purpose register. There are some registers that also serve as general purpose registers. The 8086 machine contains four 16-bit data registers that are accessible on a byte or 16-bit basis. It also has four 16-bit pointers and index registers. The data registers

Example: A multiply instruction always uses accumulator. The four pointer registers each with segment offset are also used in a number of operations implicitly. There are also four segment registers. Three of these segment registers are used in a dedicated, implicit way to point to the segment of the current instruction, a segment containing data and a segment containing a stack. This type of structure is useful in branch operations. The dedicated and implicit uses provide for compact encoding at the cost of reduced flexibility. The 8086 also includes an instruction pointer and a set of 1 bit status and control flags.

5. Discuss the different types of Bus organizations.

Ans

system bus consists of a data bus, a memory address bus and a control bus

Data Bus: A bus, which carries a word to or from memory, is called data bus. Its width is equal to the word length of the memory. Also, it provides a means for moving data between the different modules of a system. The data bus usually consists of 8, 16 or 32 separate lines. The number of lines implies the data bus

Page 5: BT0068

Address bus: A bus that is used to carry the address of the data in the memory and its width is equal to the number of bits in the Memory Address Register (MAR) of the memory. Example: If a computer memory has 64K, 32-bit words, then the data bus will be 32-bits wide and the address bus will be 16-bits wide.

Control bus: A bus that is used to control the access carries the control signals between the various units of the computer. The processor has to send commands READ and WRITE to the memory which requires single wire. A START command is necessary for the I/O units. All these signals are carried by the control bus.

6. Write a note on different data types with examples for each. Ans

Data Types The most important general categories of data are: Addresses Numbers Characters Logical data.

Numbers All machine language include numeric data types. Even in non numeric data processing, there is a need of numbers to act as counters, field widths, and so on. The numbers stored in computer are limited. That is there is a limit to the magnitude of numbers that can be represented on a machine. Also the programmer is faced with understanding the consequences of rounding, overflow, and underflow. Three types of numerical data are commonly used in computers. They are: 1. Integer or fixed point 2. Floating point (real numbers) 3. Decimal (Remember BCD; an instruction set may be able to process BCD numbers.)

Integer data type:

For unsigned integers: It is a straight forward, simple binary representation. In an N-bit word the N-bits holds the magnitude of the numbers. For example

00000000 = 0 00000001 = 100101001 = 4110000000 = 128 11111111 = 255

For signed integers: It involves treating the Most Significant Bit (MSB) which is nothing but leftmost bit in a word as a sign bit. That is if the MSB is 1 the number is considered as negative else positive. In an N-bit word, the (N-1) bits holds the magnitude of the numbers. For example

Page 6: BT0068

00000000 = 0 00000001 = 100010010 = 1810010010 = -18

11111111 = -127

Logical Data With logical data, memory can be used most efficiently for this storage. Logical values are also called as Boolean values which are 1 = true, 0 = false.

IBM 370 Data types The IBM S/370 architecture provides the following data types.

Binary integer: Binary integer may be either unsigned or signed. Signed binary integers are stored in 2’s compliment form. Allowable lengths are 16 and 32 bits.

Floating point: Floating point numbers of length 32, 64, and 128 bits are allowed. All use 7-bit exponent field.

Decimal: Arithmetic on packed decimal integers is provided. The length is from 1 to 16 bytes. The rightmost 4 bits of the rightmost byte hold the sign. Hence signed numbers from 1 to 31 decimal digits can be represented.

Binary logical: Operations are defined for data units of length 8, 32, and 64 bits. And variable length logical data of up to 256 bytes.

Character: EBCDIC is used.

VAX Data types The VAX provides an impressive array of data types. It is a byte oriented machine. All data types are in terms of bytes including 16-bit word, 32-bit long word, and the 64-bit quad-word, and even the 128 bit octa-word. The data type of VAX machine provides the following five types of data. Binary integer: Binary integers are usually considered as in 2’s complement form. However they can be considered and operated on unsigned integers. Allowable lengths are 8, 16, 32, 64, and 128 bits.

Floating point: It provides four different types of representations. They are

7. Explain various operations of ALU.

Ans

The ALU is the part of the CPU that actually performs arithmetic and logical operations on data. All of the other elements of the computer system - control unit, registers, memory, I/O - are there mainly to bring data into ALU for it to process and then take the results back out.

The inputs and outputs of ALU are shown in figure 7.1. The inputs to the ALU are the control signals generated by the control unit of CPU, and the registers of the CPU where

Page 7: BT0068

the operands for the manipulation of data are stored. The output is a register called status word or flag register which reflects the result and the registers of the CPU where the result can be stored. Thus data are presented to the ALU in registers, and the results of an operation are also stored in registers. These registers are connected by signal paths to the ALU. ALU does not directly interact with memory or other parts of the system (e.g. I/O modules), it only interacts directly with registers. An ALU like all other electronic components of a computer is based on the use of simple digital devices that store binary digits and perform Boolean logic operations.

The control unit is responsible for moving data to memory or I/O modules. Also, it is the control unit that signals all the operations that happen in the CPU. The operations, functions and implementation of Control Unit will be discussed in the tenth unit. In this unit we will concentrate on the ALU. An important part of the use of logic circuits is for computing various mathematical operations such as addition, multiplication, trigonometric operations, etc. Hence we will be discussing the arithmetic involved in using ALU. First, before discussing the computer arithmetic we must have a way of representing numbers as binary data.

8. Compute the product of 7 by 2 using Booth’s algorithm.

Ans

9. Explain the characteristics of memory system.

Ans

Memory systems are classified according to their key characteristics. The most important are listed below: Location The classification of memory is done according to the location of the memory as: CPU: The CPU requires its own local memory in the form of registers and also the control unit requires local memories which are fast accessible. We have already studied this in detail in our earlier discussions. Internal (main): It is often equated with the main memory. There are other forms of internal memory. We will be discussing the internal memory in the next coming sections of this unit.

External (secondary): It consists of peripheral storage devices like hard disks, magnetic disks, magnetic tapes, CDs etc. Capacity Capacity is one of the important aspects of the memory.

Word size: Word size is the natural unit of organization of memory. The size of the word is typically equal to the number of bits used to represent a number and is equal to the instruction length. But there are many exceptions. Common word lengths are 8, 16 and 32 bits.

Number of words: The addressable unit is the word in many systems. However external memory capacity is generally expressed in terms of bytes.

Page 8: BT0068

Unit of Transfer Unit of transfer for internal memory is equal to the number of data lines into and out of memory module.

Word: For internal memory, unit of transfer is equal to the number of data lines into and out of the memory module. Need not be equal to a word or addressable unit. Block: For external memory, data are often transferred in much larger units than a word, and these are referred to as blocks. Access Method

Sequential: Tape units have sequential access. Data are generally stored in units called "records". Data is accessed sequentially; the records may be passed (or rejected) until the record that is searched for is found. The access time to a certain record is highly variable.

Direct: Individual blocks or records have a unique address based on physical location. A block may contain a group of data. Access is accomplished by direct address to reach general vicinity, plus sequential searching, counting or waiting to reach the final location. Disk units have direct access.

Random: Each addressable location in memory has a unique, physically wired-in addressing mechanism. The time to access a given location is independent of the sequence of prior accesses and constant. Any location can be selected at random and directly addressed and accessed. Main memory and some cache systems are random access. Associative: This is a random-access type of memory that enables one to make a comparison of desired bit locations within a word for a specified match, and to do this for all words simultaneously. Thus, a word is retrieved based on a portion of its contents rather than its address. Some cache memories may employ associative access.

10. Write a note about RAID

Ans

RAID 1. RAID is a set of physical disk drives viewed by the operating system as a single logical drive.

2. Data are distributed across the physical drives of an array.

3. Redundant disk capacity is used to store parity information, which guarantees data recoverability in case of a disk failure.

Optical Memory & Magnetic Tape are other two external memories.

Winter 2011

Page 9: BT0068

Bachelor of Science in Information Technology (BScIT) – Semester 2/ Diploma in Information Technology (DIT) – Semester 2 BT0068 – Computer Organization and Architecture – 4 Credits (Book ID: B0952) Assignment Set – 2 (60 Marks) Answer all questions 10 x 6 = 60

1 Convert the hexadecimal number F3A7C2 to binary and octal.

Ans

Binary

1111001110100111110000100000

Octal

(74723702)8

2. What is Register Transfer Language? Explain.

Ans

Digital modules are best defined by the registers they contain and the operations that are performed on the data stored in them. The operations executed on data stored in registers are called microoperations. A microoperation is an elementary operation performed on the information stored in one or more registers. The result of the operation may replace the previous binary information of a register or may be transferred to another register. Examples of microoperations are shift, count, clear, and load. The internal hardware organization of a digital computer is best defined by specifying: 1. The set of registers it contains and their function. 2. The sequence of microoperations performed on the binary information stored in the registers. 3. The control that initiates the sequence of microoperations.

It is possible to specify the sequence of microoperations in a computer by explaining every operation in words, but this procedure usually involves a lengthy descriptive explanation. It is more convenient to adopt a suitable symbology to describe the sequence of transfers between registers and the various arithmetic and logic microoperations associated with the transform. The use of symbols instead of a narrative explanation provides an organized and concise manner for listing the microoperation sequences in registers and the control functions that initiate them. The symbolic notation used to describe the microoperation transfers among registers is called a register transfer language. The term “register transfer” implies the availability of hardware logic circuits that can perform a stated

Page 10: BT0068

microoperation and transfer the result of the operation to the same or another register. The word “language” is borrowed from programmers, who apply this term to programming languages. A programming language is a procedure for writing symbols to specify a given computational process. Similarly, a natural language such as English is a system for writing symbols and combining them into words and sentences for the purpose of communication between people. A register transfer language is a system for expressing in symbolic form the microoperation sequences among the registers of a digital module. It is a convenient tool for describing the internal organization of digital computers in concise and precise manner. It can also be used to facilitate the design process of digital systems. The register transfer language adopted here is believed to be as simple as possible, so it should not take very long to memorize. We will proceed to define symbols for various types of microoperations, and at the same time, describe associated hardware that can implement the stated microoperations. The symbolic designation introduced in this chapter will be utilized in subsequent chapters to specify the register transfers, the microoperations, and the control functions that describe the internal hardware organization of digital computers.

3. Explain the functions of ALU.

Ans

Arithmetic logic unit (ALU) The ALU is a collection of logic circuits designed to perform arithmetic (addition, subtraction, multiplication, and division) and logical operations (not, and, or, and exclusive-or). It's basically the calculator of the CPU. When an arithmetic or logical operation is required, the values and command are sent to the ALU for processing.

Control Unit: The purpose of control unit is to control the system operations by routing the selected data items to the selected processing hardware at the right time. Control unit acts as nerve centre for the other units.

Instruction decoder: All instructions are stored as binary values. The instruction decoder receives the instruction from memory, interprets the value to see what instruction is to be performed, and tells the ALU and the registers which circuits to energize in order to perform the function.

Registers: The registers are used to store the data, addresses, and flags that are in use, by the CPU.

4. List and explain the various conditional flags of the Intel 8085 microprocessor.

Ans

 Flags: These are nothing but condition codes. The result of ALU operations are related back in the register as flags.

Page 11: BT0068

Intel 8085 CPU organization

The different flag bits supported by the 8085 CPU are:1. Z: It stands for Zero Flag. This bit is set when the result of ALU operation is zero. That is result = zero implies Z=1 and result = non zero implies Z=0.2. S: It stands for Sign Flag. This bit is set when the result of ALU operation is negativeThat is result = negative implies S=1 and result = non negative impliesS=03. P: It stands for Parity Flag. This bit is set when the result of ALU operation results in even parity. That is the result when expressed in binary has even number of ones in it.That is result contains even number of ones implies even parity P=1 and result contains odd number of ones implies odd parity P=04. CY: It stands for Carry Flag. This bit is set when the result of ALU operation results in overflow.That is result contains overflow implies carry flag (CY) =1 and result does not contain overflow implies CY=05. AC: It stands for Auxiliary Carry Flag. This bit is set when the result ofALU operation results in carry between fourth and fifth bit.That is result contains carry from fourth to fifth bit implies AC = 1 and result contains carry from fourth to fifth bit implies AC =04. ALU output: The result of an operation is placed on the bus.5. Instruction register: It is loaded from the memory buffer register (MBR) through the Bus. The instruction is brought into CPU through the address/data buffer and internal CPU bus to the instruction register. Then it is decoded here and executed by the control unit.6. Register Array: It is a collection of registers that are user visible and help to store the operands or result of the operation.The register array contains five 16-bit registers. The B – C, D – E, H – L register, Stack pointer and program register.1. The first three types of registers can be treated as a single 16 bit register each or two 8-bit registers each. That is B, C, D, E, H, L are six registers which are 8-bit long.2. Stack pointer is a 16-bit that points to the location of stack memory. This is used for stack oriented machines.

Page 12: BT0068

3. Program counter is 16 bit that points to the current location of the memory where the instructions are to be written. It is moved to the MAR (address plus address/data buffers) to begin the fetching of the next instruction.Any of these registers may be loaded, 8-bits at a time, from the internal bus or transferred to the address buffer or address/data buffer. Also any of the 16-bit registers can be transferred to the MAR that connects to the external address bus.7. Address/data Buffer: This buffer connects to multiplexed bus lines. Some of the time, this buffer acts as a memory buffer register (MBR) to exchange data with the system bus. At other times it acts as the low order 8-bits of a memory address register (MAR). This multiplexing allows additional pins that are available for control signals to the system bus.8. Address buffer: Used as a high order 8 bits of the MAR.Let us consider an instruction ADD B as an example to study the sequence of actions that takes place.· This instruction causes the contents of register B to be added to the contents of the accumulator.· To execute this instruction, the control unit moves the contents of register B to the temporary register.· The ALU performs the add operation on its inputs.· The result is placed on the internal CPU bus and copied into the accumulator.· The ALU also updates the flags to reflect the results of add.

5. Explain the single bus structure.

Ans

In this type of inter-connection, the three units share a single bus. Hence the information can be transferred only between two units at a time. Here the I/O units use the same memory address space. This simplifies programming of I/O units as no special I/O instructions are needed. This is one of advantages of single bus organization

The transfer of information over a bus cannot be done at a speed comparable to the operating speed of all the devices connected to the bus. Some electromechanical devices such as keyboards and printers are very slow whereas disks and tapes are considerably faster. Main memory and processors operate at electronic speeds. Since all the devices must communicate over the bus, it is necessary to smoothout the differences in timings among all the devices.

6. Define: a) Opcode b) Machine Instruction.

Ans

AOperation Code: Specifies the operation to be performed. The operation is specified by a binary code, known as the operation code, or opcode. A user-defined opcode block must precede the instrument (or other opcode) from which it is used. But it is possible to call the opcode from itself. This allows recursion of any depth that is limited only by available memory. Additionally, there is an experimental feature that allows running the opcode definition at a higher control rate than the kr value specified in the orchestra header.

Page 13: BT0068

B

Elements of a Machine Instruction: Each instruction must contain the information required by the CPU for execution. Elements of a machine Instruction are: Main (or virtual) memory: The memory address must be supplied.

CPU register: CPU contains one or more registers that may be referenced by machine instructions. If only one register exists, reference to it may be implicit. If more than one register exists, then each register is assigned a unique number, and the instruction must contain the number of the desired register.

7. Discuss various number representations in a computer system.

Ans

Computers are built using logic circuits that operate on information represented by two valued electrical signals. We label the two values as 0 and 1; and we define the amount of information represented by such a signal as a bit of information, where bit stands for binary digit. The most natural way to represent a number in a computer system is by a string of bits, called a binary number. A text character can also be represented by a string of bits called a character code. We will first describe binary number representations and arithmetic operations on these numbers, and then describe character representations. Non-negative Integers The easiest numbers to represent are the non-negative integers. To see how this can be done, recall how we represent a number in the decimal system. A number such as 2034 is interpreted as: 2*103 + 0*102 + 3*101 + 4*100 But there is nothing special with the base 10, so we can just as well use base 2. In base 2, each digit value is either 0 or 1, which we can represent, for instance, by false and true, respectively. In fact, we have already hinted at this possibility, since we usually write 0 and 1 instead of false and true. All the normal algorithms for decimal arithmetic have versions for binary arithmetic, except that they are usually simpler.

8. Explain the addition of two floating point numbers with examples.

Ans

Addition is simple. Suppose you want to add two floating point numbers, X and Y.

For sake of argument, assume the exponent in Y is less than or equal to the exponent in X. Let the exponent of Y be y and let the exponent of X be x.

Here's how to add floating point numbers.

1. First, convert the two representations to scientific notation. Thus, we explicitly represent the hidden 1. 

Page 14: BT0068

2. In order to add, we need the exponents of the two numbers to be the same. We do this by rewriting Y. This will result in Y being not normalized, but value is equivalent to the normalized Y.

Add x - y to Y's exponent. Shift the radix point of the mantissa (signficand) Y left by x - y to compensate for the change in exponent. 

3. Add the two mantissas of X and the adjusted Y together. 4. If the sum in the previous step does not have a single bit of value 1, left of the

radix point, then adjust the radix point and exponent until it does. 5. Convert back to the one byte floating point representation.

Example 1

Let's add the following two numbers:

Variable sign exponent fraction

X 0 1001 110

Y 0 0111 000

Here are the steps again:

1. First, convert the two representations to scientific notation. Thus, we explicitly represent the hidden 1.

In normalized scientific notation, X is 1.110 x 22, and Y is 1.000 x 20.

2. In order to add, we need the exponents of the two numbers to be the same. We do this by rewriting Y. This will result in Y being not normalized, but value is equivalent to the normalized Y.

Add x - y to Y's exponent. Shift the radix point of the mantissa (signficand) Y left by x - y to compensate for the change in exponent.

The difference of the exponent is 2. So, add 2 to Y's exponent, and shift the radix point left by 2. This results in 0.0100 x 22. This is still equivalent to the old value of Y. Call this readjusted value, Y'

3. Add the two mantissas of X and the adjusted Y' together.

We add 1.110two to 0.01two. The sum is: 10.0two. The exponent is still the exponent of X, which is 2.

4. If the sum in the previous step does not have a single bit of value 1, left of the radix point, then adjust the radix point and exponent until it does.

In this case, the sum, 10.0two, has two bits left of the radix point. We need to move the radix point left by 1, and increase the exponent by 1 to compensate.

Page 15: BT0068

This results in: 1.000 x 23.

5. Convert back to the one byte floating point representation.

Sum sign exponent fraction

X + Y 0 1010 000

6.

9. Explain the concept of memory interleaving.

Ans

Interleaving is an advanced technique used by high-end motherboards/chipsets to improve memory performance. Memory interleaving increases bandwidth by allowing simultaneous access to more than one chunk of memory. This improves performance because the processor can transfer more information to/from memory in the same amount of time, and helps alleviate the processor-memory bottleneck that is a major limiting factor in overall performance.

10. Explain various replacement algorithms.

Ans

For any set associative mapping a replacement algorithm is needed. The most common algorithms are discussed here. When a new block is to be brought into the cache and all the positions that it may occupy are full, then the cache controller must decide which of the old blocks to overwrite. Because the programs usually stay in localized areas for a reasonable period of time, there is high probability that the blocks that have been referenced recently will be referenced again soon. Therefore when a block is to be overwritten, the block that has not referenced for the longest time is overwritten. This block is called least-recently-used block (LRU), and the technique is called the LRU replacement algorithm. In order to use the LRU algorithm, the cache controller must track the LRU block as computation proceeds. There are several replacement algorithms that require less overhead than LRU method. One method is to remove the oldest block from a full set when

a new block must be brought in. This method is referred to as FIFO. In this technique no updating is needed when hit occurs. However, because the algorithm does not consider the recent patterns of access to blocks in the cache, it is not effective as LRU approach in choosing the best block to remove. There is another method called least frequently used (LFU) that replaces that block in the set which has experienced the fewer references. It is implemented by associating a counter with each slot. Yet another simplest algorithm called random, is to choose a block to be overwritten in random.