Lecture 4 - Computer Architecture
Lecture 4 - Computer Architecture
Contents
• Computer Architecture
• CPU
• Memory Unit
• Computer Bus
• I/O Unit
• CPU Registers
• Instruction Set
• Instruction Format
• Fetch - Decode - Execute Cycle
• Port
• Operating System
• Programming Languages
Computer Architecture
Q.2 What is computer architecture? Explain components of computer
architecture.
Computer Architecture
• Components of computer
• each component performs a specific function
• Components of computer communicate with one another
• Computer architecture Way in which various components of computer are
connected
Components of Computer
Architecture
1- CPU
• CPU Central Processing Unit, Processor
• Considered as brain of computer
• Processes (or manipulates) data according to given instructions and converts it
into useful information
• Components of CPU
Control Unit (CU)
• Acts as a supervisor of computer
• Controls all parts of computer & coordinates all activities of computer
• Fetches instructions & data from memory unit
• Decodes & executes instructions one by one
Arithmetic & Logic Unit (ALU)
• Performs all arithmetic & logical operations on data
Components of Computer
2-
Architecture
Main Memory
• Memory Used to store data and instructions
• CPU loads data & instructions in main memory
• Reads data & instructions from main memory
• Process data according to given instructions
• Data and results of calculations stored in main memory
• Working area of computer (computer cannot work without having main memory)
3- I/O Unit
• Controls communication between processor & peripheral devices (i.e. I/O devices)
• Peripheral devices keyboard, monitor, printer, & disk drives
• Controls different I/O devices connected to computer system
4- Bus Interconnection
• Bus electrical path through which data, instructions, or control signals flow from one component of
computer to another
• Communication channel on motherboard
• Connects different components of computer (such as CPU, main memory, and I/O units)
CPU
Q.3 Explain CPU with its main components.
CPU
• CPU stands for Central Processing Unit
• Considered as brain of computer
• Performs different operations on the data according to given
instructions
• Manages other operations of computer
• CPU of personal computer is also called microprocessor
• It’s a Single chip
• Its located on motherboard
• CPU sends & receives data to/from different components of
computer through Bus interconnection
Components of CPU
1. Control Unit
• Acts as a supervisor of computer
• Controls all parts of computer & coordinates all activities of computer
• Example: receives data & instructions from input device and stores them in main
memory.
• Also controls execution of instructions given to computer
• Fetches instructions & data from memory unit
• Decodes & executes instructions one by one
2. Arithmetic & Logic Unit (ALU)
• Performs arithmetic & logical operations on data
• Arithmetic operations ALU performs addition, subtraction, multiplication, & division
• Logical operations ALU compares numerical data as well as alphabetic data
• For example: checks whether first number is greater than second, less than second or equal to
second, etc.
Memory Unit
Q.4 What is the main memory? Describe its structure. How data is accessed in
main memory?
Memory Unit
• Memory, stores data & instructions
• Personal computer contains a main memory
• CPU loads data & instructions in main memory to process data
• CPU reads data & instructions from main memory & processes data according
to given instructions
• Data & results of calculations are also stored in main memory
• Working area of computer
• computer cannot work without having main memory
• Two types of memories
• RAM
• ROM
RAM
Pros:
Requires no additional hardware
Easy to implement
Cons :
Processor suspends all other processing
Reduces overall performance of computer system
Ways of transferring data from peripheral
devices into computer
2) DMA
• DMA stands for Direct Memory Access
• DMA controller is a special hardware component
• Data transfer takes place without involvement of CPU
• CPU sends request to DMA controller to perform
I/O operation
• CPU continues to do other tasks
• When data transfer completed
• DMA controller sends on interrupt signal to CPU
• CPU involved only at beginning & end of data transfer
Pros
• Processor does not have to wait for completion of I/O operation
• Performance increased
Cons
• More complex & more hardware needed to implement
CPU Registers
Q.16 What are CPU registers? Describe the special-purpose registers.
Q.17 Explain different general-purpose registers (GPR).
Q.18 Explain the purposes of different Segment / Address registers.
CPU Registers
• Registers CPU contains small, high-speed storage locations (areas)
• Used during program execution
• Temporarily hold instructions, data, or intermediate results of calculations
• Different types of registers is used for a specific purpose
• Size of registers 1, 2, 4, or 8 bytes
• Large register increases performance of CPU
• Example: computer having 32-bit (4-bytes) registers CPU can process four bytes of
data at a time
• Types of Registers
• Special-purpose registers
• General-purpose registers
• Segment registers
Special Purpose Registers
• Perform specific functions (special functions) during program execution
1. Program Counter (PC)
• The Program Counter keeps track of the memory address of the next
instruction to be fetched and executed.
• When instruction fetched the value of PC incremented
• Steps:
• The ALU (Arithmetic Logic Unit) carries out arithmetic or logic operations.
• Data may be moved between registers or between the CPU and memory.
• Results of the operation are stored back in registers or memory as needed.
• Any necessary flags or status registers may be updated based on the outcome
of the operation.
Port
Q.22 What is a port? Explain different types of ports.
Port
• Peripheral devices connected to system unit through a special device Port
• Port interface or connecting point
• Provide a standard way of communication between computer and its
peripheral devices
• Example: keyboard, mouse, printer, monitor, & modem connected with computer by
plugging their connectors into ports
• Computer or mobile device different types of ports
• Example: desktop personal computer different ports on its front and back
Types of Port
i) Serial Port
• Transmits one bit at a time
• communication (COM) port
• Slow data transmission
• Data transmission rate 115 Kbps or more
• Serial port mouse, keyboard, and modem are connected
• do not require fast data transmission
• Not used today
Types of Port
ii) Parallel Port
• Transmits many bits at a time
• Faster data transmission than serial port
• Data transmission rate up to 12 Mbps or more
• Parallel port printer and scanner connected
• Line Printer Ports (LPT)
• Not used in modern computers
• Parallel and serial ports replaced with USB ports
Types of Port
iii) USB Port
• USB Universal Serial Bus
• Most popular standard port used in PCs
• Single connector allows up to 127 peripheral devices to be connected
• Examples: keyboard, mouse, printer, scanner, digital camera, speakers, card
reader, smartphone, USB flash drives, & external hard disk
• USB ports in personal computers typically 6 to 8 either on front or back
• Also be used as a power supply for different devices
• such as smartphones & tablets
END
Operating System
Q.23 What is operating system? Name some important operating systems.
Operating System
• A set of system programs that controls & coordinates overall operations of a computer
system (or mobile device)
• Computer needs an operating system to do work
• Computer cannot operate without OS
• Without OS, computer is like a car with no fuel
• OS must be installed on computer to perform different tasks
• When computer is turned on, OS loaded into main memory from disk
• Performs various functions residing in main memory
• Tasks of OS
• Provides user-interface
• Accepts input from input devices
• Sends output to output devices
• Manages the application programs in memory
• Organizes data on storage devices
• Performs memory management tasks
Operating System
• Controls overall hardware to perform various operations
• Provides most common functions needed by users & programmers
• Users & programmers request hardware through OS
• OS provides an interface to users & programmers
• Important Operating Systems
• Microsoft Windows
• UNIX
• Linux
• Mac OS
• Solaris
Functions of Operating System
1. Booting
• OS starts computer and makes it ready to work
• Process of starting or restarting a computer booting
2. Manage Hardware Resources
• Different applications (or programs) try to use various hardware resources at same time
• OS is responsible for allocating & managing various resources for different applications
3. Memory Management
• Data & program must be loaded into main memory for execution
• Different programs & data can be loaded at the same time
• OS manages and allocates memory to different programs
• OS carefully monitors contents of memory
• When program terminates its execution OS de-allocates (clears) memory area and its related data
4. Loading and Executing Programs
• Program loaded into main memory for execution
• OS provides facility for loading program into memory and for starting its execution
Functions of Operating System
5. Data Security
• OS provides facility to protect important data against illegal access and modification (unauthorized
access).
6. Providing User-Interface
• OS provides an interface between user & computer
• User interacts with computer through OS
• User requests computer through OS to perform specific task
• Command-line User Interface
• provides a prompt line on computer screen
• User communicates by typing commands through keyboard
• Difficult interface
• Example: MS-DOS operating system
• Graphical User Interface (GUI)
• provides graphical images on computer screen
• Images icons or command buttons
• Example: application programs, commands, disk drives, files, etc. in form of icons
• User communicates by clicking icons with a pointing device (such as mouse)
• GUI easy to interact
Programming Languages
Q.25 What are programming languages? Explain low-level and high-level
languages.
Programming Languages
• Provides way of communication between user & computer
• Computer program written in programming language
• Various programming languages
• Example:
• programming languages for writing business programs
• programming languages for writing scientific programs
• Syntax set of rules of a specific programming language to write a computer
program
• Program instructions are written according to these rules
• Types of Programming language
• Low-level languages
• High-level languages
Types of Programming Languages
1- Low-Level Languages
• Near to machine language (0s and 1s)
• Difficult to learn and use
• because instructions are written in binary form and symbolic form
• Examples: machine language & assembly language
(i) Machine Language
• Instructions are written in binary form (in form of 1s and 0s)
• Fundamental language of computer
• Computer only understands machine language
• No need to translate
• because; already in machine code i.e. binary form
(ii) Assembly Language
• Easier to learn and use than machine language
• Instructions are written by using short names or symbols mnemonics
• Example: ADD for addition, MUL for multiplication, and SUB for subtraction
Types of Programming Languages
2- High-Level Languages
• Near to human languages
• Easy to learn and use
• Instructions written in English like words print and input etc.
• Language has its own rules or grammar for writing program
• Computer cannot understand program written in any high-level language
• Must be translated to machine code before running on computer
• Language has its own translator program
• Examples: BASIC, FORTRAN, C & C++, Java, Pascal, Visual Basic, and COBOL.
• Source Code
• Program written in any high-level programming language or assembly
language
• Cannot be executed directly by computer
• Must be converted into machine code before running it on computer
Object Code
• Computer understands only machine code
• Source code high-level languages and assembly language code
• Must be translated into machine code before running it on computer
• Translated program into machine code object code
Language Translator
Q.27 What is a language translator? Explain its different types.
Language Translator
• System software that translates source code into machine code (object code)
• language processor
• Every programming language (except machine language) has its own language
translator
• Computer only understands instructions in machine code (i.e. 0’s and 1’s)
• Difficult to write program directly in machine code
• Mostly programs are written in high-level languages
• such as C/C++, Java, and BASIC
• Must be translated into machine code before running on computer
Language Translator
1- Compiler
• Translates source code into machine code (object code) as a whole
• Examples: C and C++ translators
• Compiler analyzes source code & checks errors
• If no error translates source code into object code (machine code)
• If error specifies errors and does not translate
Language Translator
2- Interpreter
• Translates & executes statements of a source code one by one
• Translates one statement & executes it immediately
• before translating next statement
• Process continued up to end of the program
• If error terminates translating process at that statement
• Also displays an error message
• Example: GW-BASIC translator
+ Easier to detect & correct errors in source program
- Time-consuming process
- Does not produce object code
- Each time program run source code translated again
- Must have a Interpreter permanently on our computer
3- Assembler
Compiler Interpreter
• Translates as a whole • Translates statement-by-statement
• Creates an object file • Does not create an object file
• Fast program execution • Slow program execution
• Translated only once • Translated each time to run the
• Not easier to correct errors program
• Easier to correct errors
Primary Memory Secondary Memory
• Temporary memory • Permanent memory
• Use to store during data • Use to store permanently for later
processing use
• Volatile memory • Non-volatile memory
• Smaller storage capacity than • Larger storage capacity than primary
secondary memory memory
• High data accessing speed • Slow data accessing speed
• Directly accessed by CPU • Not directly accessed by CPU