SlideShare a Scribd company logo
Datapath and control for simple processor
ECE 374
ECE 374 U. Tida 1 / 38
Background
Focus of this lecture
ECE 374 U. Tida 2 / 38
Background
Introduction
CPU performance factors
Instruction count
? Determined by ISA and Compiler
CPI and Cycle time
? Determined by CPU hardware
Implementations Covered MIPS (Microprocessor without Interlocked
Pipelined Stages) implementations
A simplified version
An improved version by pipelining technique
Instructions covered for MIPS implementation
Memory reference: lw, sw
Arithmetic/logical: add, sub, and, or, slt
Control transfer: beq, j
ECE 374 U. Tida 3 / 38
Background
Instruction Execution Procedure
1 PC (program counter) → instruction memory, fetch instruction
2 Register numbers → register file, read
3 Instruction determines ALU to calculate:
Arithmetic/logic result
Memory address for load/store
Branch target address
4 Access data memory for load/store or write to register
5 PC ← target address or PC+4
ECE 374 U. Tida 4 / 38
Background
CPU Overview
ECE 374 U. Tida 5 / 38
Background
CPU Overview
We cannot join wires together and expect it to select whatever we
need by itself.
Use multiplexer to select between data
ECE 374 U. Tida 6 / 38
Background
Control
The blue circuitry (control logic) determines instruction execution.
ECE 374 U. Tida 7 / 38
Background Logic Design
Logic Design Basics
Binary Encoded Information
Two states: Low voltage = 0 and High voltage = 1. (Traditional
method)
One wire per bit
Multi-bit data encoded on multi-wire buses
Combinational Element
Operate on data continuously
Output is a function of input
State (Sequential Element
Store information for a certain period
ECE 374 U. Tida 8 / 38
Background Logic Design
Typical Combinational Elements
Given a set of inputs, it always produces the same output
AND-gate
Y = A & B
Adder
Y = A + B
Multiplexer
Y = S ? I1 : I0
Arithmetic Logical Unit (ALU)
Y = F(A , B)
ECE 374 U. Tida 9 / 38
Background Logic Design
Sequential Element
Register: Stores data in a circuit
Clock signal determines when to update the stored value
Edge-triggered flip flop: update data when clk changes 0 to 1 =⇒
positive triggered (1 to 0 =⇒ negative triggered)
ECE 374 U. Tida 10 / 38
Background Logic Design
Sequential Element with write control
Register with write control
Only updates on clock edge when write control input is 1
ECE 374 U. Tida 11 / 38
Background Logic Design
Maximum clock speed
Combinational logic transforms data between clock edges
Longest delay for data to travel [input state element → combinational
logic → output state element] determines clock period
ECE 374 U. Tida 12 / 38
Datapath Design
Datapath Design Approach
Datapath design
Design of elements that process data and addresses (of data memory
and instruction memory) in the CPU
Consists of Registers, ALU, Mux’s, memories, ...
Approach
Let’s start with one set of instructions and include rest systematically
by refining the overall design of previous step.
Instruction-set Design Sequence we follow
1 R-format instructions
2 I-format instructions
3 J-format instructions
ECE 374 U. Tida 13 / 38
Datapath Design
Step 1: Instruction Fetch
Program Counter (PC) Register
Holds address of the current instruction
Increment by 4 after each fetch!
Common step for all instruction type execution
ECE 374 U. Tida 14 / 38
Datapath Design R-format
Datapath design for R-type instructions
Register format (R-format)
Instruction Fields:
op: operation code or opcode of an instruction.
rs: first source register number (READ)
rt: second source register number (READ)
rd: destination register number (WRITE)
shamt: shift amount
funct: function code
ECE 374 U. Tida 15 / 38
Datapath Design R-format
Step 2: Read registers
R-format instruction has two register addresses of a register file and
this information is used to read the two registers simulataneously!
ECE 374 U. Tida 16 / 38
Datapath Design R-format
Step 3: Perform operation
The register read in Step 2 will be given to the ALU to perform the
required opeartion!
ECE 374 U. Tida 17 / 38
Datapath Design R-format
Step 4: Write back result
ALU result will be stored in the destination register
RegWrite is a control signal that will be high almost at the end of
clock cycle!
ECE 374 U. Tida 18 / 38
Datapath Design I-format
Datapath design extension to include I-format instructions
Immediate format (I-format)
Instruction Fields:
op: operation code or opcode of an instruction. Determined by the
hardware control
rs: first source register number (READ)
rt: destination register number (READ (SW)/WRITE (LW))
constant: 16 bit size
address: 16 bit offset added to base address in rs
Different formats complicate decoding but allow 32-bit instructions
uniformly.
ECE 374 U. Tida 19 / 38
Datapath Design I-format
Step 2: Read registers
Two reads occur for sw instruction and only one read occurs for lw
instruction
ECE 374 U. Tida 20 / 38
Datapath Design I-format
Step 3: Address calculation
The register read in Step 2 will be given to the ALU to perform the
required opeartion!
ECE 374 U. Tida 21 / 38
Datapath Design I-format
Step 4: Access memory: (Write for sw and Read for lw)
ECE 374 U. Tida 22 / 38
Datapath Design I-format
Step 5: Write back result
Data in memory will be stored in the destination register
ECE 374 U. Tida 23 / 38
Datapath Design I-format
Putting all together for R-type and Memory instructions!
ECE 374 U. Tida 24 / 38
Datapath Design I-format
How about conditional branch (beq)?
ECE 374 U. Tida 25 / 38
Datapath Design I-format
Putting all together for R-type and I-type instructions!
ECE 374 U. Tida 26 / 38
Control circuitry
Think of controlling the circuit
ECE 374 U. Tida 27 / 38
Control circuitry
ALU operation
Utilize it for
1 Addition in Load/Store instructions for memory address calculation
2 Subtraction in branch if equal (beq) instruction
3 Operation depending on funct field for R-type instructions!
ALU operation (4-bit) Function
0000 AND
0001 OR
0010 add
0110 subtract
0111 set-on-less-than
1100 NOR
ECE 374 U. Tida 28 / 38
Control circuitry
ALU control
ALU operation (4-bits) are set depending on opcode and funct bits
Since there are only 4 different opcodes possible i.e., lw, sw, beq and
R-type, we can assume 2 ALUOp bits derived from opcode
We will design a combination logic circuits based on truth table to
obtain ALU operation bits
inst ALUOp Operation funct ALU function ALU operation
lw 00 load word XXXXXX add 0010
sw 00 load word XXXXXX add 0010
beq 01 branch if equal XXXXXX subtract 0110
R-type 10
add 100000 add 0010
subtract 100010 subtract 0110
AND 100100 AND 0000
OR 100101 OR 0001
set on less than 101010 set on less than 0111
ECE 374 U. Tida 29 / 38
Control circuitry
Main control circuit from instruction register
Control signals are derived from instruction register!
ECE 374 U. Tida 30 / 38
Datapath and control: Processor
Datapath with control
ECE 374 U. Tida 31 / 38
Datapath and control: Processor
Datapath and control of R-type instruction
ECE 374 U. Tida 32 / 38
Datapath and control: Processor
Datapath and control of load instruction
ECE 374 U. Tida 33 / 38
Datapath and control: Processor
Datapath and control of branch-on-equal instruction
ECE 374 U. Tida 34 / 38
Datapath and control: Processor
How about Unconditional Jump (j)?
Jump uses word address
Update PC with concatenation of
? Top 4-bit of old PC
? 26-bit jump address
? 00 (multiply by 4)
Need an extra control signal decoded from opcode
ECE 374 U. Tida 35 / 38
Datapath and control: Processor
Datapath and control with Jumps added
ECE 374 U. Tida 36 / 38
Datapath and control: Processor
Performance metric and issues
Longest delay determines clock period
Critical path: load instruction
? Instruction memory → Register file → ALU → Data memory →
Register file
What happens if the frequency of load instruction is low?
We can improve performance by pipelining (will be covered in next
lecture series!)
Sincere suggestion: Revise the lecture slides, clear doubts, practice many
problems, prepare to become a computer engineer!
ECE 374 U. Tida 37 / 38
What have we learnt today?
1 Background
Logic Design
2 Datapath Design
R-format
I-format
3 Control circuitry
4 Datapath and control: Processor
ECE 374 U. Tida 38 / 38

More Related Content

Similar to ECE_374_Lec4.pdf

Basic computer organization and design
Basic computer organization and designBasic computer organization and design
Basic computer organization and design
mahesh kumar prajapat
 
multi cycle in microprocessor 8086 sy B-tech
multi cycle  in microprocessor 8086 sy B-techmulti cycle  in microprocessor 8086 sy B-tech
multi cycle in microprocessor 8086 sy B-tech
RushikeshThorat24
 
MICROCONTROLLER.pptx
MICROCONTROLLER.pptxMICROCONTROLLER.pptx
MICROCONTROLLER.pptx
fiqrie mohd
 
microprocessor8085 power point presentation
microprocessor8085 power point presentationmicroprocessor8085 power point presentation
microprocessor8085 power point presentation
rohitkuarm5667
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
Dilum Bandara
 
CMPN301-Pipelining_V2.pptx
CMPN301-Pipelining_V2.pptxCMPN301-Pipelining_V2.pptx
CMPN301-Pipelining_V2.pptx
NadaAAmin
 
8085 microprocessor(1)
8085 microprocessor(1)8085 microprocessor(1)
8085 microprocessor(1)
Reevu Pal
 
Unit 2 8085.pdf
Unit 2 8085.pdfUnit 2 8085.pdf
Unit 2 8085.pdf
HimanshuPant41
 
timing_diagram_of_8085.pptx
timing_diagram_of_8085.pptxtiming_diagram_of_8085.pptx
timing_diagram_of_8085.pptx
BhagyarajKosamia
 
computer architecture
computer architecture computer architecture
computer architecture
Dr.Umadevi V
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
Nitin Ahire
 
AVR arduino dasar
AVR arduino dasarAVR arduino dasar
AVR arduino dasar
Oktaf Kharisma
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
vipinkmenon1
 
8051 Presentation
8051 Presentation8051 Presentation
8051 Presentation
Sayan Chakraborty
 
UNIT 1 Microprocessors.pptx
UNIT 1 Microprocessors.pptxUNIT 1 Microprocessors.pptx
UNIT 1 Microprocessors.pptx
Gowrishankar C
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
Ankita Tiwari
 
Ch5_MorrisMano.pptx
Ch5_MorrisMano.pptxCh5_MorrisMano.pptx
Ch5_MorrisMano.pptx
SangeetaTripathi8
 
Computer architecture 3
Computer architecture 3Computer architecture 3
Computer architecture 3
Dr.Umadevi V
 
Computer organisation Module 1.ppt
Computer organisation Module 1.pptComputer organisation Module 1.ppt
Computer organisation Module 1.ppt
SoulReaper21
 
Lecture6
Lecture6Lecture6
Lecture6
Mahmut Yildiz
 

Similar to ECE_374_Lec4.pdf (20)

Basic computer organization and design
Basic computer organization and designBasic computer organization and design
Basic computer organization and design
 
multi cycle in microprocessor 8086 sy B-tech
multi cycle  in microprocessor 8086 sy B-techmulti cycle  in microprocessor 8086 sy B-tech
multi cycle in microprocessor 8086 sy B-tech
 
MICROCONTROLLER.pptx
MICROCONTROLLER.pptxMICROCONTROLLER.pptx
MICROCONTROLLER.pptx
 
microprocessor8085 power point presentation
microprocessor8085 power point presentationmicroprocessor8085 power point presentation
microprocessor8085 power point presentation
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
 
CMPN301-Pipelining_V2.pptx
CMPN301-Pipelining_V2.pptxCMPN301-Pipelining_V2.pptx
CMPN301-Pipelining_V2.pptx
 
8085 microprocessor(1)
8085 microprocessor(1)8085 microprocessor(1)
8085 microprocessor(1)
 
Unit 2 8085.pdf
Unit 2 8085.pdfUnit 2 8085.pdf
Unit 2 8085.pdf
 
timing_diagram_of_8085.pptx
timing_diagram_of_8085.pptxtiming_diagram_of_8085.pptx
timing_diagram_of_8085.pptx
 
computer architecture
computer architecture computer architecture
computer architecture
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
AVR arduino dasar
AVR arduino dasarAVR arduino dasar
AVR arduino dasar
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
8051 Presentation
8051 Presentation8051 Presentation
8051 Presentation
 
UNIT 1 Microprocessors.pptx
UNIT 1 Microprocessors.pptxUNIT 1 Microprocessors.pptx
UNIT 1 Microprocessors.pptx
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
 
Ch5_MorrisMano.pptx
Ch5_MorrisMano.pptxCh5_MorrisMano.pptx
Ch5_MorrisMano.pptx
 
Computer architecture 3
Computer architecture 3Computer architecture 3
Computer architecture 3
 
Computer organisation Module 1.ppt
Computer organisation Module 1.pptComputer organisation Module 1.ppt
Computer organisation Module 1.ppt
 
Lecture6
Lecture6Lecture6
Lecture6
 

Recently uploaded

spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
gowrishankartb2005
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
Roger Rozario
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
TaghreedAltamimi
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
architagupta876
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
MiscAnnoy1
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
Madan Karki
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 

Recently uploaded (20)

spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 

ECE_374_Lec4.pdf

  • 1. Datapath and control for simple processor ECE 374 ECE 374 U. Tida 1 / 38
  • 2. Background Focus of this lecture ECE 374 U. Tida 2 / 38
  • 3. Background Introduction CPU performance factors Instruction count ? Determined by ISA and Compiler CPI and Cycle time ? Determined by CPU hardware Implementations Covered MIPS (Microprocessor without Interlocked Pipelined Stages) implementations A simplified version An improved version by pipelining technique Instructions covered for MIPS implementation Memory reference: lw, sw Arithmetic/logical: add, sub, and, or, slt Control transfer: beq, j ECE 374 U. Tida 3 / 38
  • 4. Background Instruction Execution Procedure 1 PC (program counter) → instruction memory, fetch instruction 2 Register numbers → register file, read 3 Instruction determines ALU to calculate: Arithmetic/logic result Memory address for load/store Branch target address 4 Access data memory for load/store or write to register 5 PC ← target address or PC+4 ECE 374 U. Tida 4 / 38
  • 6. Background CPU Overview We cannot join wires together and expect it to select whatever we need by itself. Use multiplexer to select between data ECE 374 U. Tida 6 / 38
  • 7. Background Control The blue circuitry (control logic) determines instruction execution. ECE 374 U. Tida 7 / 38
  • 8. Background Logic Design Logic Design Basics Binary Encoded Information Two states: Low voltage = 0 and High voltage = 1. (Traditional method) One wire per bit Multi-bit data encoded on multi-wire buses Combinational Element Operate on data continuously Output is a function of input State (Sequential Element Store information for a certain period ECE 374 U. Tida 8 / 38
  • 9. Background Logic Design Typical Combinational Elements Given a set of inputs, it always produces the same output AND-gate Y = A & B Adder Y = A + B Multiplexer Y = S ? I1 : I0 Arithmetic Logical Unit (ALU) Y = F(A , B) ECE 374 U. Tida 9 / 38
  • 10. Background Logic Design Sequential Element Register: Stores data in a circuit Clock signal determines when to update the stored value Edge-triggered flip flop: update data when clk changes 0 to 1 =⇒ positive triggered (1 to 0 =⇒ negative triggered) ECE 374 U. Tida 10 / 38
  • 11. Background Logic Design Sequential Element with write control Register with write control Only updates on clock edge when write control input is 1 ECE 374 U. Tida 11 / 38
  • 12. Background Logic Design Maximum clock speed Combinational logic transforms data between clock edges Longest delay for data to travel [input state element → combinational logic → output state element] determines clock period ECE 374 U. Tida 12 / 38
  • 13. Datapath Design Datapath Design Approach Datapath design Design of elements that process data and addresses (of data memory and instruction memory) in the CPU Consists of Registers, ALU, Mux’s, memories, ... Approach Let’s start with one set of instructions and include rest systematically by refining the overall design of previous step. Instruction-set Design Sequence we follow 1 R-format instructions 2 I-format instructions 3 J-format instructions ECE 374 U. Tida 13 / 38
  • 14. Datapath Design Step 1: Instruction Fetch Program Counter (PC) Register Holds address of the current instruction Increment by 4 after each fetch! Common step for all instruction type execution ECE 374 U. Tida 14 / 38
  • 15. Datapath Design R-format Datapath design for R-type instructions Register format (R-format) Instruction Fields: op: operation code or opcode of an instruction. rs: first source register number (READ) rt: second source register number (READ) rd: destination register number (WRITE) shamt: shift amount funct: function code ECE 374 U. Tida 15 / 38
  • 16. Datapath Design R-format Step 2: Read registers R-format instruction has two register addresses of a register file and this information is used to read the two registers simulataneously! ECE 374 U. Tida 16 / 38
  • 17. Datapath Design R-format Step 3: Perform operation The register read in Step 2 will be given to the ALU to perform the required opeartion! ECE 374 U. Tida 17 / 38
  • 18. Datapath Design R-format Step 4: Write back result ALU result will be stored in the destination register RegWrite is a control signal that will be high almost at the end of clock cycle! ECE 374 U. Tida 18 / 38
  • 19. Datapath Design I-format Datapath design extension to include I-format instructions Immediate format (I-format) Instruction Fields: op: operation code or opcode of an instruction. Determined by the hardware control rs: first source register number (READ) rt: destination register number (READ (SW)/WRITE (LW)) constant: 16 bit size address: 16 bit offset added to base address in rs Different formats complicate decoding but allow 32-bit instructions uniformly. ECE 374 U. Tida 19 / 38
  • 20. Datapath Design I-format Step 2: Read registers Two reads occur for sw instruction and only one read occurs for lw instruction ECE 374 U. Tida 20 / 38
  • 21. Datapath Design I-format Step 3: Address calculation The register read in Step 2 will be given to the ALU to perform the required opeartion! ECE 374 U. Tida 21 / 38
  • 22. Datapath Design I-format Step 4: Access memory: (Write for sw and Read for lw) ECE 374 U. Tida 22 / 38
  • 23. Datapath Design I-format Step 5: Write back result Data in memory will be stored in the destination register ECE 374 U. Tida 23 / 38
  • 24. Datapath Design I-format Putting all together for R-type and Memory instructions! ECE 374 U. Tida 24 / 38
  • 25. Datapath Design I-format How about conditional branch (beq)? ECE 374 U. Tida 25 / 38
  • 26. Datapath Design I-format Putting all together for R-type and I-type instructions! ECE 374 U. Tida 26 / 38
  • 27. Control circuitry Think of controlling the circuit ECE 374 U. Tida 27 / 38
  • 28. Control circuitry ALU operation Utilize it for 1 Addition in Load/Store instructions for memory address calculation 2 Subtraction in branch if equal (beq) instruction 3 Operation depending on funct field for R-type instructions! ALU operation (4-bit) Function 0000 AND 0001 OR 0010 add 0110 subtract 0111 set-on-less-than 1100 NOR ECE 374 U. Tida 28 / 38
  • 29. Control circuitry ALU control ALU operation (4-bits) are set depending on opcode and funct bits Since there are only 4 different opcodes possible i.e., lw, sw, beq and R-type, we can assume 2 ALUOp bits derived from opcode We will design a combination logic circuits based on truth table to obtain ALU operation bits inst ALUOp Operation funct ALU function ALU operation lw 00 load word XXXXXX add 0010 sw 00 load word XXXXXX add 0010 beq 01 branch if equal XXXXXX subtract 0110 R-type 10 add 100000 add 0010 subtract 100010 subtract 0110 AND 100100 AND 0000 OR 100101 OR 0001 set on less than 101010 set on less than 0111 ECE 374 U. Tida 29 / 38
  • 30. Control circuitry Main control circuit from instruction register Control signals are derived from instruction register! ECE 374 U. Tida 30 / 38
  • 31. Datapath and control: Processor Datapath with control ECE 374 U. Tida 31 / 38
  • 32. Datapath and control: Processor Datapath and control of R-type instruction ECE 374 U. Tida 32 / 38
  • 33. Datapath and control: Processor Datapath and control of load instruction ECE 374 U. Tida 33 / 38
  • 34. Datapath and control: Processor Datapath and control of branch-on-equal instruction ECE 374 U. Tida 34 / 38
  • 35. Datapath and control: Processor How about Unconditional Jump (j)? Jump uses word address Update PC with concatenation of ? Top 4-bit of old PC ? 26-bit jump address ? 00 (multiply by 4) Need an extra control signal decoded from opcode ECE 374 U. Tida 35 / 38
  • 36. Datapath and control: Processor Datapath and control with Jumps added ECE 374 U. Tida 36 / 38
  • 37. Datapath and control: Processor Performance metric and issues Longest delay determines clock period Critical path: load instruction ? Instruction memory → Register file → ALU → Data memory → Register file What happens if the frequency of load instruction is low? We can improve performance by pipelining (will be covered in next lecture series!) Sincere suggestion: Revise the lecture slides, clear doubts, practice many problems, prepare to become a computer engineer! ECE 374 U. Tida 37 / 38
  • 38. What have we learnt today? 1 Background Logic Design 2 Datapath Design R-format I-format 3 Control circuitry 4 Datapath and control: Processor ECE 374 U. Tida 38 / 38