Yi 2009
Yi 2009
Abstract—In this paper, we analyze MIPS instruction format、、 of MIPS instruction directly extends new instruction based
instruction data path、、 decoder module function and design on old instruction but not abnegates any old instruction, so
theory basend on RISC CPUT instruction set. Furthermore, MIPS processor of 64-bit instruction set can execute 32-bit
we design instruction fetch(IF) module of 32-bit CPU based on instruction.
RISC CPU instruction set. Function of IF module mainly All MIPS instructions are all 32-bit specified instruction
includes fetch instruction and latch module 、 address and instruction address is word justification. MIPS divides
arithmetic module、 、 check validity of instruction module、 、 instructions into three formats: immediate format(I-
synchronous control module. Function of IF modules are Format ) 、 register format(R-Format) and jump format(J-
implemented by pipeline and simulated successfully on Format)[2]. Three instruction format shows as Figure. 1.
QuartusII。。 Meaning of every instruction field as following:
OP: 6-bit operation code;
Keywords- MIPS, Data Flow, Data Path, Pipeline rs: 5-bit source register;
rt: 5-bit temporary (source/destination)register number or
I. INTRODUCTION branch condition;
immediate: 16-bit immediate, branch instruction offset or
Because memory was expensive in old days, designer of address offset;
instruction enhanced complication of instruction to reduce destination: 26-bit destination address of unconditional jump;
program length. Tendency of complication instruction design rd: 5-bit destination register number;
brought up one traditional instruction design style, which is shamt: 5-bit shift offset;
named “Complex Instruction Set Computer-CISC” structure. funct: 6-bit function field;
But great disparity among instructions and low universal
property result in instruction realization difficulty and long
running-time cost. Comparing to CISC, RISC CPU have
more advantages, such as faster speed 、 simplified
structure、easier implementation. RISC CPU is extensive
use in embedded system. Developing CPU with RISC
structure is necessary choice. Figure. 1 MIPS Instruction Format.
755
IV. PIPELINE DESIGN
Pipeline decomposition enhances throughput rate of
instruction. Clock cycle is decided by the slowest stage
running time. In general words, pipeline includes five stages:
instruction fetch(IF) 、 instruction decoder( ID ) 、
execution( EXE )、 memory/ IO(MEM)、write-back(WB).
A. Instruction Fetch( IF )
Instruction fetch (IF) stage is request for instruction
which is fetched from memory. Main component of IF stage
shows as Figure. 7. Instruction and PC is memorized in
IF/ID pipeline register as temporary memory for next clock
Figure. 5 Memory Instruction Data Path
cycle.
Figure. 7 IF Stage
756
C. Execution(EXE) instruction memories result in R1 register to make program
run faster. Figure. 11 shows WB unit instruction.
EXE stage executes arithmetic. Main component of EXE
stage is ALU. Arithmetic logic unit and shift-register
compose of ALU. Figure. 9 shows EXE stage structure.
Function of EXE stage is to do operation of instruction, such
as add and subtraction. ALU sends result to EX/MEM
pipeline register before entering MEM stage.
Figure. 11 WB Stage
A. Function Statement
Function of instruction fetch(IF) stage shows as below:
1) Fetch instruction and latch. Fetch instruction from
Figure. 9 EXE Stage
instruction register depending on PC value and send the
instruction to IF/ID pipeline register to latch.
757
branchPC: jump address of branch signal
retPC: subprogram return address signal
retiPC: interrupt return address signal
sel : selection signal from pcselector in EXE stage
clk: clock signal
ifid_flush: data signal
ifid_enable、pc_enable: control signal
Output signal of IF stage includes ins[31..0]、
pcvelue[31..0] 、 insOut[31..0]and pcout[31..0]. Their function
shows as below: Figure. 14 progc Module Simulation Waveform
ins[31..0]: instruction code fetch from instruction register;
pcvelue[31..0]: PC value in IF stage;
insOut[31..0]: instruction code which is to sent to next stage 3) incPC module. Input port includes pcin[31..0] and
and comes from pipeline register ifid;
pcout[31..0]: program counter value.
output port includes pcout[31..0]. The function of incPC
Module Implementation shows as below: module is to PC add 1 and the new PC cat as one optional
1) pcselector module. Input port includes value. When negative clock sign comes, PC value is sent to
nextpc[31..0] 、 branchpc[31..0] 、 retpc[31..0] 、 pcselector module. Figure. 15 shows incPC module entity
retipc[31..0] and sel[3..0]. Output port includes structure and RTL structure. Figure. 16 shows simulation
newpc[31..0]. Select data from four source data as next waveform of incPC module. We can know pcIn value adds 1
instruction address determined by sel[3..0]. The four source and send result to pcVal from waveform.
data are nextpc[31..0]、branchpc[31..0]、retpc[31..0] and
retipc[31..0].
Input signal are nextPC、branchPC、retPC、retiPC
and sel. Output signal are newPC. Function of input signal
shows as below:
nextPC: next instruction address;
branchPC: address of branch jump signal;
retPC: subprogram return address signal;
retiPC: interrupt return address signal;
sel: selector signal.
Time sequence simulation waveform of pcselector shows
as Figure. 13. Input different address sign into nextpc 、
branchpc、retpc、retipc ports, and newpc selects one of the
four input signal to output depending on value in sel[3..0].
758
memory location which is specified by address bus
address[5..0], moreover, fetch next instruction from memory REFERENCE
and send out the instruction by instruction bus q[31..0].
lpm_rom0 module can be implemented EAB of FPGA [1] Bai-ZhongYing, Computer Organization, Science Press, 2000.11.
by calling macro function module. Adopt lpm_rom structure [2] Wang-AiYing, Organization and Structure of Computer, Tsinghua
University Press, 2006.
in macro function library to realize the module. Parameter
[3] Wang-YuanZhen, IBM-PC Macro Asm Program, Huazhong
configuration is that address bus address is 6-bit and output University of Science and Technology Press, 1996.9.
bus q is 32-bit. Process of lpm_rom0 is described as
[4] MIPS Technologies, Inc. MIPS32™ Architecture For Programmers
following: when positive inclock edge comes, latch Volume II: The MIPS32™ Instruction Set,June 9, 2003.
address[5..0] and ouput the data pointed by value of [5] Zheng-WeiMin, Tang-ZhiZhong. Computer System Structure (The
address[5..0] to output port q[31..0]. Set up data in second edition), Tsinghua University Press,2006.
lpm_rom0 by memory initialization file (.mif), or edit 、 [6] Pan-Song, Huang-JiYe, SOPC Technology Utility Tutorial , Tsinghua
update and reload data on debugging by system memory University Press,2006.
editor tool. [7] MIPS32 4KTMProcessor Core Family Software User's Manual ,
5) ifid module. Input port includes pcin[31..0] 、 MIPS Technologies Inc.
insin[31..0] 、 clkid_flush and ifid_enable. Output port [8] Mo-JianKun, Gao-JianSheng,Computer Organization, Huazhong
University of Science and Technology Press, 1996.
includes pcout[31..0] and insout[31..0]. Function of ifid is [9] Zhang-XiuJuan, Chen-XinHua, EDA Design and emulation Practice
to latch PC and instr of Statge1 and send them to next stage. [M]. BeiJing, Engine Industry Press. 2003.
Time sequence simulation waveform of Ifid module [10] "IEEE Standard of Binary Floating-Point Arithmetic" IEEE
shows as Figure. 17. We can see fact that when ifid_enalbe is Standard754, IEEE Computer Society, 1985.
high level and id_flush is low level, data are not relative in [11] Yi-Kui, Ding-YueHua, Application of AMCCS5933 Controller in
pipeline. When positive edge of clk comes, values of insOut PCI BUS, DCABES2007, 2007.7.
and pcOut are same to insIn and pcIn respectively; When
ifid_enable and id_flush are all high level, data is relative in
pipeline. When positive edge of clk comes, insOut changes
to “0000H”, but pcOut maintains its original value ; After
pipeline conflicts, insOut and pcOut returns to normal
working state; if ifid_enable is low level, pipeline stops
working and insOut and pcOut maintain its original state.
VI. CONCLUSION
In this research, we adopt top-down design method and
use VHDL to describe system. At first, we design the system
from the top, and do in-depth design gradually. The structure
and hierarchical of design is very clear. It is easy to edit and
debug. Design of instruction fetch (IF)stage simulates 、
integrate and routes on Quartus II 4.3. The result indicates
IF stage completes prospective function.
759
Figure. 12 IF Circuit Diagram.
760