CPU Design for Computer Integrated Experiment

Similar documents
Computer Architecture Experiment

CENG 3420 Lecture 06: Datapath

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

MIPS%Assembly% E155%

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

RTL Model of a Two-Stage MIPS Processor

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

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

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

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

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Week 10: Assembly Programming

CS 351 Exam 2 Mon. 11/2/2015

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

F. Appendix 6 MIPS Instruction Reference

Computer Architecture. The Language of the Machine

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

The MIPS Instruction Set Architecture

CS3350B Computer Architecture Quiz 3 March 15, 2018

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

Reduced Instruction Set Computer (RISC)

MIPS Instruction Reference

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

ECE260: Fundamentals of Computer Engineering

Concocting an Instruction Set

Instruction Set Principles. (Appendix B)

EE108B Lecture 3. MIPS Assembly Language II

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

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

ECE260: Fundamentals of Computer Engineering

MIPS Instruction Set

Chapter 4. The Processor

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

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

Reduced Instruction Set Computer (RISC)

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

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

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

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Project Part A: Single Cycle Processor

Concocting an Instruction Set

Concocting an Instruction Set

Mips Code Examples Peter Rounce

Computer Architecture. MIPS Instruction Set Architecture

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

Chapter 4. The Processor

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

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

Review: MIPS Organization

TSK3000A - Generic Instructions

CS61CL Machine Structures. Lec 5 Instruction Set Architecture

MIPS Reference Guide

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

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

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

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

Midterm Questions Overview

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

CS 4200/5200 Computer Architecture I

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

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Concocting an Instruction Set

INSTRUCTION SET COMPARISONS

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

Midterm. CS64 Spring Midterm Exam

CS Computer Architecture Spring Week 10: Chapter


Processor (I) - datapath & control. Hwansoo Han

Lecture 4: MIPS Instruction Set

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

MACHINE LANGUAGE. To work with the machine, we need a translator.

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

Assembly Language. Prof. Dr. Antônio Augusto Fröhlich. Sep 2006

Computer Architecture

The Processor: Datapath and Control. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CS3350B Computer Architecture MIPS Instruction Representation

CS 61C: Great Ideas in Computer Architecture Datapath. Instructors: John Wawrzynek & Vladimir Stojanovic

IMPLEMENTATION MICROPROCCESSOR MIPS IN VHDL LAZARIDIS DIMITRIS.

CSEE W3827 Fundamentals of Computer Systems Homework Assignment 3 Solutions

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

Topic Notes: MIPS Instruction Set Architecture

CENG3420 Lecture 03 Review

Unsigned Binary Integers

Unsigned Binary Integers

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

ECE 473 Computer Architecture and Organization Project: Design of a Five Stage Pipelined MIPS-like Processor Project Team TWO Objectives

The MIPS Processor Datapath

Midterm Questions Overview

CPS311 - COMPUTER ORGANIZATION. A bit of history

CSE 378 Midterm 2/12/10 Sample Solution

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

Chapter 4. The Processor. Computer Architecture and IC Design Lab

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.

CSc 256 Midterm 2 Fall 2011

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

MIPS PROJECT INSTRUCTION SET and FORMAT

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

Programming the processor

MIPS Instruction Format

Examples of branch instructions

Transcription:

CPU Design for Computer Integrated Experiment Shan Lu, Guangyao Li, Yijianan Wang CEIE, Tongji University, Shanghai, China Abstract - Considering the necessity and difficulty of designing a CPU for students, we simplify the MIPS instruction set for a MIPS architecture processor. Besides this, data path is given and all internal modules are compiled such as ALU module, controller module, bus module and so on. After testing and validation, the difficulty and time consumption of designing such a CPU are proved possible for students. As a result, a suit of experiment platforms based on CPU is born. It not only provides students a chance to have their own processor, but also provides us with a platform for further experiment, such as OS and fundamentals of compilation. Key words: MIPS, processor, integrated experiment 1 Introduction Nowadays, most students whose major are CS have little understanding of the principle of CPU works, and have little practice. So these students can hardly grasp the main point of principle computer organization. To solve this problem, a simple student-oriented CPU is born. This design is used to help students to learn more about the computer configuration in practice. What s more, this CPU also provides a platform for the following course of OS and fundamentals of compilation. Thanks to the open instruction model, MIPS instruction set [1] is chosen. In this model, subscribers are encouraged to design your own CPU in accordance with their own demands. Besides this, MIPS belongs to the RISC architecture, and the instructions are simple and few. So it is a good idea to choose MIPS instruction to structure our CPU. It is easy for students to see the achievement in a short term. Verilog [2] is chosen to design this CPU because it is similar to C, and majority of students have C programming foundation. What s more, there are enough choices for you to design, such as ALU module, controller module, I/O module [3], storage module and so on. In this article, the designs and verification of all modules are involved. As a result, this CPU design has achieved the expected effect. 2 The Design of MIPS Processor 2.1 MIPS Instruction Set According to Harvard structure, data are stored separately from instruction. Figure 1 shows the five steps of execute a MIPS instruction in a single cycle. The five steps are IF, ID, EX, MEM, W B. (1) IF step, instruction address is taken from PC Register(PC_Reg) to identify the current execution instruction and sent to Instruction Memory(Instr_Mem) to get the binary code of the instruction through Address Bus. (2) ID step, instruction code is decoded by Controller to get the control signal. According to the different instruction type, the corresponding register value is obtained from the Register File(Reg File). (3) EX step, the operand and the control signal are sent to the ALU for arithmetical or logical operation or the BS module for shifting. (4) MEM step, according to different MIPS instruction, the ALU result will be sent to the bus controller for arbitration. The bus controller will decide the destination of data such as Data Memory(Data_Mem) or GPIO. GPIO module realizes the responsibility of cache to solve the speed relation between internal unit and peripheral unit. (5) WB, according to the control signal, write-back mux module will decide whether the data writes back to the Register File(Reg_File).

IF ID EX MEM WB Controller ALU Bus Controller PC Reg Instr Mem WriteBack Mux Reg File BS Data Mem GPIO Figure 1 process and modules of MIPS Figure 2 MIPS processor data path The 30 most common used instructions as shown in Table 1 include the arithmetical operation, logical operation, branch, store instruction and so on. This set meets all the demands we need in the following design. MIPS instruction sets include three types: R-type, I-type and J-type. (1) R-type means register instructions. Two operands are taken from Register File, and the result is also sent to the Register File. (2) I-type means immediate instructions. These instructions fetch 16-bit immediate as an operand. (3) J-type means jump instructions. These instructions fetch 26-bit immediate as the destination address which will be stored into PC Register. of MIPS processor is designed as Figure 2. Pin information and wiring information is designed as well according to the statement in section 2.1. 2.2.2 ALU design ALU module typically handles logical and arithmetical operation. The operation between operand A and B is controlled by ALU control signal(alucontrol). Afterwards ALU result and zero flag can be fetched from the output pins. Figure 3 shows the pin signal and Table 2 shows the detailed information of pins. 2.2 MIPS CPU Design 2.2.1 Data Path Design After analyzing the MIPS instruction format and its [4, 5] classification, referring to the relevant CPU design and the MIPS modules defined in Figure 1, the data path Figure 3 ALU pin signal

Table 1 MIPS instruction set and its format Mnemonic Symbol Format Sample Bit # 31..26 25..21 20..16 15..11 10..6 5..0 R-type op rs rt rd shamt func add 000000 rs rt rd 0 100000 add $1,$2,$3 addu 000000 rs rt rd 0 100001 addu $1,$2,$3 sub 000000 rs rt rd 0 100010 sub $1,$2,$3 subu 000000 rs rt rd 0 100011 subu $1,$2,$3 and 000000 rs rt rd 0 100100 and $1,$2,$3 or 000000 rs rt rd 0 100101 or $1,$2,$3 xor 000000 rs rt rd 0 100110 xor $1,$2,$3 nor 000000 rs rt rd 0 100111 nor $1,$2,$3 slt 000000 rs rt rd 0 101010 slt $1,$2,$3 sltu 000000 rs rt rd 0 101011 sltu $1,$2,$3 sll 000000 0 rt rd shamt 000000 sll $1,$2,10 srl 000000 0 rt rd shamt 000010 srl $1,$2,10 sra 000000 0 rt rd shamt 000011 sra $1,$2,10 sllv 000000 rs rt rd 0 000100 sllv $1,$2,$3 srlv 000000 rs rt rd 0 000110 srlv $1,$2,$3 srav 000000 rs rt rd 0 000111 srav $1,$2,$3 jr 000000 rs 0 0 0 001000 jr $31 Bit # 31..26 25..21 20..16 15..0 I-type op rs rt immediate addi 001000 rs rt immediate addi $1,$2,100 addiu 001001 rs rt immediate addiu $1,$2,100 andi 001100 rs rt immediate andi $1,$2,10 ori 001101 rs rt immediate andi $1,$2,10 xori 001110 rs rt immediate andi $1,$2,10 lw 100011 rs rt immediate lw $1,10($2) sw 101011 rs rt immediate sw $1,10($2) beq 000100 rs rt immediate beq $1,$2,10 bne 000101 rs rt immediate bne $1,$2,10 slti 001010 rs rt immediate slti $1,$2,10 sltiu 001011 rs rt immediate sltiu $1,$2,10 Bit # 31..26 25..0 J-type op address j 000010 address j 10000 jal 000011 address jal 10000

Table 2 ALU pin signal and function a(31:0) operand a of arithmetical or logical operation b(31:0) operand b of arithmetical or logical operation alucontrol(3:0) control signal, operation type result(31:0) ALU result zero zero flag, if it is effective, ALU result is zero 2.2.3 Controller Design During the five steps of implementing MIPS instructions, signals from controller control the data flow in EX step, Mem step and WB step. Controller receives the machine code from instruction register, and then decodes it into control signal to control others modules, such as ALU module, BS module and so on. Figure 4 shows the pin signal and Table 3 shows the detailed information of pins. Figure 4 controller pin signal Table 3 controller pin signal and function funct(5:0) funct filed of instruction ImmHigh(7:0) data bus, controller get the high 8-bit of immediate to identify the data direction, to I/O or memory zero zero flag alucontrol(3:0) ALU control signal bscontrol(2:0) BS control signal aluormem data strobe signal, if it is effective, ALU result is sent to register, else data from memory is sent to register dstreg address strobe signal, if it is effective, Instr 20..16 are set as destination register address, else 15-11 bits of instructions are set as destination register address jal data or address strobe signal, when signal is effective, the value of PC+4 is sent to the NO.31 register jmp PC strobe signal, when signal is effective, the jump location is sent to PC register jorjr PC strobe signal, when signal is effective, the jump location is sent to PC register muxtobs bit strobe signal, if it is effective, the bit is the value which is stored in the register, which address is 25-21 bits of instructions, else the immediate in the 10-6 bits of instruction is sent to BS as the bit to be shifted pcsrc branch signal readio I/O read signal readmem memory read signal rtorimm data strobe signal, if it is effective, ALU operand is the value from register, else 15-0 bits of instruction writebackorbs data strobe signal, if it is effective, BS result is written back writeio I/O write signal writemem memory write signal writereg register write signal zeroorsign extend control signal, if it is effective, the 15-0 bits will extend by zero, else the 15-0 bits will extend by symbol

2.2.4 BS Module Design This CPU is a single cycle processor. In this type of process, shift instruction is demanded to complete in a single cycle. Nowadays, there are three popular encoding. After analyzing these decoding, full-encoding [6] is chosen to realize the BS module. For 32-bit barrel shifter, it demands 5-bit control signal to co mplete logical shift, arithmetical shift and cyclic shift. Figure 5 shows the pin signal and Table 4 shows the detailed information of pins. Figure 5 barrel shifter pin signal Table 4 barrel shifter pin signal and function Bit(4:0) bit to shift Sin(31:0) operand type(2:0) type Sout(31:0) BS result 2.2.5 Bus Module Bus module provides the unified writing and reading management of I/O and memory. The data can be distributed and I/O selected signal and port address can be given by the I/O or memory read-write signal. Figure 6 shows the pin signal and Table 5 shows the detailed information of pins. Table 5 bus module pin signal and function address(15:0) address bus, the low 16-bit of ALU result is set as the address of memory or I/O iodate(15:0) data bus, the data from I/O is sent to bus controller mdata(31:0) data bus, data from memory is sent to bus controller wdata(31:0) data bus, data from register is sent to bus controller readio I/O read signal readmem memory read signal writeio I/O write signal writemem memory write signal portaddr(3:0) port address, the low 4-bit of I/O address is set as port address rdata(31:0) data bus, I/O or memory read signal decide to read I/O data or memory data write_data(31:0) data bus, I/O or memory write signal decide to write data to I/O or memory LEDCtrl LED strobe signal 2.2.6 Register Module Register module(figure 7) consists of 32 registers. Among those registers, No.31 register is used to store return address, the other registers are general-purpose register. During the five steps of implementing MIPS instructions, register module typically handles EX step and WB step. During EX step, operand is fetched from register and sent to ALU module. During WB step, the data is written to the register by the write register signal. Figure 6 bus module pin signal Figure 7 register module pin signal

S T E P. A S T E P. B C o n t r o l l o r T e s t i n g P C I n s t r u c t i o n B u s C o n t r o l M e m o r y & R e g A L U B S G P I O Figure 8 module testing process Figure 9 TestBench code Table 6 register module pin signal and function ra1(4:0) address bus, the 25-21 bits of instruction is send to register as register address ra2(4:0) address bus, the 20-16 bits of instruction is send to register as register address wa3(4:0) address bus, the data written back is sent to register as register address wd3(31:0) data bus, the data written back is sent to register as register data clk clock signal we3 register write signal rd1(31:0) data bus, the data is read from registers according to the ra1 address rd2(31:0) data bus, the data is read from registers according to the ra2 address 3 Testing and Verification RTL simulation consists of two parts, module testing and system testing. This simulation needs complete testbench, and output response for observation. You can determine whether the design reach the expected function in accordance with these information 3.1 Module Testing This testing is divided into two parts as shown in Figure 8. Step A verifies the correctness of PC to fetch the current instruction and next instruction. That is, to verify whether the MIPS processor fetches the machine code which PC points to, correctly parses the func filed, op filed and ImmHigh field of instruction and sends the binary code into right pin. Step B use QtSpim to generate the machine code of test program. The test programs are required to cover the routine testing and marginal testing.

All test programs are run in Modelsim. You can determine whether the design reach the desired function with the help of output pin signal. 3.2 System Testing Write testbench to test the MIPS processor by black box testing. The test which involves all instructions includes logical operation test, arithmetical operation test, GPIO test and so on. Figure 9 shows the testbench code of jump instruction which contains all J-type instruction, jr instruction and parts of I-type instruction such as beq instruction. With the help of instruction execute order and the registers data generated by Modelsim, we can determine whether the design reach the desired function or not. 4 Conclusion A student-oriented MIPS processor is designed to recognize and execute MIPS instruction set correctly. Besides this, as supplements, interface information and function explanation are given. Tests show that the difficulty and time factor are considered to be possible for students to design such a CPU. What s more, the implement of this MIPS processor provide the computer integrated experiment a visual testbed. In the process of this design, students can learn more about the computer configuration in practice. Up till now, we have completed the design and implementation of MIPS processor. The future work is to improve and enlarge the processor, and to program some software such as BIOS, Mini OS or Compiler beyond it. 5 Reference [1] MipsMIPS32 Architecture For Programmers Volume II: The MIPS32 Instruction Set,, MIPS Technologies, Inc. [2] Yuwen Xia, Verilog Digital System Design Tutorial. 2008, Beijing University of Aeronautics and Astronautics Press. [3] XILINX, XPS General Purpose Input/Output(GPIO) (v2.00a). [4] David Money Harris, Sarah L. Harris, Digital Design and Computer Architecture. [5] Quansheng Yang, The Computer System Comprehensive Design Course. 2008, Tsinghua University Press. [6] Field Programmable Gate Array. 1999, Atmel Corporation.