ELEC 2441 - Computer Organization and Microprocessors
ELEC 2441 - Computer Organization and Microprocessors
ELEC 2441 - Computer Organization and Microprocessors
Todays Quote
- Albert Einstein.
Chapter 2 1
2. Basic Organization & Operations of
A Microcomputer
[Part A]
Objectives:
The uses of tri-state logic gates to control data bus in a
microcomputer;
The RS flip-flops (FFs), clocked RS FFs and D-type
FFs;
The importance of Setup and Hold time for clocked
FFs;
FFs as registers to transfer data in parallel or serial
mode;
The basic concepts and operation of data buses;
Decoders, Encoders, Multiplexers and their uses in
modern computers;
Basic operations of an Arithmetic Logic Unit (ALU) in
modern computers;
Understand the basic computer organization (i.e. CPU,
Memory and I/O units);
An overview of computer instructions: common types
and formats.
Basic steps involved in a program execution.
Chapter 2 2
Tri-state (three-state) logic (ref. Ch. 2.3) for Control of
Signal Flows
A B A B
E=1
A B A B
E=0
Chapter 2 3
Active high signal
A B
If E = 0, B = A' ,
if E = 1, B is disconnected (high impedance state).
[In fact, active-low signals are very popular examples used in our ref. book #1!]
Chapter 2 4
Bus organization (ref. Ch. 2.3, pp.39)
E2 E4 E6 E8 E10
E1 E3 E5 E7 E9
Only one device can send data through the bus at any one
time, otherwise there will be a conflict (bus contention), &
will cause hardware damage.
More than one device can receive data at any one time
because there is no conflict.
Chapter 2 5
An n-bit bus can be implemented by duplicating a 1-bit
bus n times. n bits can be transferred at any one time.
3-bit bus
Chapter 2 6
Flip-flops (ref. Ch. 2.4)
Flip-flops possess 2 states only.
RS flip-flop (Latch)
[Caution: The RS flip-flop is different from the Basic FF Circuit
introduced on pp.41. Here, we used NOR rather than NAND gate]
R R S Qn+1 Q'n+1
(reset, Q
clear) 0 0 Qn Q'n
0 1 1 0
S Q' 1 0 0 1
(set) 1 1 0 0
When R=S=0, Q & Q' will not change, i.e., current state =
previous state.
Chapter 2 7
Clocked RS flip-flop (ref. Ch. 2.6)
R S Qn+1 Q'n+1
R
Q 0 0 Qn Q'n
CLK 0 1 1 0
1 0 0 1
Q'
S 1 1 Avoid
level-triggered flip-flop
In the above circuit, transition occurs only during CLK=1.
Edge-triggered flip-flop
Corrects the above pitfall. Transition occurs only during
the rising edge of the clock pulse. The circuit is more
complex.
When the clock pulse exceeds a given threshold, inputs are
locked out & the flip-flop is unresponsive to further
changes in the input until the clock pulse returns to zero &
another pulse occurs.
S Q
CLK
R Q'
Chapter 2 8
D flip-flop (ref. Ch. 2.6)
D Q S Q
CLK CLK
Q' R Q'
Truth table
D Q
0 0
1 1
Chapter 2 9
Practical waveforms (ref. Ch. 2.8)
Ideal signal
Real signal
Chapter 2 10
Setup time (ref. Ch. 2.8)
Sampling
instant
D=1
D Q
D=0 CLK=1
CLK
Q'
CLK=0
t1 t2
Setup time
At t1, the input at D changes from 0 to 1.
Chapter 2 11
Hold time
Sampling
instant
D=1
D Q
CLK D=0 D=0
CLK=1
Q'
CLK=0
t1 t2 t3
Setup time Hold time
Again, it takes a finite time (until t3) for the internal logic
gates of the flip-flop to reach the correct state following
the rising edge of CLK.
Chapter 2 12
Registers (ref. Ch. 2.9)
x1 x2 xn
LOAD
D Q y1 D Q y2
... D Q yn
Q' Q' Q'
CLOCK
Chapter 2 13
Parallel transfer from one register to another (ref. Ch. 2.9)
D Q x1 D Q x2 D Q xn
Q' Q' Q'
...
D Q y1 D Q y2 D Q yn
Q' Q' Q'
CLOCK
Shift register
Serial
input S
D Q1
Q1'
D Q2
Q2'
D Q3
Q3'
... D Qn
Qn'
CLOCK
Chapter 2 14
Bus operation (ref. Ch. 2.11 and 2.12)
Flip-flops can be used for sending & receiving data from a
bus.
1-bit bus
E1 E2 E3
D1 Q1 D2 Q2 D3 Q3 D4 Q4 D5 Q5 D6 Q6
CLK1 CLK2 CLK3 CLK4 CLK5 CLK6
Chapter 2 15
e.g. to transfer data from Device A to Device C:
E1
data valid
Data bus High-Z High-Z
CLK6
t1 t2 t3 t4 t5
Chapter 2 16
An n-bit bus can be implemented by duplicating the 1-bit
bus n times. Common bus widths are 8-bit, 16-bit, 32-bit
& 64-bit.
E1 E2
E1
D Q E2 D Q
D Q D Q
E1 E2
D Q D Q D Q D Q
D Q D Q D Q D Q
Device A Device B
Chapter 2 17
Integrated circuits (I.C.) (ref. Ch. 2.10)
The 74173 is a 4-bit register with 4 flip-flops & tri-state
buffers.
Chapter 2 18
Bidirectional register
Chapter 2 19
It can be further simplified as:
Chapter 2 20
Decoders (ref. Ch. 2.13)
A decoder is a logic device such that given an input code,
the associated (corresponding) output line is activated.
B O5
Chapter 2 21
Encoders (ref. Ch. 2.14)
An encoder is the inverse of a decoder.
Chapter 2 22
Multiplexers (ref. Ch. 2.15)
A multiplexer (or data selector) has a number of input
data streams. Depending on the selector input, one of the
input data streams is routed to the output.
Chapter 2 23
e.g.
Chapter 2 24
A multiplexer can be implemented using a decoder and
some logic gates.
I0
Input I1
channels
I2
I7
S2
Channel 3-to-8
S1
select Decoder Output
S0
Chapter 2 25
Arithmetic circuit (ref. Ch. 2.16)
Chapter 2 26
The operation to be performed (e.g. +) is given by the
control inputs.
Chapter 2 27
Basic Computer Organization [ref. text. Ch. 4.4]
Input unit:
Accepts information from the outside world, e.g.
keyboard, mouse, hard disk, CD reader.
Output unit:
Outputs processed data to the outside world, e.g.
monitor, printers, hard disk, CD writer.
Memory unit:
Stores both instructions & data ready for execution.
Made up of a large no. of memory units (e.g. 216 units
in the Motorola MC68HC11 a simple example of 8-bit
uniprocessor).
Each unit has a unique address.
Each unit may contain a collection of bits (a nibble,
character, or byte), or even larger unit called a word.
Most computers: 1 byte = 8 bits, 1 word = 2 bytes
Chapter 2 28
CPU:
The CPU consists of the Control (unit) + Datapath =
ALU and some registers (or accumulators).
Control unit:
Sequences operations, decodes instructions,
controls other units. [i.e. timing and control logic
(TCL) unit, instruction decoder, etc]
Datapath
- ALU (as shown on p.26 - 27):
Performs arithmetic & logic operations.
Chapter 2 29
Bus: [ref. p159 - 160]
The bus connects the units together so that information
can travel from one unit to another. There are three
buses: data bus, address bus & control bus.
Data bus:
Transfers data from one unit to another.
Address bus:
Carries address information. For example, to
access memory for data, the address of the
memory cell is put onto the address bus. To access
the internal register of an input/output device, the
address of that register is put onto the address bus.
Control bus:
Carries control information. For example, if the
CPU wants to read from a memory cell, CPU (i)
puts the address of the cell onto the address bus,
(ii) activates the READ signal on the control bus.
The memory unit, knowing that it is a read
operation, will take the address from the address
bus, read the addressed cell, and put the data onto
the data bus. The CPU then gets the data from the
data bus.
Chapter 2 30
As explained in the previous section on digital circuits,
all the above information transfers can be effected by
enabling and disabling the appropriate tri-state buffers
so that the registers holding the information and the
registers receiving the information are connected to the
bus.
Chapter 2 31
Instructions (ref. text Ch. 4.9)
Chapter 2 32
Common Instruction Formats
(1) Three-address Instructions
An operation code (op-code) followed by 3
addresses/registers (as in most ARM instructions);
An example of 3-address instruction format:
Chapter 2 33
(3) One-address instructions
Op-code Source
Addr. / Reg.
4-bit
16-bit operand address
op code
19 18 17 16 15 14 ................2 1 0
0 1 0 0 0 1 0 1 1 0 1 0 0 1 1 1 0 0 1 0
The instruction informs the CPU to get the data byte from
memory at address $5A72, send it to the ALU, add the
data byte to the integer in the accumulator. The result is
to be stored in the accumulator (i.e. the original integer in
the accumulator (ACC) is lost).
Chapter 2 35
An Example of Assembly program (based on 1-
address or accumulator-based instructions)
Basically, a program, no matter expressed in which prog.
lang., = a sequence of instructions.
Assume the 3 hex. integers $10, $A1 & $2B already stored at
consecutive memory cells/units starting at address $E0.
Address Content
$E0 $10
$E1 $A1
$E2 $2B
$E3
Note:
The above program does not compute $E0+$E1+$E2.
Chapter 2 36
Instead, it computes $10+$A1+$2B (i.e. values stored at
addr. $E0..E2) & stores the result $DC at address $E3.
Chapter 2 37
Basic Steps Involved in A Program Execution
The program to be executed is always stored in memory.
LDAA $80 ; load the value from addr. $80 into ACC-A
Chapter 2 38
Here are the basic steps to execute the above instruction
($96 $80):
Chapter 2 39
After executing the current instruction, if the program
contains more instructions, the CPU fetches the next
instruction, decodes & executes it. This continues until all
instructions in the program have been executed.
Chapter 2 40
Summary: [** The following key points are written to facilitate your revision.
Knowing ONLY these key points is always not sufficient for test or exam.]
Tri-state logic devices for the control of signal flows: when
ENABLE, the normal HIGH/LOW output; else DISABLE (high-
Z) state, output as disconnected from the device!
When multiple device outputs are often connected to the same line
in a data bus, the high-Z state of tri-state logic gates can be set to
avoid bus contention (i.e. two or more buffer outputs compete for
the same data line)!
Basically, flip-flops (FFs) can be used as memory devices to store
binary information in digital computers. The simplest RS FFs
takes two input signals: basically when Set = 1 Output (Q) = 1;
when Reset = 1 Output (Q) = 0. The clocked RS FFs allows the
synchronous changes of states for FFs to exchange information
between the FFs thru the clock signal. The D-type FF is mainly
used to lock up/store binary information.
The Setup time is the minimum time interval before the activation
CLK signal, during which the synchronous input has to be stable
at a proper level for the reliable operation of clocked FFs; whereas
the Hold time is the minimum time interval for that synchronous
input to remain unchanged after the activation CLK signal.
A register is a group of memory devices to store binary
information. The most common register device is the FF. To
transfer data between two groups (X1 and X2 versus Y1 and Y2)
of registers in parallel, simply wire the registers one-to-one to
facilitate the parallel transfer of: [X1][Y1] and [X2][Y2]. For
serial transfer, we need SHIFT registers to shift one bit at a time.
Chapter 2 41
The basic concepts and operation of data buses: A data bus is a set
of common data lines carrying signals from one device to another.
Always remember to carefully set/unset the Input/Output Enable
of connected devices (tri-state registers) so as to ensure exclusive
access to the concerned data bus at any time!
A decoder is a logic device such that given an input code, the
associated (corresponding) output line is activated, e.g. 3-to-8
binary code decoder. An encoder works in the reverse way of a
decoder. A multiplexer is basically a data selector which can be
implemented by a decoder and some logic gates.
The Arithmetic/logic unit (ALU) is responsible for performing
operations such as +, , , , logical operations such as AND, OR,
etc. with an accumulator (A) and a data buffer register (B). The
immediate result is always stored at the accumulator.
Most modern computers contain five basic units:
(i) datapath: the arithmetic/logic unit (ALU) + registers (or
other functional units), (ii) the control unit [(i) + (ii) = the central
processing unit (CPU)], (iii) the memory, (iv) the input unit, (v)
the output unit.
Basically, computer instructions can be categorized into 4 types: i)
arithmetic or logic, ii) program control, iii) internal data
manipulation and iv) I/O. In general, there can be 3 different kinds
of instruction formats, namely the 3-address, 2-address and 1-
address instructions, depending on the number of operand
address(es) or register(s) allowed in a single instruction.
A (computer) program is basically a sequence of instructions
stored in memory (ROM or RAM) to specify the operations to be
performed in a computer.
Chapter 2 42
The basic execution cycle of a program is: i) fetch op code, ii)
decode op code, iii) fetch operand, iv) execute the instruction.
Chapter 2 43