Professional Documents
Culture Documents
Curs 2017
Patricia Santos Rodriguez
Machine language
Computer instructions can be represented as
sequences of bits. Generally, this is the lowest possible
level of representation for a program each instruction
is equivalent to a single, indivisible action of the CPU.
This representation is called machine language, since it
is the only form that can be understood directly by
the machine.
A slightly higher-level representation (and one that is
much easier for humans to use) is called assembly
language.
3
Assembly language
Assembly language is very closely related to
machine language, and there is usually a
straightforward way to translate programs
written in assembly language into machine
language.
This algorithm is usually implemented by a
program called the assembler.
4
assembly
Machine
language
ALU
CPU
COMPUTER
7
Processor
CPU must:
Fetch instructions
Interpret instructions
Fetch data
Process data
Write data
10
The ALU
The ALU (Arithmetic-Logic Unit, or Patterson and Hennessys
datapath) is the figuring unit of the computer, providing
the calculation capability.
The ALU is connected to storage elements (registers for
holding data to be processed and the results of the
processing) by data buses.
The ALU processor is normally composed of single-element
(one-bit) processors (primarily adders), which are
assembled together to form a 32-bit processor (in the case
of the MIPS R2000). It also includes some other processing
elements.
11
ALU Components
As noted above, the ALU needs other components as well:
Registers to store arguments and results.
Buses to carry data from registers to the ALU and results back to
the register unit.
Two memory access units, with associated buses:
An instruction fetch unit to get instructions from computer
memory as needed. This includes a program counter, which
always points to the address of the next instruction to be
accessed.
A second path to memory to obtain data to be used in the
program and to store data back into memory as required.
A control unit that tells the ALU what to do .
12
ALU Components
13
ALU Components
ALU Architecture
for Processing
In the MIPS CPU, all
arguments used in
processing are stored in
registers.
This requires two buses
to route data to the ALU.
All registers are tied to
both output buses.
A single input bus carries
results back to all 32
registers.
16
MIPS: Registers
We will learn more about Registers when we see the MIPS R-format instructions!
19
MIPS: Memory
Main memory used for composite data
Arrays, structures, dynamic data
21
Example
Data bus connection in a Load Instruction
22
A Complete ALU
Over the last slides, we have designed many of the elements
that, when assembled, will make up the ALU of our MIPS
computer.
We now connect the various sections of the ALU together to
produce a final single cycle ALU; an ALU that executes one
instruction each time the clock ticks.
Note that up to now, we have NOT considered any of the
Control elements of the ALU; that is, the circuits that interpret
the instructions and direct the ALU as to (1) which operation to
execute, and (2) what operands or variables to process.
23
25
ALU Summary
We have now seen how the common elements we studied
earlier are combined to make the MIPS ALU.
This design is a solid, single-cycle implementation that
supports the MIPS instruction we are going to study in the
following lectures on assembly language programming.
We will study the control logic for this in the next slides.
26
28
29
Current Architecture
The ALU control uses instruction bits 0-5 to obtain information
about the ALU operation in register-to-register instructions.
Note in the following diagram (next slide) that some of the
decoding is done in the register block, which has the decoding
mechanism that identifies source and destination registers in
load/store and register/register operations.
The ALU control also has input control lines from the
operation code decoder which decodes bits 26-31.
30
31
Op Code Control
block Signal Identifier
32
Multicycle implementation
A solution to the single-cycle problem is stated as follows:
Each instruction has several phases, such as fetch/decode, register
selection, ALU processing, etc.
Instead of using a single clock cycle for the whole instruction, run
the clock much faster, and have a single clock cycle for each of the
elements or phases of the instruction process.
Many instructions take fewer phases (for example, jump, branch
[the fewest phases], register-register or store instructions), so
these instructions execute much faster.
As most instructions execute faster than the longest instructions
(such as lw), the average instruction time will be reduced
substantially.
34
35
Multicycle Implementation
36
37
38
39
Step 1: Fetch
The Control Unit sends a signal to the RAM in order to fetch the
program and data, which is then stored in one of the CPUs
register. To do so, the CPU makes use of a vital hardware path
called the address bus along which the program and data
travels.
The Control Unit then increments the Program Counter (PC). The
PC is an important register that keeps track of the running order
of the instructions and shows which instruction in the program is
due to be executed next.
The CPU then places the address of the next item to be fetched
on to the address bus. Data from this address then moves from
main memory into the CPU by travelling along another hardware
path called the data bus.
40
Step 2: Decode
The instruction set of the CPU is designed to understand a
specific set of commands, which serves to make sense of
the instruction it has just fetched. This process is called
decode.
A single piece of program code might require several
instructions.
41
Step 3: Execute
This is the part of the cycle when data processing takes
place, and the instruction is executed.
Once the execute stage is complete, the CPU begins the
cycle all over again.
42
Architectures
CISC vs RISC
43
RISC
RISC (Reduced Instruction Set Computer)
At 80s Smaller instructions.
RISC
Smaller instructions.
Uniform instructions (same size) a Easier
decoding.
Regular format.
Easier addressing.
Use of registers a Faster access.
Memory access load/store.
45
RISC
No stack, but registers
Few parameters.
Few local variables.
Simpler hardware Less space.
Von Newmann scheme.
VLSI (Very Large Scale Integration)
Hardwired design No microprogramming.
Optimise the instruction Pipeline.
46
RISC
RISC Compiler
Optimization is done by the compiler.
Less instructions optimized job.
Less instructions Less errors.
Between the program and the microprocessor.
Examples of RISC micro-processors:
ARM Mobile phones
MIPS Playstation 2, Nintendo 64
SPARC Sun Mycrosystems
Cell Playstation 3
47
MIPS
MIPS (Microprocessor without Interlocked Pipeline Stages)
MIPS Computer Systems Inc. was founded in 1984 by a
group of researchers from Stanford University that
included John L. Hennessy, one of the pioneers of the RISC
concept. See: www.mips.com
48
49
Acknowledgements
Part of the content of this collection of slides is based from:
- The University of Texas Dallas (UTD) Erik Jonsson School of
Engineering and Computer Science
50