Computer Architecture Experiment Lab2

Similar documents
Computer Architecture Experiment

Computer Architecture Experiment

ECS 154B Computer Architecture II Spring 2009

CPE 335. Basic MIPS Architecture Part II

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours.

Processor: Multi- Cycle Datapath & Control

Major CPU Design Steps

Computer Architecture Experiment

Chapter 4 The Processor 1. Chapter 4A. The Processor

Systems Architecture I

COSC 6385 Computer Architecture - Pipelining

CC 311- Computer Architecture. The Processor - Control

ALUOut. Registers A. I + D Memory IR. combinatorial block. combinatorial block. combinatorial block MDR

Pipeline Overview. Dr. Jiang Li. Adapted from the slides provided by the authors. Jiang Li, Ph.D. Department of Computer Science

Topic #6. Processor Design

Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle

COMP2611: Computer Organization. The Pipelined Processor

Adding Support for jal to Single Cycle Datapath (For More Practice Exercise 5.20)

CSE 2021 COMPUTER ORGANIZATION

Data Hazards Compiler Scheduling Pipeline scheduling or instruction scheduling: Compiler generates code to eliminate hazard

Computer and Information Sciences College / Computer Science Department Enhancing Performance with Pipelining

Computer Architecture

Pipeline design. Mehran Rezaei

Pipelining. Pipeline performance

ECE154A Introduction to Computer Architecture. Homework 4 solution

Lecture 9. Pipeline Hazards. Christos Kozyrakis Stanford University

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1

CPE 335 Computer Organization. Basic MIPS Architecture Part I

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination

EI338: Computer Systems and Engineering (Computer Architecture & Operating Systems)

University of Jordan Computer Engineering Department CPE439: Computer Design Lab

CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19

CPE 335 Computer Organization. Basic MIPS Pipelining Part I

LECTURE 6. Multi-Cycle Datapath and Control

Points available Your marks Total 100

CSE 2021 COMPUTER ORGANIZATION

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

Pipelining! Advanced Topics on Heterogeneous System Architectures. Politecnico di Milano! Seminar DEIB! 30 November, 2017!

Computer Organization and Structure

RISC Processor Design

Computer Science 141 Computing Hardware

Pipelining Analogy. Pipelined laundry: overlapping execution. Parallelism improves performance. Four loads: Non-stop: Speedup = 8/3.5 = 2.3.

EE557--FALL 1999 MAKE-UP MIDTERM 1. Closed books, closed notes

RISC Architecture: Multi-Cycle Implementation

CS232 Final Exam May 5, 2001

ECEC 355: Pipelining

Chapter 4. The Processor

Processor (multi-cycle)

Chapter 5 Solutions: For More Practice

Beyond Pipelining. CP-226: Computer Architecture. Lecture 23 (19 April 2013) CADSL

ECE260: Fundamentals of Computer Engineering

Chapter 5: The Processor: Datapath and Control

Lecture 3. Pipelining. Dr. Soner Onder CS 4431 Michigan Technological University 9/23/2009 1

Lecture 4: Review of MIPS. Instruction formats, impl. of control and datapath, pipelined impl.

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor.

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

RISC Architecture: Multi-Cycle Implementation

ﻪﺘﻓﺮﺸﻴﭘ ﺮﺗﻮﻴﭙﻣﺎﻛ يرﺎﻤﻌﻣ MIPS يرﺎﻤﻌﻣ data path and ontrol control

1 Hazards COMP2611 Fall 2015 Pipelined Processor

CISC 662 Graduate Computer Architecture Lecture 6 - Hazards

EE457. Note: Parts of the solutions are extracted from the solutions manual accompanying the text book.

Laboratory Pipeline MIPS CPU Design (2): 16-bits version

CS 61C Fall 2016 Guerrilla Section 4: MIPS CPU (Datapath & Control)

ECE 313 Computer Organization FINAL EXAM December 11, Multicycle Processor Design 30 Points

Design of Digital Circuits 2017 Srdjan Capkun Onur Mutlu (Guest starring: Frank K. Gürkaynak and Aanjhan Ranganathan)

Lecture 7 Pipelining. Peng Liu.

RISC Pipeline. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter 4.6

CS 61C Summer 2016 Guerrilla Section 4: MIPS CPU (Datapath & Control)

COMPUTER ORGANIZATION AND DESIGN

Perfect Student CS 343 Final Exam May 19, 2011 Student ID: 9999 Exam ID: 9636 Instructions Use pencil, if you have one. For multiple choice

Processor (II) - pipelining. Hwansoo Han

3/12/2014. Single Cycle (Review) CSE 2021: Computer Organization. Single Cycle with Jump. Multi-Cycle Implementation. Why Multi-Cycle?

ENE 334 Microprocessors

LECTURE 3: THE PROCESSOR

CENG 3420 Lecture 06: Datapath

ECE369. Chapter 5 ECE369

CSE 378 Midterm 2/12/10 Sample Solution

EE2011 Computer Organization Lecture 10: Enhancing Performance with Pipelining ~ Pipelined Datapath

CSE 2021: Computer Organization Fall 2010 Solution to Assignment # 3: Multicycle Implementation

COMPUTER ORGANIZATION AND DESIGN

Multi-cycle Approach. Single cycle CPU. Multi-cycle CPU. Requires state elements to hold intermediate values. one clock cycle or instruction

Lecture Topics. Announcements. Today: Data and Control Hazards (P&H ) Next: continued. Exam #1 returned. Milestone #5 (due 2/27)

Full Datapath. Chapter 4 The Processor 2

CS3350B Computer Architecture Quiz 3 March 15, 2018

Laboratory Single-Cycle MIPS CPU Design (3): 16-bits version One clock cycle per instruction

ECE331: Hardware Organization and Design

Using a Hardware Description Language to Design and Simulate a Processor 5.8

The MIPS Processor Datapath

ECE232: Hardware Organization and Design

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Data Paths and Microprogramming

ECE232: Hardware Organization and Design

Pipelined datapath Staging data. CS2504, Spring'2007 Dimitris Nikolopoulos

CPU Design Steps. EECC550 - Shaaban

CSEN 601: Computer System Architecture Summer 2014

Digital Design & Computer Architecture (E85) D. Money Harris Fall 2007

LECTURE 5. Single-Cycle Datapath and Control

EECE 417 Computer Systems Architecture

Transcription:

Computer Architecture Experiment Lab2 College of Computer Science & Engineering Zhejiang University

Topics 0 Lab instroduction Lab 1). Warmup Run you multiple-cycle CPU on 3E board. Try to add one new branch instruction. Lab 2). 5-stage pipelined CPU with 15 MIPS instructions (only required to execute in pipeline). Lab 3). Implementing "stall" when have hazards Lab 4). Implementing forwarding paths Lab 5). The whole CPU with 31 instructions. 1.2

Outline Experiment Purpose Experiment Task Basic Principle Operating Procedures Precaution 1.3

Experiment Purpose 1 Understand the principles of MC CPU Controller and datapath and master methods of MC CPU Controller and datapath design. Understand the principles of Datapath and master methods of Datapath design Understand the principles of MC CPU and master methods of MC CPU design master methods of program verification of CPU 1.4

Experiment Purpose 2 Understand the principles of Pipelined CPU Understand the basic units of Pipelined CPU Understand the working flow of 5-stages Master the method of simple Pipelined CPU master methods of program verification of simple Pipelined CPU 1.5

Experiment Task 1 Design the CPU Controller, Datapath, bring together the basic units into Multiplecycle CPU Verify the MC CPU with program and observe the execution of program 1.6

Experiment Task 2 Design the CPU Controller, and the Datapath of 5-stages Pipelined CPU 5 Stages Register File Memory (Instruction and Data) other basic units Verify the Pipelined CPU with program and observe the execution of program 1.7

15 common used MIPS instructions 1.8

Step1: CPU Controller 1.9

Output of CPU Controller Output Signal Meaning When 1 Meaning When 0 1 PCSrc[1:0] 00: PC + 4;01: Branch Instr.;10: jump Instr 2 WritePC Write PC Not Write PC 3 IorD Instruction Addr Data Addr. 4 WriteMem Write Mem. Not Write Mem. 5 Write DR Write Data. Reg Not Write Data. Reg 6 Write IR Write Instr. Reg Not Write Instr. Reg 7 MemToReg From Mem. To Reg From ALUOut To Reg 8 RegDest rd rt 9 ALUC ALU Controller Op 10 ALUSrcA Register rs PC 11 ALUSrcB Selection:00:Reg rt; 01:4; 10:Imm.; 11: branch Address 12 WriteA Write A Reg. Not Write A Reg. 13 WriteB Write B Reg. Not Write B Reg. 14 WriteC Write C Reg. Not Write C Reg. 15 WriteReg Write Reg. Not Write Reg. SF CA_2013Spring_Lab

The principle of CPU Controller(1) 1.11

The principle of CPU Controller(2) 1.12

The Datapath of Multiple-cycle CPU 1.13

Basic Units of Multiple-cycle CPU CPU Controller ALU and ALU Controller Register file Mem. (Instruction and Data together). others:register, sign-extend Unit, shifter, multiplexor 1.14

Memory Memory Dual Port Block Memory Port A: Read Only, Width: 32, Depth: 512 Port B: Read and Write, Read After Write Rising Edge Triggered 1.15

Multiple-cycle CPU Top Module memory x_memory(.addra(raddr),.addrb(waddr),.clka(clk),.clkb(clk),.dinb(b_data),.douta(mem_data),.web(write_mem)); ctrl x_ctrl(clk, rst, ir_data, zero,write_pc, iord, write_mem, write_dr, write_ir, memtoreg, regdst, pcsource, write_c, alu_ctrl, alu_srca, alu_srcb, write_a, write_b, write_reg, state_out, insn_type, insn_code, insn_stage); pcm x_pcm(clk, rst, alu_out, c_data, ir_data, pcsource, write_pc,pc); alu_wrapper x_alu_wrapper(a_data, b_data, ir_data, pc, alu_srca, alu_srcb, alu_ctrl, zero, alu_out); reg_wrapper x_reg_wrapper(clk, rst, ir_data, dr_data, c_data, memtoreg, regdst, write_reg, rdata_a, rdata_b, r6out); 1.16

Observation Info Input West Button: Step execute South Button: Reset Slide Button: Address of Register Output 0-7 Character of First line: Instruction Code 8 of First line : Space 9-10 of First line : Read Address 11 of First line : Space 12-13 of First line : Write Address 0/2/4/6 of Second line : state/type/code/stage 8-9 of Second line : PC 11-14 of Second line: Selected Register Content 1.17

Program for verification <0> lw r1, $20(r0); 0x8c01_0014 State:0,1,3,5,9 Type:3 Code:1 (LD) <1> lw r2, $21(r0); 0x8c02_0015 State:0,1,3,5,9 Type:3 Code:1 (LD) <2> add r3, r1, r2; 0x0022_1820 State:0,1,2,8 Type:1 Code:3 (AD) <3> sub r4, r1, r2; 0x0022_2022 State:0,1,2,8 Type:1 Code:4 (SU) <4> and r5, r3, r4; 0x0064_2824 State:0,1,2,8 Type:1 Code:5 (AN) <5> nor r6, r4, r5; 0x0085_3027 State:0,1,2,8 Type:1 Code: 6 (NO) <6> sw r6, $22(r0); 0x ac06_0016 State:0,1,4,7 Type:3 Code: 2 (ST) <7> J 0; 0x0800_0000 State:0,1 Type:2 Code:7 (JP) DataMem(20) = 0xbeef_0000 ; DataMem(21) =0x0000_beef ; 1.18

Precaution 1. Add Anti-Jitter 2. Finish the State Machine 3. Add Stage Status 1.19

Step2 Comparison of three CPUs work 1.20

Datapath of 5-stages Pipelined CPU 1 0 IF/ID ID/EX EX/MEM MEM/WB 4 add PC Instr. Mem. rs rt imm Reg. File Signextend ed 16 32 2 0 1 add A B zero result ALU Branch Taken Data Mem. 1 0 rd rt 0 1 1.21

The principle of Multiple-cycle CPU 1.22

Structural hazards -resource conflicts Structural hazards arise from resource conflicts when the hardware cannot support all possible combinations of instructions in simultaneous overlapped execution. Memory conflicts Register File conflicts Other units conflicts 1.23

How to resolve Structural hazards 1.24

Register File Register File Positive edge for transfer data for stages Negative edge for write operation Low level for read operation 1.25

Memory Instruction Memory Single Port Block Memory Read only, Width:32 Falling Edge Triggered Data Memory Single Port Block Memory Read and write, Width:32 Falling Edge Triggered 1.26

The principle of Pipelined CPU-with CPU controller 1.27

Output of CPU Controller Output Signal Meaning When 1 Meaning When 0 1 Cu_branch Branch Instr. Non-Branch Instr. 2 Cu_shift sa Register data1 3 Cu_wmem Write Mem. Not Write Mem. 4 Cu_Mem2Reg From Mem. To Reg From ALUOut To Reg 5 Cu_sext Sign-extend the imm. No sign extended the imm. 6 Cu_aluc ALU Operation 7 Cu_aluimm Imm. Register data2 8 Cu_wreg Write Reg. Not Write Reg. 9 Cu_regrt rt rd SF CA_2013Spring_Lab

Units of Pipelined-cycle CPU IF Stage (Instr. Mem.) ID Stage (CPU Ctl. And R.F.) EX Stage (ALU) Mem Stage (Data Mem.) WB Stage 1.29

1.30

Pipelined CPU Top Module module top (input wire CCLK, BTN3, BTN2, input wire [3:0]SW, output wire LED, LCDE, LCDRS, LCDRW, output wire [3:0]LCDDAT); assign pc [31:0] = if_npc[31:0]; if_stage x_if_stage(btn3, rst, pc, mem_pc, mem_branch, IF_ins_type, IF_ins_number,ID_ins_type,ID_ins_number); id_stage x_id_stage(btn3, rst, if_inst, if_pc4, wb_destr, ID_ins_type, ID_ins_number, EX_ins_type, EX_ins_number..); ex_stage x_ex_stage(btn3, id_imm, id_ina, id_inb, id_wreg,.. EX_ins_type, EX_ins_number, MEM_ins_type, MEM_ins_number); mem_stage x_mem_stage(btn3, ex_destr, ex_inb, ex_alur, MEM_ins_type, MEM_ins_number, WB_ins_type, WB_ins_number); wb_stage x_wb_stage(btn3, mem_destr, mem_alur, WB_ins_type, WB_ins_number,OUT_ins_type, OUT_ins_number); 1.31

Observation Info Input West Button: Step execute South Button: Reset 4 Slide Button: Register Index Output 0-7 Character of First line: Instruction Code 8 of First line : Space 9-10 of First line : Clock Count 11 of First line : Space 12-15 of First line : Register Content Second line : stage name /number/type stage name: 1- f, 2- d, 3- e, 4- m, 5- w 1.32

Program for verification Instruction Bin Code Address Inst. Type 1 lw r1, $20(r0) 0x8c01_0014 0 6 2 lw r6, $21(r0) 0x8c06_0015 1 6 3 add r3,r0,r0 0x0000_1820 2 1 4 add r4,r0,r0 0x0000_2020 3 1 5 add r5,r0,r0 0x0000_2820 4 1 6 add r2,r2,r1 0x0041_1020 5 1 7 sub r3, r3, r1 0x0061_1822 6 2 8 and r4, r4, r1 0x0081_2024 7 3 9 nor r5, r5, r1 0x00a1_2827 8 5 10 beq r2, r1, -8 0x1041_fff8 9 8 1.33

Precaution 1. Add Anti-Jitter and display for A-F. 2. Finish the blank. 3. Debug method: Output whatever signal to LCD Display. 4. Understand the principle of pipelined CPU and check the logic of circuit carefully, understand the sample code, then write code and synthesize the project, because it takes you a few minutes 1.34

Something Important!!! 1 The number and type tells the information of the instruction that is to be executed in the stage. 2 How to verify the result? Pls. check the result of WB stage for R- type and LW instructions, while check the result of EXEC stage for BEQ instruction. 3 Why there are some NONE instructions following BEQ? How many NONE instructions? 3, because the condition of BEQ is generated in MEM stage. 4 Why the initial value of PC is FFFFFFFF, not 0? 5 Why we should pull the slide button after step execution to refresh the result? And instruction refresh is delayed by 1 clock-cycle? How to refresh automatically? 1.35

Thanks! 1.36