MARIE: An Introduction To A Simple Computer
MARIE: An Introduction To A Simple Computer
1
Chapter 4 Objectives
2
4.1 Introduction
3
4.2 CPU Basics
4
4.2 CPU Basics
• Registers hold data that can be readily accessed by the CPU.
• They can be implemented using D flip-flops.
• One D flip-flop is equivalent to a 1-bit register, so a
collection of D flip-flops is necessary to store multi-bit
values.
– A 32-bit register requires 32 D flip-flops.
• These collections of flip-flops must be clocked to work in
unison. At each pulse of the clock, input enters the register
and cannot be changed (and thus is stored) until the clock
pulses again.
5
4.2 CPU Basics
• Most computers have registers of a certain size.
(Common sizes include 16, 32, and 64 bits).
• The arithmetic-logic unit (ALU) carries out logical and
arithmetic operations as directed by the control unit.
• The control unit is the policeman” or “traffic manager”
of the CPU and determines which actions to carry out
according to the values in a program counter register
and a status register.
6
4.3 The Bus
This is a point-to-point
bus configuration:
7
4.3 The Bus
8
4.3 The Bus
• Buses consist of data lines, control lines, and address lines.
• While the data lines convey bits from one device to another (are
bidirectional allowing the transfer of data in either direction),
• control lines determine the direction of data flow, and when
each device can access the bus and for what purpose (reading or
writing from memory or from an I/O device, for example).
• Address lines determine the location of the source or destination
of the data (are unidirectional from processor to memory)
• *The power lines provide the electrical power necessary
9
The next slide shows a model bus configuration.
4.3 The Bus
10
4.3 The Bus
• In a master-slave configuration, where more than one
device can be the bus master, concurrent bus master
requests must be arbitrated.
• Bus arbitration schemes must provide priority to certain
master devices while, at the same time, making sure
lower priority devices are not starved out.
• Four categories of bus arbitration are:
– Daisy chain: Permissions – Distributed using self-detection:
are passed from the highest- Devices decide which gets the bus
priority device to the among themselves.
lowest. – Distributed using collision-
– Centralized parallel: Each detection: Any device can try to
device is directly connected use the bus. If its data collides
to an arbitration circuit. with the data of another device,
11
it tries again.
4.4 Clocks
12
4.4 Clocks
13
4.5 The Input/Output Subsystem
14
4.6 Memory Organization
15
4.6 Memory Organization
18
4.7 MARIE
• Memory buffer register, MBR, a 16-bit register that holds the data
after its retrieval from, or before its placement in memory.
• MBR - holds either the data just read from memory or the data
ready to be written to memory.
19
4.7 MARIE
20
4.7 MARIE
21
4.7 MARIE
22
4.7 MARIE
23
4.7 MARIE
Instruction set architecture
• computer’s instruction set architecture (ISA) specifies the format of its
instructions and the primitive operations that the machine can perform.
•The ISA is an interface between a computer’s hardware and its software.
•Some ISAs include hundreds of different instructions for processing
data and controlling program execution.
•Opcode-specifies the instruction to be executed (which allows for a total
of 16 instructions).
•The least significant 12 bits, bits 0–11, form an address, which allows
for a maximum memory size of 212–1.
24
4.7 MARIE
25
4.7 MARIE
26
4.7 MARIE
27
4.7 MARIE
28
4.7 MARIE
29
4.7 MARIE
30
4.8 Instruction Processing
32
4.8 Instruction Processing
Interrupt
•All computers provide a way of interrupting the fetch-decode-
execute cycle.
•Interrupt is a signal to the processor generated by the
software/hardware indicating an immediate attention needed by an
event.
•Typically, the input or output device sends an interrupt by using a
special register, the status or flag register.
•A special bit is set to indicate an interrupt has occurred. For
example, as soon as input is entered from the keyboard, this bit is
set. The CPU checks this bit at the beginning of every machine
cycle.
33
4.8 Instruction Processing
When it is set, the CPU processes an interrupt. When it is not
set, the CPU performs a normal fetch-decode-execute cycle,
processing instructions in the program it is currently executing.
•Interrupts can be : hardware interrupts and software interrupts.
Hardware interrupts: are used by devices to communicate that
they require attention from the operating system.
software interrupt is caused either by an exceptional condition in
the processor itself, or a special instruction in the instruction set
which causes an interrupt when it is executed.
e.g. divide-by-zero exception
34
Software interrupts are also called traps.
4.8 Instruction Processing
35
4.8 Instruction Processing
36
4.8 Instruction Processing
37
4.9 A Simple Program
38
4.9 A Simple Program
39
4.9 A Simple Program
40
4.9 A Simple Program
41
4.10 A Discussion on Assemblers
42
4.10 A Discussion on Assemblers
44
4.10 A Discussion on Assemblers
45
4.10 A Discussion on Assemblers
46
4.10 A Discussion on Assemblers
• Assembly language puts the programmer closer to the architecture.
• As a programmer, the closest you can come to the processor of a
machine is by using assembly language. Here, you can write code
to access the registers and even deal with memory addresses
directly for retrieving values and pointers.
• e.g, embedded systems. These are systems in which the computer
is integrated into a device that is typically not a computer.
• These systems are designed to perform either a single instruction
or a very specific set of instructions. (cameras, medical
instruments (such as heart monitors))
*Assembly language puts the programmer closer to the architecture,
and thus, in firmer control.
47
4.11 Extending Our Instruction Set
48
4.11 Extending Our Instruction Set
AC 0 50
4.12 A Discussion on Decoding
52
4.12 A Discussion on Decoding
53
Fig. Hardwired Control Unit
4.12 A Discussion on Decoding
• Microprogramming, uses software for control.(storing the
control signals in memory)
• In microprogrammed control, instruction microcode
produces control signal changes.
• All machine instructions are input into a special program,
the microprogram, to convert the instruction into the
appropriate control signals.
• The microprogram is essentially an interpreter, written in
microcode, that is stored in firmware (ROM, PROM, or
EPROM), which is often referred to as the control store.
54
4.12 A Discussion on Decoding
55
4.12 A Discussion on Decoding
56
4.12 A Discussion on Decoding
57
Fig. microprogrammed control unit
4.13 Real World Architectures
58
4.13 Real World Architectures
RISC
•A reduced instruction set computer is a computer which
only uses simple commands that can be divided into several
instructions which achieve low-level operation within a
single CLK cycle.
•It is a CPU design plan based on simple orders and acts
fast.
•every instruction is expected to attain very small jobs. In
this machine, the instruction sets are modest and simple,
•Execution time is very less
59
4.13 Real World Architectures
CISC
•It is a CPU design plan based on single commands,
which are skilled in executing multi-step operations.
•CISC computers have small programs. It has a huge
number of compound instructions, which takes a long
time to perform.
•It has a memory unit to implement complex
instructions.
60
4.13 Real World Architectures
61
4.13 Real World Architectures
62
4.13 Real World Architectures
63
4.13 Real World Architectures
64
4.13 Real World Architectures
65
4.13 Real World Architectures
66
Chapter 4 Conclusion
67
Chapter 4 Conclusion
68