2

Fundamentals of a Computer

images Calculator

images Computer

images Input devices

images Output devices

images Memory and its classification

images Arithmetic Logic Unit (ALU)

images Control unit and CPU

images Input and output ports

images Microcomputer

images Microprocessor

images Microcontroller

images Computer languages

images Machine language program

images Assembly language program

images High-level language program

images Questions

This chapter outlines in brief the various components of a computer and their major functions. In the first half of the chapter we deal with the advantages of a computer over a calculator. The chapter ends with a small note on microcomputers and a detailed discussion of the various computer languages along with their merits and demerits.

images 2.1 CALCULATOR

A calculator is a hand-held equipment using which arithmetic calculations are performed very easily. Block diagram of a calculator is shown in Fig. 2.1.

It will have keypad as an input device. Values needed in a calculation are provided to the calculator using this keypad. There will be an arithmetic unit, which is responsible for performing the needed calculations. It is a semiconductor chip, which performs the calculations at electronic speeds. Typically it can perform an addition operation in a microsecond.

images

Fig. 2.1 Block diagram of a calculator

In an arithmetic operation, say addition, the two inputs are entered using the keypad. The first value that is input goes to the accumulator. The accumulator in turn, provides one input to the arithmetic unit. Next the user inputs the operation to be performed by the arithmetic unit (e.g. ‘+’). Finally, the user inputs the second value to the arithmetic unit using the keypad. Then the arithmetic unit performs the add operation, under the control of the control unit, and displays the result on the LCD panel in about a microsecond after the completion of the operation.

It takes the user about 3 seconds to get this result on the calculator assuming 1 second is needed for inputting each of the values to be added, and 1 second is needed for inputing the operation to be performed. However, the arithmetic unit utilized only about a microsecond for performing the calculation. Thus a calculator becomes slow in the hands as one cannot input values to the calculator at electronic speeds! This problem is overcome in a computer.

images 2.2 COMPUTER

A computer is generally a desktop equipment, using which arithmetic calculations are performed at a tremendous speed. Nowadays laptop computers as well as hand-held computers have emerged. The blocks that make up a computer are shown in Fig. 2.2.

2.2.1 INPUT DEVICES

The input devices are used for supplying program and data to the memory. In other words, the computer system reads the program and the data from the input devices. Most common input devices are the keyboard and mouse.

2.2.2 OUTPUT DEVICES

Output devices are used for displaying or recording the results computed by the computer. Most common output devices are the CRT display, printer, and plotter.

images

Fig. 2.2 Blocks of a Von Neumann computer

2.2.3 MEMORY AND ITS CLASSIFICATION

Compared to a calculator, the memory unit is an extra block. In the memory the entire set of operations that are to be performed is written using the keyboard as a sequence of instructions. This sequence of instructions is called program. Also, the data on which the program is to operate is entered using the keyboard, and can be stored in memory. Memory can also be used for storing intermediate and final results. This design of a stored program computer where program, data, and result reside in memory is due to Von Neumann.

Memory can be classified into main memory and secondary memory. Secondary memory is also frequently termed as auxiliary memory. Main memory has the drawback of high-cost and low-capacity storage. But its advantage is the high speed of data transfer. The control unit can directly communicate with the main memory but not with the secondary memory. Main memory can be broadly classified into random access memory (RAM) and read only memory (ROM).

Random access memory (RAM): RAM consists of a number of memory locations where in each location typically 8bits are stored. (A bit is a binary digit. Thus it can have only one of the two values 0 or 1.) It is possible to read from a RAM location, as well as write to a RAM location. The disadvantage of RAM is that it is volatile. What it means is that, the moment power supply to the RAM is switched off, the information in the RAM will be lost.

Sequential Access: There are two types of accessing information. They are sequential access and random access. In sequential access it is necessary to access information strictly in an order. If there are 100 memory locations, it has to be accessed in the order of 1, 2, 3, … 100. Thus, it takes least time to access information from location 0 and maximum time to access information from location 100. An example device that employs sequential access is the magnetic tape.

Random Access: In random access technique, it is possible to access a memory location in any order. For example, one can read from the 100 locations in the order of 45, 34, 67, 28, 57, and so on. Second, it takes the same time to read from a memory location irrespective of its position. In a RAM, the method of access is random, and its name in fact is derived based on the method of access.

Read only memory (ROM): ROM also consists of a number of memory locations where in each location typically 8bits are stored. A ROM also uses random access technique just like a RAM. The advantage of ROM is that it is nonvolatile. What it means is that, even if the power supply to the ROM is switched off, the information in the ROM will not be lost. However, it is only possible to read from a ROM location. Thus, in a computer ROM is used for storing information that should not be lost when power is switched off. But first of all how to store information in a ROM? To answer this question, semiconductor manufacturers provide several versions of ROM whose characteristics are briefly discussed in the following.

Mask-programmed ROM: It derives this name because the information is written to this type of ROM at the time of manufacture using a suitable mask. Once the manufacturer writes this type of ROM, it is not possible to change this information even by the manufacturer. The information entered is permanent. It is cheap compared to the other types of ROMs, when cost per unit quantity is considered. But the user has to place an order for a large number at a time. Thus, ROMs are used in equipments that are produced in large quantities. To give an analogy, mask-programmed ROMs are similar to books that are printed in large volumes.

PROM: It stands for ‘programmable read only memory’. The user writes information to this type of ROM using PROM programmer equipment. Once the user writes this type of ROM, it is not possible to change this information anymore. The information entered is permanent. Although it is costlier compared to a mask ROM, it is cheap compared to the other types of ROMs discussed successively in this chapter. The advantage is that the user is free to buy even a single piece of PROM from a local shop. Thus, PROMs are used in equipment that are produced in small quantities. To extend the analogy PROMs are similar to blank notebooks that are written by a user making use of an ink pen.

EPROM: It stands for ‘erasable programmable read only memory’. Information is written to this type of ROM by the user using a EPROM programmer equipment. After the user writes this type of ROM, it is possible to change this information a number of times. Thus, although the information entered is not lost when power is switched off, it is possible to erase it and then write new information. Erasing of the EPROM is done by exposure of strong ultraviolet (UV) light from a very close distance on the quartz window of the EPROM chip. Then the contents of the entire EPROM are lost. For this purpose UV light eraser equipment are available. Although it is costlier compared to a mask ROM or a PROM, it is very popular. The user is free to buy even a single piece of EPROM from a local shop. Thus, EPROMs are used during the development phase of the equipment. They are also frequently used in equipments that are produced in small quantities. To extend the analogy writing to an EPROM is similar to writing on sand using a stick. If a strong breeze comes everything is erased!

images

EEPROM or EAPROM: It stands for ‘electrically erasable (or alterable) programmable read only memory’. Information is written to this type of ROM by the user using a EPROM programmer equipment. After the user writes this type of ROM, it is possible to change this information a number of times. Thus although the information entered is not lost when power is switched off, it is possible to erase it and then write new information. However, erasing of the EEPROM is done by electrical signals. Then the contents of the EEPROM can be selectively erased. It is costlier compared to the other types of ROMs, and is gaining in popularity. The user is free to buy even a single piece of EEPROM from a local shop. Thus EEPROMs are used during the development phase of the equipment. They are also frequently used in equipments that are produced in small quantities. To extend the analogy EEPROMs are similar to blank notebooks that are written by a user making use of a soft pencil. The information can be selectively rubbed out and new information can be written.

If an EPROM or an EEPROM can be used for reading as well as writing information, and is also nonvolatile, what is the use of RAM? The problem with any type of ROM is that although reading from the ROM is fast, the writing (if permitted) is very slow, and the erasing (if permitted) is extremely slow. Also the writing of the EPROM is not possible when the program is in execution. To give an example, some typical EPROM chips allow reading from a memory location in less than a microsecond, write to a memory location in about 50ms, and is erased in about 30 minutes.

Secondary memory: Sometimes there is a need to have more amount of information than is possible to store in a main memory. In such cases it is stored in the secondary memory. This type of memory is characterized by virtues of large capacity for storage and low cost per bit of storage. But its disadvantage is its very low speed for access. The control unit does not directly access secondary storage. Typical examples for secondary memory are the hard disk, floppy disk, and magnetic tape.

2.2.4 ARITHMETIC LOGIC UNIT (ALU)

In a computer, there is an ALU, which is capable of performing logical operations (like AND, OR, Ex-OR, Invert) in addition to the arithmetic operations. The control unit supplies the data required by the ALU from memory, or from input devices, and directs the ALU to perform a specific operation based on the instruction fetched from the memory. ALU is the ‘calculator’ portion of the computer.

2.2.5 CONTROL UNIT AND CPU

The control unit fetches one instruction at a time from the main memory, and then executes it. In this execution, it makes use of the ALU, if the instruction execution involves an arithmetic or logical operation (like AND, OR, Ex-OR). This fetching and execution is done at electronic speeds, say in less than a microsecond. Then the control unit fetches and executes the next instruction from the memory, and so on, till the program is completed and the result is output using the output device. In many computers, the control unit and the ALU are integrated into a single block, and this single block is termed as the central processing unit (CPU).

The point to be noted here is that the control unit is fetching the instructions from the main memory at electronic speeds, rather than from a human being through a keypad at terribly low speeds. In a calculator we may indicate an operation to be performed by the arithmetic unit in 1 second. In a computer, the control unit fetches and executes more than 1 million instructions at the same time. This is what makes the computer much faster than a calculator. Is a calculator obsolete in view of the above virtues of the computer? It is not. The reason is simple. If it is required to find the roots of a given quadratic equation one needs only about 1minute when using a calculator. But using a computer it may take as much as a few hours to develop an error-free program for this problem. It depends on the ability of the programmer. Once the program is developed it takes only a few microseconds to execute the program to obtain the roots of the quadratic equation. Thus a calculator is the choice if the calculation is required to be done only once. A computer is the choice if the calculations are required to be done a number of times with different sets of data.

2.2.6 INPUT AND OUTPUT PORTS

CPU and the main memory are very fast compared to electromechanical input or output devices like printers, etc. In such a case it is essential that the data lines of the computer is not kept engaged for a long time during communication with input/output (I/O) devices. Otherwise the overall speed of the computer system comes down drastically. So I/O devices are connected to a computer through I/O ports.

For example, to communicate with a printer, the CPU loads the output port connected to the printer at electronic speeds. This is slowly printed by the printer. When the printer has finished printing, the output port requests the CPU for further data. This way, the CPU is allowed to work at its full speed with no degradation in the overall speed of the computer system.

images 2.3 MICROCOMPUTER

A microcomputer is a small sized, inexpensive, and limited capability computer. It has the same blocks that are present in a computer. Present-day microcomputers are very small in size. They are of the size of a notebook. In the days to come they are bound to become still smaller. They are very cheap so that many individuals can possess them as their personal computers. Because of mass production they are becoming still cheaper. Many early microcomputers were not very powerful. For example, they did not have even a simple multiply instruction in their instruction set. Also, they could work only on unsigned integer data. But present-day microcomputers have not only multiply and divide instructions on unsigned and signed numbers, but are also capable of performing floating point arithmetic operations. In fact they are more powerful than the mini computers and main computers of yesteryear.

2.3.1 MICROPROCESSOR

Microprocessor is the CPU part of a microcomputer, and is available as a single integrated circuit. Thus a microprocessor will have the control unit and the ALU of a microcomputer. An example is Intel 8085 microprocessor. In addition to the microprocessor, a microcomputer will have the following:

  • – ROM/PROM/EPROM/EEPROM for storing program;
  • – RAM for storing data, intermediate results, and final results;
  • – I/O devices for communication with the outside world;
  • – I/O ports for communication with the I/O devices.

Microprocessors are extensively used in the present-day world. Before the advent of the microprocessor, logic design was done by hardware using gates, flip flops, etc. A mini computer was too expensive to think of. With the advent of the microprocessor, logic design using hardware is mostly replaced by design using a microprocessor. This provides ‘flexible’ instrumentation where just by changing the software it is possible to change the characteristics of the system. Also, new generations of applications have surfaced, which were not thought of earlier because of the prohibitive cost of a mini computer or the complexity of logic design using hardware. A few of the applications using microprocessors are listed below.

  • – Business applications such as desk-top publishing;
  • – Industrial applications such as power plant control;
  • – Measuring instruments such as multi meter;
  • – Household equipments such as washing machine;
  • – Medical equipments such as blood pressure monitor;
  • – Defence equipments such as light combat aircraft;
  • – Computers such as personal computer.

2.3.2 MICROCONTROLLER

It is possible to integrate on a single chip all of the blocks that are needed in a microcomputer, except the I/O devices. Such a chip is termed a microcontroller. An example is Intel 8751. A few of the blocks on the 8751 are:

  • – 4K × 8 bits of EPROM;
  • – 128 × 8 bits of RAM;
  • – 4 numbers of 8 bit I/O ports.

It also has timers and facility for serial communication. Microcontrollers are used in a variety of instruments like washing machines, printer sharer, computer keyboards, etc. They are basically used in equipment where the size and cost are required to be very small compared to a microcomputer, and where lots of complex calculations are not needed.

images 2.4 COMPUTER LANGUAGES

In this section we describe the evolution of computer languages starting from the machine language to the high-level languages. Their merits and demerits are discussed at length.

2.4.1 MACHINE LANGUAGE PROGRAM

A program can be written using only 0s and 1s. The data can also be specified using only 0s and 1s. Such a program is called machine language program. Machine language was the first in the evolution of computer programming languages. Computer directly understands a program written in the machine language. In fact, even to this day, basically computers understand only the 0s and 1s.

Disadvantages of machine language program: Writing a program in machine language has the following drawbacks.

  • It is very tiresome to work with and highly error prone. While writing the program, a 1 and 0 can get interchanged due to typographical error. But then it is very difficult to locate it for correction.
  • By a glance through the program, it is very difficult to visualize the function of the program. In fact, it is very difficult to make out whether a particular bit sequence is an instruction in the program, or a data value, or the output result. This is because data, result, and an instruction are represented using 0s and 1s in machine language.
  • The same program does not work on another computer by a different manufacturer. This is because machine language is different for different computers. For example, on one computer the bit sequence 10100110 may mean ‘add two numbers’, and may mean ‘subtract two numbers’ on another computer. In other words, a program written in machine language is said to be ‘not portable’.
  • To write a program in machine language one must be highly conversant with the organization and architecture of the computer system being used.

Advantages of machine language program: The only advantages of writing in machine language are:

  • Machine language program is executed faster than a program written in a high-level language (high-level language is discussed a little later).
  • A translator like compiler is not needed and so results in a cheaper computer system.

To conclude, machine language is rarely used nowadays, except where very high-speed execution is required. It is also used in cheap microcomputer systems.

2.4.2 ASSEMBLY LANGUAGE PROGRAM

The next development in the evolution of computer languages was the assembly language. Assembly language uses mnemonics in place of a sequence of 0s and 1s. For example, to add register A and B in a particular computer, assembly language uses the mnemonic ‘ADD B’ in place of 10000000. Also, assembly language uses symbolic names to denote addresses and data. A number of such examples are dealt with in the successive chapters. Thus writing a program in assembly language has advantages over writing the same in a machine language.

Disadvantages of assembly language program: However, the disadvantages of writing in assembly language are:

  • The same program does not work on another computer by a different manufacturer. This is because assembly language is different for different computers. For example, on one computer the mnemonic ‘ADD E’ may mean ‘add contents of A register and E register’, and may have no meaning at all on another computer. In other words, a program written in assembly language is also not portable.
  • To write a program in assembly language one must be highly conversant with the organization and architecture of the computer system being used.
  • An assembler, which is a translator program, is needed for translating the assembly language program into machine code. But each assembly language instruction is translated into only one instruction in the machine language. As such the assembler program is not a very huge one, and so is quite cheap.

Advantages of assembly language program: The advantages of writing in assembly language are:

  • It is less tiresome to work with and much less error prone. While writing the program, if a typographical error occurred due to oversight, it is much easier to locate it for correction. In most cases, the assembler program detects it.
  • By a glance through the program it is much easier to visualize the function of the program.
  • As far as speed of execution is concerned machine language and assembly language have equal speed of execution. Thus assembly language program is also executed faster than a program written in a high-level language (high-level language is discussed next).

To conclude, assembly language is rarely used nowadays except where very high-speed execution is required. However, it is widely used in microcomputer systems. Both machine language and assembly language are termed as low-level languages.

2.4.3 HIGH-LEVEL LANGUAGE PROGRAM

The next development in the evolution of computer languages is the high-level language. Some examples for high-level languages are as follows:

  • BASIC (for ‘Beginners All Purpose Symbolic Instruction Code’);
  • FORTRAN (for ‘Formula Translation’);
  • COBOL (for ‘COmmon Business Oriented Language’);
  • Pascal (named after the French scientist Blaise Pascal).

High-level languages use English-like language, but with less words and fewer ambiguities. For example, in English the word ‘can’ can have different meanings based on the context. It is possible to use it as a noun or a verb in a sentence. But high-level languages use only a few words, with each word having a unique meaning.

Disadvantages of high-level languages: However, the disadvantages of writing in high-level languages are:

  • A compiler, which is a translator program, is needed for translating the high-level language program into machine code. But each high-level language instruction is translated into more than one instruction in the machine language. As such the compiler program is a huge one and so is quite expensive.
  • The code generated by the compiler might not be as compact as written straightaway in low-level language. Thus a program written in high-level language usually takes longer to execute.

Advantages of high-level languages: But writing a program in a high-level language has the following advantages over writing the same in a low-level language.

  • It is very easy to learn a high-level language and is a pleasure to work with. While writing the program, if a typographical error occurred due to oversight, it is much easier to locate it for correction. Most of the times the compiler detects it.
  • By a glance through the program it is easy to visualize the function of the program.
  • The programmer is not required to be familiar with the organization or the architecture of the computer system being used. Thus even school children can work with high-level languages.
  • The same program works on any other computer, provided the other computer has a compiler for the language in which the program is written. In other words the programs written in high-level languages are portable.
  • Productivity is enormously increased.

To conclude, high-level languages are almost always used nowadays except where very high-speed execution is required.

QUESTIONS

  1. What is the difference between a calculator and a computer? What makes a computer faster than a calculator?
  2. Briefly explain the blocks that constitute a stored program computer.
  3. Name a few input and output devices and their role in a computer.
  4. Explain the terms ‘random access’ and ‘sequential access’. Identify the type of access in the following:
    1. RAM,
    2. EPROM,
    3. ROM,
    4. Magnetic tape.
  5. Distinguish between main memory and secondary memory. Identify the memory type for the following:
    1. Magnetic disk,
    2. RAM,
    3. Magnetic tape,
    4. EEPROM.
  6. Describe the features of various types of ROMs.
  7. Describe the role of ALU and control unit in a computer.
  8. What is the need for input ports and output ports?
  9. Differentiate microprocessor, microcontroller, and microcomputer.
  10. Give an overview of the evolution of computer languages, highlighting the merits and demerits of each type of language.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.68.81