SlideShare a Scribd company logo
1 of 47
Unit 3
Processor and Control Unit
1
A Basic MIPS Implementation
2
•
•
We're ready to look at an implementation of the MIPS
Simplified to contain only:
–
–
–
memory-reference instructions: lw, sw
arithmetic-logical instructions: add, sub, and, or, slt
control flow instructions: beq, j
• Generic Implementation:
– use the program counter (PC) to supply instruction address
– get the instruction from memory
– read registers
– use the instruction to decide exactly what to do
• All instructions use the ALU after reading the registers
Why? memory-reference? arithmetic? control flow?
5.1 Introduction
• Memory Reference Instruction uses
the ALU for an Address Calculation.
• ALU Reference Instruction uses the
ALU for the Operation Execution.
• Branch Instruction uses ALU for
Comparison.
• A memory Reference Instruction has access the memory
either to read data for a load (or) write data for store.
• An ALU Instruction (or) Load Instruction has to write the
data from ALU (or) memory back in to register.
• Finally for branch instruction, we may need to change the
next instruction address based on the comparison,
otherwise we have to increment the PC by 4 to get the
address of the next instruction.
An Overview of the Implementation
• For most instructions: fetch instruction, fetch operands, execute,
store.
•
5
Missing Multiplexers, and some Control lines for read and write.
4
An Overview of the Implementation
• The program counter gives the instruction address to the instruction
memory.
• After the instruction is fetched ,the register operands required by an
instruction are specified by fields of that instruction.
Once the register operands have been fetched, they can be used to
compute a memory address( for a load and store), to compute an
arithmetic result( for an integer arithmetic-logical instruction) or a
compare(for a branch).
If the instruction is an arithmetic-logical instruction, the result from the
ALU must be written to a register.
If the operation is a load or store, the ALU result is used as an address to
either store a value from memory into the registers. The result from the
ALU or memory is written back into the register file.
Branches require the use of the ALU output to determine the next
instruction address which comes either from the ALU( where the PC and
branch offset are summed) or from an adder that increments the current
•
•
•
•
PC by 4.
5
Continue
• The basic implementation of the MIPS subset including the necessary
multiplexers and control lines.
• Multiplexer (data selector) selects from among several inputs based on
the setting of its control lines. The control lines are set based on
information taken from the instruction being executed.
5.3 Building a Datapath
• Datapath
– Elements that process data and addresses within the CPU
• Register file, ALUs, Adders, Instruction and Data
Memories, …
We need functional units (datapath elements) for:
1. Fetching instructions and incrementing the PC.
2. Execute arithmetic-logical instructions: add, sub, and, or, and slt
3. Execute memory-reference instructions: lw, sw
4. Execute branch/jump instructions: beq, j
1. Fetching instructions and incrementing the PC.
8
Continue
registers, perform an ALU operation
the registers and write the result
on the contents
to the register.
2. Execute arithmetic-logical instructions: add, sub, and, or, and slt
The arithmetic logic instructions read operands from two
of
So
this instructions as R-type instructions.
add $t1, $t2, $t3 # t1 = t2 + t3
9
Continue
3. Execute memory-reference instructions: lw, sw
lw $t1, offset_value($t2)
sw $t1, offset_value($t2)
10
4. Execute branch/jump instructions: beq, j
beq $t1, $t2, offset
11
Creating a Single Datapath
• Sharing datapath elements between two different instruction classes ,
we have connected multiple connections to the input of an element and
used a multiplexer and control signals to select among the multiple
inputs.
12
Continue
Now we con combine all the pieces to make a simple datapath
for the MIPS architecture:
13
5.4 A Simple Control Implementation
Scheme
The ALU Control
14
Designing the Main Control Unit
15
Continue
16
Continue
17
Finalizing the Control
18
Continue
19
Continue
20
Example: Implementing Jumps
21
Why a Single-Cycle Implementation Is Not Used Today
22
Example: Performance of Single-Cycle Machines
Calculate cycle time assuming negligible delays except:
–
–
–
memory (200ps),
ALU and adders (100ps),
register file access (50ps)
Which of the following implementation would be faster:
1. When every instruction operates in 1 clock cycle of fixes length.
2. When every instruction executes in 1 clock cycle using a variable-length
clock.
To compare the performance, assume the following instruction mix:
25% loads
10% stores
45% ALU instructions
15% branches, and
5% jumps
21
Continue
CPU clock cycle (option 1) = 600 ps.
CPU clock cycle (option 2) = 400 45% + 60025% + 550 10% + 350 15% + 2005%
= 447.5 ps.
Performance ratio = 1.34
447.5
600
45% ALU instructions
25% loads
10% stores
15% branches, and
5% jumps
memory (200ps),
ALU and adders (100ps),
register file access (50ps)
5.5 A Multicycle Implementation
•
•
•
A single memory unit is used for both instructions and data.
There is a single ALU, rather than an ALU and two adders.
One or more registers are added after every major functional unit.
24
Continue
Replacing the three ALUs of the single-cycle by a single ALU means that the
single ALU must accommodate all the inputs that used to go to the three
different ALUs.
25
Continue
26
Continue
27
Continue
28
Breaking the Instruction Execution into Clock Cycles
29
1. Instruction fetch step
IR <= Memory[PC];
PC <= PC + 4;
Breaking the Instruction Execution into Clock Cycles
IR <= Memory[PC];
To do this, we need:
MemRead ➔Assert
IRWrite ➔ Assert
IorD ➔ 0
-------------------------------
PC <= PC + 4;
ALUSrcA ➔ 0
ALUSrcB ➔ 01
ALUOp ➔ 00 (for add)
PCSource ➔ 00
PCWrite ➔ set
The increment of the PC and instruction memory access can occur in parallel, how?
30
Breaking the Instruction Execution into Clock Cycles
31
2. Instruction decode and register fetch step
–
–
Actions that are either applicable to all instructions
Or are not harmful
A <= Reg[IR[25:21]];
B <= Reg[IR[20:16]];
ALUOut <= PC + (sign-extend(IR[15-0] << 2 );
A <= Reg[IR[25:21]];
B <= Reg[IR[20:16]];
Since A and B are
overwritten on every
cycle ➔ Done
ALUOut <= PC + (sign-
extend(IR[15-0]<<2);
This requires:
ALUSrcA ➔ 0
ALUSrcB ➔ 11
ALUOp ➔ 00 (for add)
branch target address will
be stored in ALUOut.
The register file access and computation of branch target occur in parallel.
32
Breaking the Instruction Execution into Clock Cycles
33
3. Execution, memory address computation, or branch completion
Memory reference:
ALUOut <= A + sign-extend(IR[15:0]);
Arithmetic-logical instruction:
ALUOut <= A op B;
Branch:
if (A == B) PC <= ALUOut;
Jump:
PC <= { PC[31:28], (IR[25:0], 2’b00) };
Memory reference:
ALUOut <= A + sign-extend(IR[15:0]);
ALUSrcA = 1 && ALUSrcB = 10
ALUOp = 00
Arithmetic-logical instruction:
ALUOut <= A op B;
ALUSrcA = 1 && ALUSrcB = 00
ALUOp = 10
Branch:
if (A == B) PC <= ALUOut;
ALUSrcA = 1 && ALUSrcB = 00
ALUOp = 01 (for subtraction)
PCSource = 01
PCWriteCond is asserted
Jump:
PC <= { PC[31:28], (IR[25:0],2’b00) };
PCWrite is asserted
PCSource = 10
34
Breaking the Instruction Execution into Clock Cycles
35
4. Memory access or R-type instruction completion step
Memory reference:
MDR <= Memory [ALUOut];
or
Memory [ALUOut] <= B;
 MemRead, IorD=1
 MemWrite, IorD=1
Arithmetic-logical instruction (R-type):
Reg[IR[15:11]] <= ALUOut;  RegDst=1,RegWrite, MemtoReg=0
5. Memory read completion step
Load:
Reg[IR[20:16]] <= MDR;  RegDst=0, RegWrite, MemtoReg=1
Breaking the Instruction Execution into Clock Cycles
36
Continue
Summary of the steps taken to execute any instruction class
37
Defining the Control
Two different techniques to specify the control:
–
–
Finite state machine
Microprogramming
Example: CPI in a Multicycle CPU
Using the SPECINT2000 instruction mix, which is: 25% load, 10% store, 11%
branches, 2% jumps, and 52% ALU.
What is the CPI, assuming that each state in the multicycle CPU requires 1
clock cycle?
Answer:
The number of clock cycles for each instruction class is the following:
▪
▪
▪
▪
▪
Load: 5 25%
Stores: 4 10%
ALU instruction: 4 52%
Branches: 3 11%
Jumps: 3 2%
38
Example Continue
The CPI is given by the following:
CPI 
CPU clock cycles
 Instruction counti CPIi
Instruction count Instruction count
Instruction count
The ratio
Instruction counti
Instruction count
is simply the instruction frequency for the instruction class i. We can therefore
substitute to obtain:
CPI = 0.255 + 0.104 + 0.524 + 0.113 + 0.023 = 4.12
This CPI is better than the worst-case CPI of 5.0 when all instructions take the
same number of clock cycles.
CPI   Instruction counti
i
CPI
39
Defining the Control (Continue)
40
Defining the Control (Continue)
The complete finite state machine control
41
Defining the Control (Continue)
• Finite state machine controllers are typically implemented using a
block of combinational logic and a register to hold the current state.
42
5.6 Exceptions
43
•
•
Exceptions
Interrupts
Type of event From where? MIPS terminology
I/O device request
Invoke the operating system from user
program
Arithmetic overflow
Using an undefined instruction
Hardware malfunction
External Interrupt
Internal Exception
Internal
Internal
Either
Exception
Exception
Exception or interrupt
How Exception Are Handled
44
To communicate the reason for an exception:
1. a status register ( called the Cause register)
2. vectored interrupts
Exception type Exception vector address (in hex)
Undefined instruction
Arithmetic overflow
C000 0000hex
C000 0020hex
How Control Checks for Exception
45
Assume two possible exceptions:
▪
▪
Undefined instruction
Arithmetic overflow
Continue
The multicycle datapath with the addition needed to implement exceptions
46
Continue
The finite state machine with the additions to handle exception detection
47

More Related Content

Similar to MIPS IMPLEMENTATION.pptx

Hennchthree 161102111515
Hennchthree 161102111515Hennchthree 161102111515
Hennchthree 161102111515marangburu42
 
Pipelining of Processors Computer Architecture
Pipelining of  Processors Computer ArchitecturePipelining of  Processors Computer Architecture
Pipelining of Processors Computer ArchitectureHaris456
 
Unit 2 ca- control unit
Unit 2 ca- control unitUnit 2 ca- control unit
Unit 2 ca- control unitBBDITM LUCKNOW
 
Control unit design
Control unit designControl unit design
Control unit designDhaval Bagal
 
Computer architecture
Computer architectureComputer architecture
Computer architectureneclinux
 
Compuer organizaion processing unit
Compuer organizaion processing unitCompuer organizaion processing unit
Compuer organizaion processing unitDeepak John
 
Operating system
Operating systemOperating system
Operating systemraj732723
 
Computer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationComputer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationAmrutaMehata
 
Pipelining And Vector Processing
Pipelining And Vector ProcessingPipelining And Vector Processing
Pipelining And Vector ProcessingTheInnocentTuber
 
Pipelining in Computer System Achitecture
Pipelining in Computer System AchitecturePipelining in Computer System Achitecture
Pipelining in Computer System AchitectureYashiUpadhyay3
 
computer architecture
computer architecturecomputer architecture
computer architecturePandiya Rajan
 
Design pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelinesDesign pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelinesMahmudul Hasan
 
Basic computer organization and design
Basic computer organization and designBasic computer organization and design
Basic computer organization and designmahesh kumar prajapat
 
Pipelining and vector processing
Pipelining and vector processingPipelining and vector processing
Pipelining and vector processingKamal Acharya
 
Basic structure of computers by aniket bhute
Basic structure of computers by aniket bhuteBasic structure of computers by aniket bhute
Basic structure of computers by aniket bhuteAniket Bhute
 
20IT204-COA- Lecture 17.pptx
20IT204-COA- Lecture 17.pptx20IT204-COA- Lecture 17.pptx
20IT204-COA- Lecture 17.pptxPerumalPitchandi
 

Similar to MIPS IMPLEMENTATION.pptx (20)

Hennchthree
HennchthreeHennchthree
Hennchthree
 
Hennchthree 161102111515
Hennchthree 161102111515Hennchthree 161102111515
Hennchthree 161102111515
 
Pipelining of Processors Computer Architecture
Pipelining of  Processors Computer ArchitecturePipelining of  Processors Computer Architecture
Pipelining of Processors Computer Architecture
 
Unit 2 ca- control unit
Unit 2 ca- control unitUnit 2 ca- control unit
Unit 2 ca- control unit
 
Control unit design
Control unit designControl unit design
Control unit design
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
Unit iii
Unit iiiUnit iii
Unit iii
 
Compuer organizaion processing unit
Compuer organizaion processing unitCompuer organizaion processing unit
Compuer organizaion processing unit
 
Operating system
Operating systemOperating system
Operating system
 
Computer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationComputer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organization
 
Pipelining And Vector Processing
Pipelining And Vector ProcessingPipelining And Vector Processing
Pipelining And Vector Processing
 
Chapter 8
Chapter 8Chapter 8
Chapter 8
 
Pipelining in Computer System Achitecture
Pipelining in Computer System AchitecturePipelining in Computer System Achitecture
Pipelining in Computer System Achitecture
 
computer architecture
computer architecturecomputer architecture
computer architecture
 
CA UNIT III.pptx
CA UNIT III.pptxCA UNIT III.pptx
CA UNIT III.pptx
 
Design pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelinesDesign pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelines
 
Basic computer organization and design
Basic computer organization and designBasic computer organization and design
Basic computer organization and design
 
Pipelining and vector processing
Pipelining and vector processingPipelining and vector processing
Pipelining and vector processing
 
Basic structure of computers by aniket bhute
Basic structure of computers by aniket bhuteBasic structure of computers by aniket bhute
Basic structure of computers by aniket bhute
 
20IT204-COA- Lecture 17.pptx
20IT204-COA- Lecture 17.pptx20IT204-COA- Lecture 17.pptx
20IT204-COA- Lecture 17.pptx
 

More from JEEVANANTHAMG6

Introduction to NodeJS JSX is an extended Javascript based language used by R...
Introduction to NodeJS JSX is an extended Javascript based language used by R...Introduction to NodeJS JSX is an extended Javascript based language used by R...
Introduction to NodeJS JSX is an extended Javascript based language used by R...JEEVANANTHAMG6
 
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptxJEEVANANTHAMG6
 
7. Input Output Operations.pptx
7. Input Output Operations.pptx7. Input Output Operations.pptx
7. Input Output Operations.pptxJEEVANANTHAMG6
 
CLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptxCLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptxJEEVANANTHAMG6
 
Arithmetic for Computers.ppt
Arithmetic for Computers.pptArithmetic for Computers.ppt
Arithmetic for Computers.pptJEEVANANTHAMG6
 
6. Addressng Modes.pptx
6. Addressng Modes.pptx6. Addressng Modes.pptx
6. Addressng Modes.pptxJEEVANANTHAMG6
 
1.Basic Structure of Computer System.ppt
1.Basic Structure of Computer System.ppt1.Basic Structure of Computer System.ppt
1.Basic Structure of Computer System.pptJEEVANANTHAMG6
 

More from JEEVANANTHAMG6 (9)

Introduction to NodeJS JSX is an extended Javascript based language used by R...
Introduction to NodeJS JSX is an extended Javascript based language used by R...Introduction to NodeJS JSX is an extended Javascript based language used by R...
Introduction to NodeJS JSX is an extended Javascript based language used by R...
 
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
 
7. Input Output Operations.pptx
7. Input Output Operations.pptx7. Input Output Operations.pptx
7. Input Output Operations.pptx
 
EITK UNIT - III.pptx
EITK UNIT - III.pptxEITK UNIT - III.pptx
EITK UNIT - III.pptx
 
CLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptxCLEAN CODING AND DEVOPS Final.pptx
CLEAN CODING AND DEVOPS Final.pptx
 
UNIT I.ppt
UNIT I.pptUNIT I.ppt
UNIT I.ppt
 
Arithmetic for Computers.ppt
Arithmetic for Computers.pptArithmetic for Computers.ppt
Arithmetic for Computers.ppt
 
6. Addressng Modes.pptx
6. Addressng Modes.pptx6. Addressng Modes.pptx
6. Addressng Modes.pptx
 
1.Basic Structure of Computer System.ppt
1.Basic Structure of Computer System.ppt1.Basic Structure of Computer System.ppt
1.Basic Structure of Computer System.ppt
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
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.pptxvipinkmenon1
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Recently uploaded (20)

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
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
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 

MIPS IMPLEMENTATION.pptx

  • 1. Unit 3 Processor and Control Unit 1
  • 2. A Basic MIPS Implementation 2 • • We're ready to look at an implementation of the MIPS Simplified to contain only: – – – memory-reference instructions: lw, sw arithmetic-logical instructions: add, sub, and, or, slt control flow instructions: beq, j • Generic Implementation: – use the program counter (PC) to supply instruction address – get the instruction from memory – read registers – use the instruction to decide exactly what to do • All instructions use the ALU after reading the registers Why? memory-reference? arithmetic? control flow? 5.1 Introduction
  • 3. • Memory Reference Instruction uses the ALU for an Address Calculation. • ALU Reference Instruction uses the ALU for the Operation Execution. • Branch Instruction uses ALU for Comparison.
  • 4. • A memory Reference Instruction has access the memory either to read data for a load (or) write data for store. • An ALU Instruction (or) Load Instruction has to write the data from ALU (or) memory back in to register. • Finally for branch instruction, we may need to change the next instruction address based on the comparison, otherwise we have to increment the PC by 4 to get the address of the next instruction.
  • 5. An Overview of the Implementation • For most instructions: fetch instruction, fetch operands, execute, store. • 5 Missing Multiplexers, and some Control lines for read and write.
  • 6. 4 An Overview of the Implementation • The program counter gives the instruction address to the instruction memory. • After the instruction is fetched ,the register operands required by an instruction are specified by fields of that instruction. Once the register operands have been fetched, they can be used to compute a memory address( for a load and store), to compute an arithmetic result( for an integer arithmetic-logical instruction) or a compare(for a branch). If the instruction is an arithmetic-logical instruction, the result from the ALU must be written to a register. If the operation is a load or store, the ALU result is used as an address to either store a value from memory into the registers. The result from the ALU or memory is written back into the register file. Branches require the use of the ALU output to determine the next instruction address which comes either from the ALU( where the PC and branch offset are summed) or from an adder that increments the current • • • • PC by 4.
  • 7. 5 Continue • The basic implementation of the MIPS subset including the necessary multiplexers and control lines. • Multiplexer (data selector) selects from among several inputs based on the setting of its control lines. The control lines are set based on information taken from the instruction being executed.
  • 8. 5.3 Building a Datapath • Datapath – Elements that process data and addresses within the CPU • Register file, ALUs, Adders, Instruction and Data Memories, … We need functional units (datapath elements) for: 1. Fetching instructions and incrementing the PC. 2. Execute arithmetic-logical instructions: add, sub, and, or, and slt 3. Execute memory-reference instructions: lw, sw 4. Execute branch/jump instructions: beq, j 1. Fetching instructions and incrementing the PC. 8
  • 9. Continue registers, perform an ALU operation the registers and write the result on the contents to the register. 2. Execute arithmetic-logical instructions: add, sub, and, or, and slt The arithmetic logic instructions read operands from two of So this instructions as R-type instructions. add $t1, $t2, $t3 # t1 = t2 + t3 9
  • 10. Continue 3. Execute memory-reference instructions: lw, sw lw $t1, offset_value($t2) sw $t1, offset_value($t2) 10
  • 11. 4. Execute branch/jump instructions: beq, j beq $t1, $t2, offset 11
  • 12. Creating a Single Datapath • Sharing datapath elements between two different instruction classes , we have connected multiple connections to the input of an element and used a multiplexer and control signals to select among the multiple inputs. 12
  • 13. Continue Now we con combine all the pieces to make a simple datapath for the MIPS architecture: 13
  • 14. 5.4 A Simple Control Implementation Scheme The ALU Control 14
  • 15. Designing the Main Control Unit 15
  • 22. Why a Single-Cycle Implementation Is Not Used Today 22 Example: Performance of Single-Cycle Machines Calculate cycle time assuming negligible delays except: – – – memory (200ps), ALU and adders (100ps), register file access (50ps) Which of the following implementation would be faster: 1. When every instruction operates in 1 clock cycle of fixes length. 2. When every instruction executes in 1 clock cycle using a variable-length clock. To compare the performance, assume the following instruction mix: 25% loads 10% stores 45% ALU instructions 15% branches, and 5% jumps
  • 23. 21 Continue CPU clock cycle (option 1) = 600 ps. CPU clock cycle (option 2) = 400 45% + 60025% + 550 10% + 350 15% + 2005% = 447.5 ps. Performance ratio = 1.34 447.5 600 45% ALU instructions 25% loads 10% stores 15% branches, and 5% jumps memory (200ps), ALU and adders (100ps), register file access (50ps)
  • 24. 5.5 A Multicycle Implementation • • • A single memory unit is used for both instructions and data. There is a single ALU, rather than an ALU and two adders. One or more registers are added after every major functional unit. 24
  • 25. Continue Replacing the three ALUs of the single-cycle by a single ALU means that the single ALU must accommodate all the inputs that used to go to the three different ALUs. 25
  • 29. Breaking the Instruction Execution into Clock Cycles 29 1. Instruction fetch step IR <= Memory[PC]; PC <= PC + 4;
  • 30. Breaking the Instruction Execution into Clock Cycles IR <= Memory[PC]; To do this, we need: MemRead ➔Assert IRWrite ➔ Assert IorD ➔ 0 ------------------------------- PC <= PC + 4; ALUSrcA ➔ 0 ALUSrcB ➔ 01 ALUOp ➔ 00 (for add) PCSource ➔ 00 PCWrite ➔ set The increment of the PC and instruction memory access can occur in parallel, how? 30
  • 31. Breaking the Instruction Execution into Clock Cycles 31 2. Instruction decode and register fetch step – – Actions that are either applicable to all instructions Or are not harmful A <= Reg[IR[25:21]]; B <= Reg[IR[20:16]]; ALUOut <= PC + (sign-extend(IR[15-0] << 2 );
  • 32. A <= Reg[IR[25:21]]; B <= Reg[IR[20:16]]; Since A and B are overwritten on every cycle ➔ Done ALUOut <= PC + (sign- extend(IR[15-0]<<2); This requires: ALUSrcA ➔ 0 ALUSrcB ➔ 11 ALUOp ➔ 00 (for add) branch target address will be stored in ALUOut. The register file access and computation of branch target occur in parallel. 32
  • 33. Breaking the Instruction Execution into Clock Cycles 33 3. Execution, memory address computation, or branch completion Memory reference: ALUOut <= A + sign-extend(IR[15:0]); Arithmetic-logical instruction: ALUOut <= A op B; Branch: if (A == B) PC <= ALUOut; Jump: PC <= { PC[31:28], (IR[25:0], 2’b00) };
  • 34. Memory reference: ALUOut <= A + sign-extend(IR[15:0]); ALUSrcA = 1 && ALUSrcB = 10 ALUOp = 00 Arithmetic-logical instruction: ALUOut <= A op B; ALUSrcA = 1 && ALUSrcB = 00 ALUOp = 10 Branch: if (A == B) PC <= ALUOut; ALUSrcA = 1 && ALUSrcB = 00 ALUOp = 01 (for subtraction) PCSource = 01 PCWriteCond is asserted Jump: PC <= { PC[31:28], (IR[25:0],2’b00) }; PCWrite is asserted PCSource = 10 34
  • 35. Breaking the Instruction Execution into Clock Cycles 35 4. Memory access or R-type instruction completion step Memory reference: MDR <= Memory [ALUOut]; or Memory [ALUOut] <= B;  MemRead, IorD=1  MemWrite, IorD=1 Arithmetic-logical instruction (R-type): Reg[IR[15:11]] <= ALUOut;  RegDst=1,RegWrite, MemtoReg=0 5. Memory read completion step Load: Reg[IR[20:16]] <= MDR;  RegDst=0, RegWrite, MemtoReg=1
  • 36. Breaking the Instruction Execution into Clock Cycles 36
  • 37. Continue Summary of the steps taken to execute any instruction class 37
  • 38. Defining the Control Two different techniques to specify the control: – – Finite state machine Microprogramming Example: CPI in a Multicycle CPU Using the SPECINT2000 instruction mix, which is: 25% load, 10% store, 11% branches, 2% jumps, and 52% ALU. What is the CPI, assuming that each state in the multicycle CPU requires 1 clock cycle? Answer: The number of clock cycles for each instruction class is the following: ▪ ▪ ▪ ▪ ▪ Load: 5 25% Stores: 4 10% ALU instruction: 4 52% Branches: 3 11% Jumps: 3 2% 38
  • 39. Example Continue The CPI is given by the following: CPI  CPU clock cycles  Instruction counti CPIi Instruction count Instruction count Instruction count The ratio Instruction counti Instruction count is simply the instruction frequency for the instruction class i. We can therefore substitute to obtain: CPI = 0.255 + 0.104 + 0.524 + 0.113 + 0.023 = 4.12 This CPI is better than the worst-case CPI of 5.0 when all instructions take the same number of clock cycles. CPI   Instruction counti i CPI 39
  • 40. Defining the Control (Continue) 40
  • 41. Defining the Control (Continue) The complete finite state machine control 41
  • 42. Defining the Control (Continue) • Finite state machine controllers are typically implemented using a block of combinational logic and a register to hold the current state. 42
  • 43. 5.6 Exceptions 43 • • Exceptions Interrupts Type of event From where? MIPS terminology I/O device request Invoke the operating system from user program Arithmetic overflow Using an undefined instruction Hardware malfunction External Interrupt Internal Exception Internal Internal Either Exception Exception Exception or interrupt
  • 44. How Exception Are Handled 44 To communicate the reason for an exception: 1. a status register ( called the Cause register) 2. vectored interrupts Exception type Exception vector address (in hex) Undefined instruction Arithmetic overflow C000 0000hex C000 0020hex
  • 45. How Control Checks for Exception 45 Assume two possible exceptions: ▪ ▪ Undefined instruction Arithmetic overflow
  • 46. Continue The multicycle datapath with the addition needed to implement exceptions 46
  • 47. Continue The finite state machine with the additions to handle exception detection 47