Course Notes
Course Notes
97.461
Maitham Shams
Department of Electronics
Carleton University
History of Computation
• Mechanical Age: B.C. to 1800s
– 500 B.C. Babylonians invented abacus, first mechanical
calculator
– 1642 Blaise Pascal invented calculator using wheels and
gears
– 1823 Charles Babbage created Analytical Engine capable of
storing data using punch cards
Memory
Microprocessor I/O System
Systems
08E30
COMMAND.COM
08490
Device Drivers such as MOUSE.SYS
02530
MSDOS Programs
01160
IO.SYS Program
00700
DOS communications area
00500
BIOS communications area
00400
Interrupt Vectors
00000
• Programs that control computer system (Operating
Systems)
• Also contains data, drivers, and application programs
• Consists of RAM, ROM, EEPROM, and Flash Memory
• DOS controls memory organization and some I/O
devices
• Interrupt Vectors contain addresses of interrupt service
procedures
• BIOS (Basic I/O system) area controls I/O devices
• IO program allows use of keyboard, video display,
printer, etc.
• Command program controls operation of computer
through keyboard
• System Area
FFFFF
MSDOS Program
F0000
BASIC language ROM (earlier PCs)
E0000
Free Area
COM1
03F8
• I/O Space Floppy Disk Controller
03F0
– Addresses I/O ports CGA Adapter
03D0
– Up to 64K 8-bit devices LPT1
0378
Hard disk Controller
0320
COM2
02F8
8255 (PIA)
0060
Timer (8253)
0040
Interrupt controller
0020
DMA Controller
0000
Microprocessor
• Data transfer between itself and memory or I/O
system
– Using data, address, and control buses
• Simple arithmetic and logic operations
– Add, Sub, Mul, Div, AND, OR, NOT, NEG, Shift, Rotate
– Data width: byte (8-bit), word (16-bit), and double
word (32-bit)
• Program flow via simple decisions
– Zero, Sign, Carry, Parity, Overflow
• Why is it so important?
Computer System Block Diagram
Address Bus
Data Bus
µP
MWTC
MRDC
IOWC
IORC
Read-only Read/Write
Memory memory Keyboard Printer
ROM RAM
• Bus is a common group of wires for
interconnection
• Address Bus: 16-bit for I/O and 20 to 36-bit for
memory
• Data Bus: 8 to 64-bit, the wider the bus, the more
data can be transferred
• Control Bs: contains lines that selects the
memory or I/O to perform a read or write
operation
– Four main control lines
– MRDC‘ (memory read control)
– MWTC’ (memory write control)
– IORC’ (I/O read control)
– IOWC’ (I/O write control)
Intel Microprocessor Architecture
• Operation Modes
– Real: uses 1st M byte of memory in all versions
– Protected: uses all parts of memory in 80286 and
above
• Register Types
– Program Visible: used during application programs
– Program Invisible: not directly addressable, but used
by system
• Program Visible Registers
– 4 Data Registers, 4 Pointer/Index Registers, 4-6
Segment Registers, Instruction Pointer, and Flags
• Compatibility is a successful strategy
– Register A may be used as 8-bit (AH and AL), 16-bit
(AX), and 32-bit (EAX) fir the later Pentium processors
– e.g. ADD AL, AH; ADD DX, CX; ADD ECX, EBX
– Instructions only affect the intended part of a register
– Later µP versions support earlier version codes
Opcode
• First byte of instruction: opcode
– First 6 bits of instruction are the binary opcode
– Direction bit (D) determines the direction of data flow
– Width bit (W) determines data size: 0 for byte, 1 for
word and double word
• Second byte of instruction: MOD-REG-R/M
MOD REG R/M
– Answer: 4.5
Magnetic Disks
• Components
– One to 15 platters with two recordable surfaces each
– Stack of platters has diameter of 1 to 8 inches and rotates
at 3600 to 7200 RPM
– Each disk surface divided into 1000 to 5000 concentric
circles called tracks
– Each track divided into 64 to 200 sectors which contain
information
• Access time
– Seek time + rotational latency + transfer time + controller
time
– What is the average rotational latency? 8.3 ms to 4.2 ms
Serial Communication
• Parallel: all bits sent at once
– Fast, but lots of wires; good for short distance
• Serial: bits sent in sequence one at a time
– Slow, but less expensive
– Modems (modulator-demodulator) allow use of telephone
lines
– Simplex: only one way, line radio and television
broadcasting
– Half-duplex: both directions, but one at a time. Modems at
both end change roles as transmitter and receiver in a
turnaround time
– Full-duplex: both directions simultaneously
Communication Between I/O and CPU
• CPU to I/O
– Isolated I/O or memory-mapped I/O
• I/O to CPU
– Operating system needs to know when I/O
finished a task
– Operating system should be notified of any errors
in I/O
– Two methods: Polling and Interrupt Driven
– I/O may access memory directly (DMA)
• Polling (Programmed I/O)
– I/O puts information in a status register
– The OS periodically checks the status register
– Busy wait loop is used to implement polling
– Checks for I/O completion is dispersed among
code
– Advantage: simple, CPU controls all the work
– Disadvantage: Polling overhead consumes a lot of
CPU time
• Interrupt Driven (Exception Strategy)
• I/O interrupts CPU to get its attention
• Step 1: CPU receives interrupt signal from I/O
• Step 2: Current PC or IP is saved
• Step 3: CPU gets address of interrupt service
routine
• Step 4: After executing ISR, CPU jumps back
• Advantage: user program is only halted during
actual transfer
• Disadvantage: Special hardware needed to cause
interrupt (I/O), detect interrupt (CPU), and save
proper states to resume after interrupt (CPU)
• Compare I/O Interrupt and Processor
Exceptions
Overhead of Polling in I/O Systems
• Polling is only suitable for low bandwidth devices
• Polling should be frequently enough not to lose any
data
• Assume and 500 MHz μP with 400 clock cycle polling
– Mouse must be polled 30 times per second
• Fraction of processor clock cycle time consumed is 0.002%
• A 12-bit Hamming code word contains 8 bits of data and 4 parity bits is read from
the memory. What was the original 8-bit data word that was written into memory
if the 12-bit word read out is:
a)000010101010, b)111110010110, and c) 100111110100.
• How many parity check bits must be included with the data word to achieve single
error correction and double error detection when the data word contains: a) 16
bits, b) 32 bits, and c) 64 bits
• It is necessary to formulate the Hamming code for 4 data
bits D3, D5, D6, D7 together with 3 parity bits P1, P2 and
P4.
a) Evaluate the 7-bit composite code word for the data
word 0101
A 1
B 2
C 3
2 4 1 1
2 10 1 1