RTL Model of a Two-Stage MIPS Processor

Similar documents
Verilog RTL for a Two-Stage SMIPSv2 Processor

MIPS Instruction Reference

F. Appendix 6 MIPS Instruction Reference

MIPS Reference Guide

Computer Architecture. The Language of the Machine

MIPS Instruction Format

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

Computer Architecture Experiment

Exam in Computer Engineering

The MIPS Instruction Set Architecture

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

ece4750-parc-isa.txt

MIPS Instruction Set

Lab 5: Pipelining an SMIPSv2 Processor: Part I

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

Processor. Han Wang CS3410, Spring 2012 Computer Science Cornell University. See P&H Chapter , 4.1 4

Project Part A: Single Cycle Processor

SMIPS Processor Specification

MIPS%Assembly% E155%

Mips Code Examples Peter Rounce

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

EE108B Lecture 3. MIPS Assembly Language II

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

Week 10: Assembly Programming

Write and Synthesize a Two-Stage SMIPSv2 Processor

Reduced Instruction Set Computer (RISC)

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

Concocting an Instruction Set

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

CPU Design for Computer Integrated Experiment

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers

Anne Bracy CS 3410 Computer Science Cornell University. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

Final Project: MIPS-like Microprocessor

Anne Bracy CS 3410 Computer Science Cornell University. See P&H Chapter: , , Appendix B

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

SPIM Instruction Set

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

Concocting an Instruction Set

CENG 3420 Lecture 06: Datapath

A General-Purpose Computer The von Neumann Model. Concocting an Instruction Set. Meaning of an Instruction. Anatomy of an Instruction

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

CS 4200/5200 Computer Architecture I

INSTRUCTION SET COMPARISONS

MIPS Assembly Language. Today s Lecture

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

Midterm. Sticker winners: if you got >= 50 / 67

Q1: /30 Q2: /25 Q3: /45. Total: /100

ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation

Reduced Instruction Set Computer (RISC)

Concocting an Instruction Set

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

TSK3000A - Generic Instructions

M2 Instruction Set Architecture

Examples of branch instructions

Computer Organization & Design

Concocting an Instruction Set

CSc 256 Midterm 2 Fall 2011

Flow of Control -- Conditional branch instructions

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

A Processor! Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

CSc 256 Midterm 2 Spring 2012

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Computer Architecture. MIPS Instruction Set Architecture

Programmable Machines

Programmable Machines

MIPS Assembly Language Programming

ECE410 Design Project Spring 2013 Design and Characterization of a CMOS 8-bit pipelined Microprocessor Data Path

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

EECS 150 Fall 2012 Checkpoint 1: Pipelined MIPS Processor

Welcome to CS250 VLSI Systems Design

Digital System Design II

Computer Architecture

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

ECE Exam I February 19 th, :00 pm 4:25pm

EECS 150 Fall 2013 Checkpoint 1: Pipelined MIPS Processor

CPS311 - COMPUTER ORGANIZATION. A bit of history

Review of the Machine Cycle

Programming the processor

The MIPS R2000 Instruction Set

Mark Redekopp, All rights reserved. EE 352 Unit 3 MIPS ISA

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

EE 109 Unit 13 MIPS Instruction Set. Instruction Set Architecture (ISA) Components of an ISA INSTRUCTION SET OVERVIEW

Assembly Programming

software hardware Which is easier to change/design???

University of California College of Engineering Computer Science Division -EECS. CS 152 Midterm I

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

ECE260: Fundamentals of Computer Engineering

COMP 303 MIPS Processor Design Project 3: Simple Execution Loop

MIPS Instructions: 64-bit Core Subset

CS 351 Exam 2 Mon. 11/2/2015

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

CS 61c: Great Ideas in Computer Architecture

EE 109 Unit 8 MIPS Instruction Set

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

CS Computer Architecture Spring Week 10: Chapter

Lecture Topics. Announcements. Today: The MIPS ISA (P&H ) Next: continued. Milestone #1 (due 1/26) Milestone #2 (due 2/2)

ece4750-tinyrv-isa.txt

CSc 256 Midterm (green) Fall 2018

Transcription:

RTL Model of a Two-Stage MIPS Processor 6.884 Laboratory February 4, 5 - Version 45 Introduction For the first lab assignment, you are to write an RTL model of a two-stage pipelined MIPS processor using Verilog. The lab assignment is due at the start of class on Friday, February 8. You are free to discuss the design with others in the class, but you must turn in your own solution. The two-stage pipeline should perform instruction fetch in the first stage, while the second pipeline stage should do everything else including data memory access. The -bit instruction register should be the only connection from the first stage to the second stage of the pipeline. You should find that the two-stage pipeline makes it easy to implement the MIPS branch delay slot. If you need to refresh your memory about pipelining and the MIPS instruction set, we recommend Computer Organization and Design: The Hardware/Software Interface, Second Edition, by Patterson and Hennessey. For this assignment, you should focus on writing clean synthesizable code that follows the coding guidelines discussed in lecture. In particular, place logic only in leaf modules and use pure structural code to connect the leaf modules in a hierarchy. Avoid tricky hardware optimizations at this stage, but make sure to separate out datapath and memory components from control circuitry. The datapath diagram in Figure 5 can be used as an intial template for your SMIPS cpu implementation, but please treat it as a suggestion. Your objective in this lab is to implement the SMIPS ISA subset, not to implement the datapath diagram so feel free to add new control signals, merge modules, or make any other modification to the datapath diagram. CPU Interface Your processor model should be in a module named mips cpu, and must have the interface shown in Figure. We will provide a test rig that will drive the inputs and check the outputs of your design, and that will also provide the data and instruction memory. We have provided separate instruction and data memory ports to simplify the construction of

6.884 Lab Assignment, Spring 5 the two stage pipeline, but both ports access the same memory space. The memory ports can only access -bit words, and so the lowest two bits of the addresses are ignored (i.e., only addr[:] and iaddr[:] are significant). Notice that the data write bus is a separate unidirectional bus from the data read bus. Bidirectional tri-state buses are usually avoided on chip in ASIC designs. module mips_cpu ( input clk, input reset, input int_ext, // Clock input // Reset input // External interrupt input input [7:] fromhost, // Value from test rig output [7:] tohost, // Output to test rig output [:] addr, // Data memory address output, // Data memory write enable output [:] write_data, // Data to write to memory input [:] read_data, // Data read back from memory ); output [:] iaddr, // Instruction address input [:] inst // Instruction bits Figure : Interface to SMIPS CPU. Implemented Instructions The SMIS instruction set is a simplified version of the full MIPS instruction set. Consult the SMIPS Processor Specification for more details about the SMIPS architecture. For this first lab assignment, you will only be implementing a subset of the SMIPS specification. Figures and show the instructions that you must support. For this first assignment there are only 5 distinct instructions to implement. The instructions we have removed from the SMIPS specification for this lab are: byte and halfword loads and stores, all multiply and divide instructions (you do not need to implement the hi and lo registers), the branch likely instructions, the branch and link instructions (BLTZAL, BGEZAL), the instructions that can cause arithmetic overflows (ADD, SUB, ADDI), and other instructions related to trap handling (SYSCALL, BREAK).

6.884 Lab Assignment, Spring 5 You do not need to support any exceptions or interrupt handling (apart from reset). The only piece of the system coprocessor you have to implement are the tohost and fromhost registers, and the MTC and MFC instructions that access these registers. These registers are used to communicate with the test rig. The test rig drives fromhost, while you should implement an 8-bit register in COP which drives the tohost[7:] port on the mips cpu module interface....9 4 5 6 7 5... 4 5 6 7...9 8...6 SPECIAL COP... SLL JR 8...6 BLTZ REGIMM ADDIU Opcode 4 5 6 7 J JAL BEQ BNE BLEZ SLTI SLTIU ANDI ORI XORI LW SW JALR SPECIAL function BGTZ LUI 4 5 6 7 SRL SRA SLLV SRLV ADDU SLT SUBU SLTU AND XOR SRAV NOR REGIMM rt 4 5 6 7 BGEZ OR 5...4... MFC ξ Figure : SMIPS CPU Instruction Subset for Lab. COP rs 4 5 6 7 ξ ξ ξ MTC ξ ξ ξ ξ ξ ξ ξ ξ ξ ξ CO Figure : SMIPS CP Instruction Subset for Lab.

6.884 Lab Assignment, Spring 5 4 4 Test Rig We are providing a test rig to connect to your CPU model. The test rig loads in a hex memory dump of instructions to fill the memory. You should use the smips-gcc toolchain to build verilog memory dump versions of your SMIPS assembly test programs. The test rig will clock the simulation until it sees a non-zero value coming back on the tohost register, signifying that your CPU has completed a test program. The simplest test program is shown in Figure 4. # x: Reset vector. addiu r, r, # Load constant into register r mtc r, r # Write tohost register in COP loop: beq r, r, loop # Loop forever nop # Branch delay slot Figure 4: Simple test program.

6.884 Lab Assignment, Spring 5 5 bneq Add/Sub Shifter Logic Unit alu_func shift_func logic_func wb_sel inst_x[5:] b pc_f[:8] inst_x[5:] b Instruction Memory iaddr inst Register File inst_x[5:] signext_sel rd[] (bsign) imm_sel a_sel 6 shamt store_data ra ra Decoder rd wa pc_sel 4 pc_seq {4(inst_x[5])} pc_branch reset_vec pc_next except_vec pc_jump pc_jr wd rd inst_x[:6] inst_x[5] addr wdata tohost[7:] Data Memory rdata fromhost[7:] dest_sel [5:] [:6] [:6] [5:] pc_f Fetch Stage Execute Stage inst_x System Coprocessor Figure 5: SMIPS -Stage Pipeline Datapath for Lab.

6.884 Lab Assignment, Spring 5 6 6 5 6 5 6 5 opcode rs rt rd shamt funct R-type opcode rs rt immediate I-type opcode target J-type Load and Store Instructions base dest signed offset LW rt, offset(rs) base dest signed offset SW rt, offset(rs) I-Type Computational Instructions src dest signed immediate ADDIU rt, rs, signed-imm. src dest signed immediate SLTI rt, rs, signed-imm. src dest signed immediate SLTIU rt, rs, signed-imm. src dest zero-ext. immediate ANDI rt, rs, zero-ext-imm. src dest zero-ext. immediate ORI rt, rs, zero-ext-imm. src dest zero-ext. immediate XORI rt, rs, zero-ext-imm. dest zero-ext. immediate LUI rt, zero-ext-imm. R-Type Computational Instructions src dest shamt SLL rd, rt, shamt src dest shamt SRL rd, rt, shamt src dest shamt SRA rd, rt, shamt rshamt src dest SLLV rd, rt, rs rshamt src dest SRLV rd, rt, rs rshamt src dest SRAV rd, rt, rs src src dest ADDU rd, rs, rt src src dest SUBU rd, rs, rt src src dest AND rd, rs, rt src src dest OR rd, rs, rt src src dest XOR rd, rs, rt src src dest NOR rd, rs, rt src src dest SLT rd, rs, rt src src dest SLTU rd, rs, rt Jump and Branch Instructions target J target target JAL target src JR rs src dest JALR rd, rs src src signed offset BEQ rs, rt, offset src src signed offset BNE rs, rt, offset src signed offset BLEZ rs, offset src signed offset BGTZ rs, offset src signed offset BLTZ rs, offset src signed offset BGEZ rs, offset System Coprocessor (COP) Instructions dest copsrc MFC rt, rd src copdest MTC rt, rd Table : SMIPS instruction subset for Lab.