0% found this document useful (0 votes)
46 views34 pages

The Processor: Dr. Randa Mohamed

The document describes the design of a MIPS processor datapath. It discusses building the datapath incrementally to support different instruction types. The datapath includes components like registers, multiplexers, an ALU, and a register file. It is built to execute R-type instructions using register operands, I-type load and store instructions using memory, and branch instructions using comparison. The full datapath can execute an instruction in one clock cycle by fetching it, decoding registers, executing with the ALU or memory, and writing results or updating the PC.

Uploaded by

Body Abdo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views34 pages

The Processor: Dr. Randa Mohamed

The document describes the design of a MIPS processor datapath. It discusses building the datapath incrementally to support different instruction types. The datapath includes components like registers, multiplexers, an ALU, and a register file. It is built to execute R-type instructions using register operands, I-type load and store instructions using memory, and branch instructions using comparison. The full datapath can execute an instruction in one clock cycle by fetching it, decoding registers, executing with the ALU or memory, and writing results or updating the PC.

Uploaded by

Body Abdo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

COMPUTER ORGANIZATION AND DESIGN 5th

Edition
The Hardware/Software Interface

Chapter 4
The Processor

Dr. Randa Mohamed


Agenda
◼ Introduction
◼ Logic design basics
◼ MIPS Datapath: R-Type & I-Type

Chapter 4 — The Processor — 2


§4.1 Introduction
Introduction
◼ Processor design is composed of 2 modules:
Datapath and Control
◼ We will examine

1. Two MIPS implementations


◼ A simplified version (Single cycle MIPS)

◼ A more realistic pipelined version (Pipelined MIPS)

2. Implementation that supports


◼ R-type instructions, like ADD, SUB
◼ I-type instructions LW, SW
◼ Conditional branch instruction BEQ
◼ J-type branch instruction J
Chapter 4 — The Processor — 3
§4.2 Logic Design Conventions
Logic Design Basics
◼ Information encoded in binary
◼ Low voltage = 0, High voltage = 1
◼ One wire per bit
◼ Multi-bit data encoded on multi-wire buses
◼ Combinational element
◼ Operate on data
◼ Output is a function of input
◼ State (sequential) elements
◼ Store information

Chapter 4 — The Processor — 4


Combinational Elements

◼ AND-gate ◼ Adder A
Y
+
◼ Y=A&B ◼ Y=A+B B

A
Y
B

◼ Arithmetic/Logic Unit
◼ Multiplexer ◼ Y = F(A, B)
◼ Y = S ? I1 : I0
A
I0 M
u Y ALU Y
I1 x
B
S F

Chapter 4 — The Processor — 5


Sequential Elements
◼ Stores data in a circuit
◼ Uses a clock signal to determine when to update
the stored value
◼ Edge-triggered: update when Clk changes from 0
to 1

Clk
D Q
D

Clk
Q

Chapter 4 — The Processor — 6


Sequential Elements
◼ Storing with write control
◼ Only updates on clock edge when write control
input is 1
◼ Used when stored value is required later

Clk

D Q Write

Write D
Clk
Q

Chapter 4 — The Processor — 7


§4.3 Building a Datapath
Building a Datapath
◼ Datapath
◼ Elements that process data and addresses
in the CPU
◼ Registers, ALUs, mux’s, memories, …
◼ We will build a MIPS datapath incrementally
◼ Refining the overview design

Chapter 4 — The Processor — 9


Datapath

Chapter 4 — The Processor — 10


Multiplexers
◼ Can’t just join
wires together
◼ Use multiplexers

Chapter 4 — The Processor — 11


Datapath

Chapter 4 — The Processor — 12


Instruction Fetch

Increment by
4 for next
32-bit instruction
register

Chapter 4 — The Processor — 13


Instruction Fetch

Increment by
4 for next
32-bit instruction
register

Chapter 4 — The Processor — 14


Instruction Fetch

Field bit
31-26 25-21 20-16 15-11 10-6 5-0
positions
No. of bits 6 5 5 5 5 6
R-type op rs rt rd shamt funct
I-type 16- bit
op rs rt
immediate/address

Chapter 4 — The Processor — 15


R-Format Instructions

Chapter 4 — The Processor — 16


R-Format Instructions
◼ Read two source register operands (defined by rs,rt)
◼ Perform arithmetic/logical operation
◼ Write result in destination register (defined by rd)

Chapter 4 — The Processor — 17


Register File

Chapter 4 — The Processor — 18


ALU

Chapter 4 — The Processor — 19


Load/Store Instructions

Chapter 4 — The Processor — 20


Load/Store Instructions
◼ To read from the data memory, set Memory read =1
◼ To write into the data memory, set Memory write =1

Chapter 4 — The Processor — 21


Load Instruction
◼ Read register operands & calculate address using 16-
bit offset What parts of R-type are altered?

Data[rs]

Offset (32)

Chapter 4 — The Processor — 22


R-Type/Load Instruction
◼ Read register operands & calculate address using 16-
bit offset

Chapter 4 — The Processor — 23


Store Instruction
◼ Read register operands & calculate address using 16-
bit offset
Data[rs]

Offset (32)

Chapter 4 — The Processor — 24


R-Type/Load/Store Datapath

Chapter 4 — The Processor — 25


Branch Instructions
◼ Read register operands
◼ Compare operands
◼ Use ALU, subtract and check Zero output
◼ Calculate target address (PC +4 +Add×4)
◼ Sign-extend displacement
◼ Shift left 2 places (word displacement)
◼ Add to PC + 4
◼ Already calculated by instruction fetch

Chapter 4 — The Processor — 26


Branch Instructions
Just
re-routes
wires PC+4+ Add×4

Data[rs]

Data[rt]
Zero=1 Branch

Offset (32)

Chapter 4 — The Processor — 27


Full Datapath

Chapter 4 — The Processor — 28


Full Datapath: R-Type

Chapter 4 — The Processor — 29


Full Datapath: I-Type (Load)

Chapter 4 — The Processor — 30


Full Datapath: I-Type (Store)

Chapter 4 — The Processor — 31


Full Datapath: I-Type (Beq:T)

Chapter 4 — The Processor — 32


Full Datapath: I-Type (Beq:F)

Chapter 4 — The Processor — 33


Instruction Execution Summary
Data path does an instruction in one clock cycle
1. Fetch: PC → instruction memory → instruction
2. Decode: Register numbers → register file → read
registers
3. Execute: Depending on instruction class
◼ Use ALU to calculate
◼ Arithmetic result

◼ Memory address for load/store

◼ Branch target address

◼ Access data memory for load/store


◼ PC  target address or PC + 4
Chapter 4 — The Processor — 34
Problems to Solve
4.1, 4.7

Chapter 4 — The Processor — 35

You might also like