21
Đồ án Cấu trúc máy tính – Nhóm 3 – Phạm Ngọc Luân, Phan Ngọc Điệp, Nguyễn Văn Thiện 1 BÁO CÁO ĐỒ ÁN CẤU TRÚC MÁY TÍNH LAB 3 THIẾT KẾT BỘ XỬ LÝ MIPS 32-BIT SINGLE-CYCLE Giáo viên hướng dẫn: Ths.Thái Văn Tiến - Bộ môn Kỹ thuật máy tính Khoa Điện tử - Viễn thông Đại học Bách Khoa Đà Nẵng Sinh viên thực hiện: Phạm Ngọc Luân - 10DT2 - Nhóm 3 Phan Ngọc Điệp - 10DT2 - Nhóm 3 Nguyễn Văn Thiện - 10DT2 - Nhóm 3 Đà Nẵng, 05 – 2014

Thiet Ke MIPS Single Cycle

  • Upload
    iegt

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

1

BÁOCÁO

ĐỒÁNCẤUTRÚCMÁYTÍNH

LAB3

THIẾTKẾTBỘXỬLÝMIPS32-BITSINGLE-CYCLE

Giáo viên hướng dẫn:

Ths.Thái Văn Tiến - Bộ môn Kỹ thuật máy tính

Khoa Điện tử - Viễn thông

Đại học Bách Khoa Đà Nẵng

Sinh viên thực hiện:

Phạm Ngọc Luân - 10DT2 - Nhóm 3

Phan Ngọc Điệp - 10DT2 - Nhóm 3

Nguyễn Văn Thiện - 10DT2 - Nhóm 3

ĐàNẵng,05–2014

Page 2: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

2

Phần1:GiớithiệuvềbộxửlýMIPS32-bitSingle-Cycle

1.1Yêucầu:

Thiết kếbộxử lýMIPSSingle-Cycle32-bit bao gồmcác lệnh:LW, SW, J, JR, JAR, BNE,

BEQ,XORI,ADD,AND,ANDI,SUBvàSLT.

Cáclệnhđềuđượcxửlýhoàntấttrong1chukỳlệnh.

Thiếtkếdựatrêncácmodulecósẵninstrmem.vvàdatamem.v

Trongthie� tke� sưdunglaicacmoduleđathie� tke� tronglab1valab2đolaREGISTERva

ALU_5_OP.

1.2Tậplệnh:

Cáclệnhchialàm3nhóm:

FormatR:ADD,SUB,SLT,JR,AND.

FormatI:LW,SW,BNE,BEQ,XORI,ANDI.

FormatJ:J,JAL

1.2.1.FormatR:

ADD:Conggiatri2thanhghisvat,lưuke� tquavaothanhghiđıch.

SUB:Lấy giá trị thanh ghi s trừ đi giá trị trong thanh ghi t,

kết quả lưu vào thanh ghi đích(d)

Page 3: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

3

SLT:sosanhgiatri2thanhghi,ne�us>t,d=0,ne�us<t,d=1;

JR:Lệnh Jump Reg: Nhảy tới giá trị lưu trong thanh ghi.

AND:Lệnh

1.2.2.FormatI:

LW:

Page 4: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

4

SW:

Ýnghĩa:

M[R[rs]+SignExtImm] = R[rt]

BNE:

Ýnghĩa:

Nếu(R[rs]!=R[rt])

PC=PC+4+offset*4

XORI:

Page 5: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

5

BEQ:

BNE: Nếu giá trị trong thanh ghi s = thanh ghi t, thì sẽ nhảy

đến PC + 4 + offset*4

ANDI:

1.2.3.FormatJ:

J:

Page 6: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

6

JAL:

Phần2:Thiếtkếphầncứng

2.1.Sơđồkhối:

2.2Thiếtkếcácmodule:

2.2.1BộMIPSControl:

Khốiđiềukhiểntrungtâm,cónhiệmvụgiảimãlệnhdựatrên6-bitOpcodevà6-bit

functioncủacâulệnhthànhcáctínhiệuđiềukhiểnđếncáckhốikháctrongbộxửlý

MIPS.

Page 7: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

7

Cáctínhiệuđiềukhiểnvàgiátrịtươngứngtrongtừngcâulệnhđượcchotrongbảng

dưới.

Từbảngtrạngthái,sửdụngcáccổnglogicANDvàOR,talậpđượccáctínhiệuratừ6bit

OpcodevaFunction.

Truthtable:Xembang1/trang24phuluccuo� ibaocao.

NgõvàobộControlgồmcó6-bitOpcodevà6-bitFunction.

CáclệnhformatR:ADD,SUB,SLTcóchungcáctínhiệuđiềukhiểnra.RiênglệnhJRcó1

tínhiệukháclà:JumpReg.DođócầnthiếtkếriêngkhốiđiềukhiểncholệnhJR.

CáclệnhkhácphânbiệtvớinhaubởiOpcodenênkhôngcầndựavàocácbitfunctionđể

điềukhiển.(Xembang2/trang25)

Đoạnmã:

/*====================================================*/

/* MIPCONTROL */

/*=====================================================*/

moduleMIP_CTL(ALUOp,RegDest,ALUSrc,MemToReg,RegWrite,MemRead,MemWrite,BranchEQ,

BranchNE,Jump,JumpReg,SignExtend,Instr[5:0],Funct[5:0]);

input[5:0]Instr,Funct;

Main

Control

RegDst[1:0]

ALUSrc

Jump

MemToReg

BranchNE

BranhEQ

RegWrite

MemRead

JumpReg

ALUop

Memwrite

Aluscr

Regwrite

Fill

Instruction [31:26]

Instruction [5:0]

Page 8: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

8

outputALUSrc,MemToReg,RegWrite,MemRead,MemWrite,BranchEQ,

BranchNE,Jump,JumpReg,SignExtend;

output[2:0]ALUOp;

wire[5:0]nInstr,nFunct;

wireInstr_LW,Instr_SW,Instr_XOIR,Instr_ANDI,Instr_J,Instr_JR;

output[1:0]RegDest;

not#50nott1_MIP_CLT(nInstr[5],Instr[5]);

not#50nott2_MIP_CLT(nInstr[4],Instr[4]);

not#50nott3_MIP_CLT(nInstr[3],Instr[3]);

not#50nott4_MIP_CLT(nInstr[2],Instr[2]);

not#50nott5_MIP_CLT(nInstr[1],Instr[1]);

not#50nott6_MIP_CLT(nInstr[0],Instr[0]);

not#50nott7_MIP_CLT(nFunct[5],Funct[5]);

not#50nott8_MIP_CLT(nFunct[4],Funct[4]);

not#50nott9_MIP_CLT(nFunct[3],Funct[3]);

not#50nott10_MIP_CLT(nFunct[2],Funct[2]);

not#50nott11_MIP_CLT(nFunct[1],Funct[1]);

not#50nott12_MIP_CLT(nFunct[0],Funct[0]);

//DetectR_FORMAT

and#50and_A_MIP_CTL(r1,nInstr[5],nInstr[4],nInstr[3],nInstr[2]); //ADD,

SUB,SLT,AND

and#50and_B_MIP_CTL(r2,nInstr[1],nInstr[0],Funct[5]);

and#50andAB_MIP_CTL(Instr_R,r1,r2);

and#50and1_JR_MIP_CTL(jr1,nInstr[5],nInstr[4],nInstr[3],nInstr[2]);//JR:

0/08

and#50and_2_JR_MIP_CTL(jr2,nInstr[1],nInstr[0],nFunct[5],nFunct[4]);

and#50and_3_JR_MIP_CTL(jr3,Funct[3],nFunct[2],nFunct[1],nFunct[0]);

and#50and12_JR_MIP_CTL(Instr_JR,jr1,jr2,jr3);

//DetectI_FORMAT

and#50and1_LW_MIPCTL(lw1,Instr[5],nInstr[4],nInstr[3]); //LW

and#50and2_LW_MIPCLT(lw2,nInstr[2],Instr[1],Instr[0]);

and#50and12_LW_MIPCTL(Instr_LW,lw1,lw2);

and#50and_G_MIP_CTL(sw1,Instr[5],nInstr[4],Instr[3]); //SW

and#50and_H_MIP_CTL(sw2,nInstr[2],Instr[1],Instr[0]);

and#50andGH_MIP_CTL(Instr_SW,sw1,sw2);

and#50and_L_MIP_CTL(beq1,nInstr[5],nInstr[4],nInstr[3]); //BEQ

and#50and_M_MIP_CTL(beq2,Instr[2],nInstr[1],nInstr[0]);

and#50andLM_MIP_CTL(Instr_BEQ,beq1,beq2);

and#50and_I_MIP_CTL(bne1,nInstr[5],nInstr[4],nInstr[3]); //BNE

and#50and_K_MIP_CTL(bne2,Instr[2],nInstr[1],Instr[0]);

and#50andIK_MIP_CTL(Instr_BNE,bne1,bne2);

and#50and_O_MIP_CTL(xori1,nInstr[5],nInstr[4],Instr[3]); //XORI

and#50and_P_MIP_CTL(xori2,Instr[2],Instr[1],nInstr[0]);

Page 9: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

9

and#50andOP_MIP_CTL(Instr_XORI,xori1,xori2);

and#50and_Q_MIP_CTL(andi1,nInstr[5],nInstr[4],Instr[3]); //ANDI

and#50and_R_MIP_CTL(andi2,Instr[2],nInstr[1],nInstr[0]);

and#50andQR_MIP_CTL(Instr_ANDI,andi1,andi2);

//DETECTJFORMAT

and#50and_U_MIP_CTL(jj1,nInstr[5],nInstr[4],nInstr[3]); //J

and#50and_S_MIP_CTL(jj2,nInstr[2],Instr[1],nInstr[0]);

and#50andUS_MIP_CTL(Instr_J,jj1,jj2);

and#50and_T_MIP_CTL(jal1,nInstr[5],nInstr[4],nInstr[3]); //JAL

and#50and_Y_MIP_CTL(jal2,nInstr[2],Instr[1],Instr[0]);

and#50andTY_MIP_CTL(Instr_JAL,jal1,jal2);

//THIETLAPTINHIEUCTL

assignRegDest[0]=Instr_R;

//RegDest

assignRegDest[1]=Instr_JAL;

or#50or_A_MIP_CTL(ALUSrc,Instr_LW,Instr_SW,Instr_XORI,Instr_ANDI);

//ALUSrc

assignMemToReg=Instr_LW;

//MemToReg

or#50or_B_MIP_CTL(RegWrite1,Instr_R,Instr_LW,Instr_XORI);

//RegWrite

or#50or_C_MIP_CTL(RegWrite2,Instr_ANDI,Instr_JAL);

or#50orBC_MIP_CTL(RegWrite,RegWrite1,RegWrite2);

assignMemRead=Instr_LW;

//MemRead

assignMemWrite=Instr_SW;

//MemWrite

assignBranchEQ=Instr_BEQ;

//BranchEQ

assignBranchNE=Instr_BNE;

//BranchNE

or#50or_jump(Jump,Instr_J,Instr_JAL);

//Jump

assignJumpReg=Instr_JR;

//JumReg

or#50or_F_MIP_CTL(SignExtend,Instr_LW,Instr_SW,Instr_BNE,Instr_BEQ);

//SignExtend

//CACALU_OP

or#50and_ALUOP2(ALUOp[2],Instr_ANDI,Instr_J,Instr_JAL);

//ALUOp2

or#50and_ALUOP1A(ALUOp1_A,Instr_BEQ,Instr_BNE,Instr_XORI);//ALUOp1

or#50and_ALUOP1B(ALUOp1_B,Instr_J,Instr_JAL);

or#50and_ALUOP1AB(ALUOp[1],ALUOp1_B,ALUOp1_A);

or#50and_ALUOP0A(ALUOp0A,Instr_LW,Instr_SW,Instr_XORI);//ALUOp0

Page 10: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

10

or#50and_ALUOP0AB(ALUOp[0],ALUOp1_B,ALUOp0A);

//XEMKEMTHEOFILE0Instr.xlxs

endmodule

2.2.2BộALUControl:

GiảimãtínhiệuđiềukhiểnALUOptừkhốiControl,kếthợpvới6bitFunctionđểđưara

tínhiệuđiềukhiểnchokhốiALUthựchiệnmộttrong5phéptoánADD,SUB,SLT,AND

vàXOR.

TínhiệuđiềukhiểnchoALUđượcchotrongbảngso� 2,trangyy:

2.2.3Khốidịchtrái(32-bitto32-bit):

Dobộnhớchươngtrìnhđượcđánhđịachỉbytevàcấutrúclệnhđượclưutrong1word,

dođóđốivớicáclệnhrẽnhánh,giátrịtrướckhiđưavàothanhghiPCphảinhânvới4,

haynóicáchkháclàdịchtráigiátrịnhịphânđi2đơnvị.

Codeverilog:

module Shift_Left32(Output, Input);

input [31:0]Input;

output [31:0]Output;

assign Output[31:0] = {Input[31:2], 2'b00};

endmodule

2.2.4Khốimởrộng(Fill):

Phầnaddress/immediatecủacáccâulệnhI-formatgồm16-bit,trongkhiđốisốcủacác

lệnhhoặcđịachỉbaogồm32-bit,dođócầncóbướcmởrộngtrướckhidùngđểtính

toán.

Tùytheolệnhmàmởrộngdấuhaymởrộngzero,tasửdụng1bitđiềukhiểntừkhối

Controlđểlựachọnkiểumởrộng(signExtend).

Codeverilog:

UnsignExtend_32bit UnsignedExtend32B(UnsignedExtend32, Instr[15:0]);

//Unsign Extend

SignExtend_32bit SignExtend32B(SignExtend32, Instr[15:0]);

mux2to1_32bits MUXSignExtend(OutExtend32, Instr[15],

UnsignedExtend32, SignExtend32); //bit 16 la bit control

module UnsignExtend_32bit(Out32, Input); //Unsigned

Extend

input [15:0]Input;

output [31:0]Out32;

genvar i;

generate

for(i = 0; i < 16; i = i+1) begin: extend1

Page 11: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

11

assign Out32[i] = Input[i];

end

endgenerate

generate

for(i = 16; i < 32; i = i+1) begin: extend2

assign Out32[i] = 1'b0;

end

endgenerate

endmodule

module SignExtend_32bit(Out32, Input); //SignExtend

input [15:0]Input;

output [31:0]Out32;

assign Out32[15:0] = Input;

genvar i;

generate

for(i = 16; i < 32; i = i+1) begin: extend

assign Out32[i] = Input[15];

end

endgenerate

endmodule

Sơđồkhối:

2.2.5Bộchọnkênh32-bit(2sang1)

Cácbộchọnkênhđượcsửdụngđểchọn1tínhiệuratừ2tínhiệuvào.

CáctínhiệuđiềukhiểnphụthuộcvàotừngcâulệnhvàđượcđưaratừkhốiControl.

Bộchọnkênh32-bit2to1đượctạothànhbằngcáchghépsongsong32bộmultiplexer

2-bit2to1.

Sơđồkhốibộchọnkênh2-bit2to1.

Page 12: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

12

/*=========================================================*/

/*-------------------MUX 32: 2 TO 1 -----------------------*/

/*=========================================================*/

module mux2to1_32bits(Out, Control, a, b);

output [31:0]Out;

input Control;

input [31:0]a,b;

mux2to1_4bits MUX2132B1(Out[31:28], Control, a[31:28], b[31:28]);

mux2to1_4bits MUX2132B2(Out[27:24], Control, a[27:24], b[27:24]);

mux2to1_4bits MUX2132B3(Out[23:20], Control, a[23:20], b[23:20]);

mux2to1_4bits MUX2132B4(Out[19:16], Control, a[19:16], b[19:16]);

mux2to1_4bits MUX2132B5(Out[15:12], Control, a[15:12], b[15:12]);

mux2to1_4bits MUX2132B6(Out[11:8], Control, a[11:8], b[11:8]);

mux2to1_4bits MUX2132B7(Out[7:4], Control, a[7:4], b[7:4]);

mux2to1_4bits MUX2132B8(Out[3:0], Control, a[3:0], b[3:0]);

endmodule

module mux2to1_5bits(Out, Control, a, b); //mux 2 to 1:

5bits

output [4:0]Out;

input [4:0]a,b;

input Control;

mux2to1_1bit MUX211A3(Out[3], Control, a[3], b[3]);

mux2to1_1bit MUX211A2(Out[2], Control, a[2], b[2]);

mux2to1_1bit MUX211A1(Out[1], Control, a[1], b[1]);

mux2to1_1bit MUX211A0(Out[0], Control, a[0], b[0]);

mux2to1_1bit MUX211A4(Out[4], Control, a[4], b[4]);

endmodule

module mux2to1_4bits(Out, Control, a, b); //mux 2 to 1:

4bits

output [3:0]Out;

input [3:0]a,b;

input Control;

mux2to1_1bit MUX211B3(Out[3], Control, a[3], b[3]);

mux2to1_1bit MUX211B2(Out[2], Control, a[2], b[2]);

mux2to1_1bit MUX211B1(Out[1], Control, a[1], b[1]);

mux2to1_1bit MUX211B0(Out[0], Control, a[0], b[0]);

Page 13: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

13

endmodule

module mux2to1_1bit(Out, Control, a, b); //mux 2 to 1: 1bit

output Out;

input Control, a, b;

not #50 not_mux2to1_1bit(nControl, Control);

and #50 and1_mux2to1_1bit(out1, nControl, a);

and #50 and2_mux2to1_1bit(out2, Control, b);

or #50 or1_mux2to1_1bit(Out, out1, out2);

endmodule

2.2.6ThanhghiPC

ThanhghiPCđượcsửdụngđểchỉđếnvịtrícủacâulệnhtiếptheosẽđượcthựchiện.

GiátrịcủathanhghiPCsaumỗichukỳlệnhsẽtựđộngtănglên4.Cáccâulệnhrẽnhánh

J,JR,BNEsẽcótácđộnglàmthayđổigiátrịcủathanhghiPC.

Banđầukhikhởiđộng,sẽcó1xungresetrấtnhỏđưavàoPCđủđểchothanhghiPC=

0x0000.

Mỗikhicóxungclk,bộnhớchươngtrìnhsẽsửdụnggiátrịcủathanhghiPCđểlấyra

câulệnhtiếptheo.

Chukỳcủaxungclockphảilớnhơnthờigianthựchiệncủalệnhdàinhất:LW

Ngoàira,thanhghiPCcòncótácdụngcấpxungclockphụcvụchoquátrìnhghidữliệu

vàothanhghifilevàbộnhớdữliệu.

ThanhghiPCđượccấutạotừ32D-Flipflopnốisongsong.

Đoạnmãverilog:

/*===========================================================*/

/*------------- PC_Register --------------------------------*/

/*===========================================================*/

module PC_Register(PCOut, clk_regfile, clk_mem,PCIn, reset, clk);

input [31:0]PCIn;

input clk, reset;

output [31:0]PCOut;

output clk_regfile, clk_mem;

buf #2600 delay_mem(clk_mem, clk);

buf #3500 delay_reg(clk_regfile, clk);

genvar i;

generate

for(i = 0; i< 32; i = i +1) begin: DFF

D_FF D_FFN(PCOut[i], PCIn[i], reset, clk);

end

endgenerate

endmodule

Page 14: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3

Sơđồkhối

2.3:tınhchukylenh:

Chukıcuacaclenh:

Thờigianthựchiệncủacáckhối

Ke�ulenh Instrution

Memory

Đocthanh

ALU 200ps

Load 200ps

Store 200ps

Branch 200ps

Jump 200ps

Nhưvay,thơigianto� ithie�uca� nđe� MIPSxưlıđươcta� tcacaclenhla

lenhdainha� tlaLW).

Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,Nguy

14

Thờigianthựchiệncủacáckhối:

Đocthanh

ghi

Lenh

ALU

Data

Mem

Ghivao

thanhghi

150ps 500ps X 150ps

150ps 500ps 200ps 150ps

150ps 500ps 200ps x

150ps 500ps x x

150ps x x x

thơigianto� ithie�uca� nđe� MIPSxưlıđươcta� tcacaclenhla1200ps

p,NguyễnVănThiện

Ghivao

thanhghi

To� ng

150ps 1000ps

150ps 1200ps

x 1050ps

x 850ps

x 350ps

1200ps(La�ythơigiancua

Page 15: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

15

2.4Viếttestbench

Mụcđíchkiểmtrakếtquảthựchiệncủatấtcảcáclệnh:LW,SW,J,JR,BNE,XORI,

ADD,SUB,vàSLT,ANDI,JAL,BEQ

FileInstrMem.datchưacacđoanlenhđadichsangmamayđe� test:

AddressMachine

CodeInstruction

00000000

00000004

00000008

0000000c

00000010

00000014

00000018

0000001c

00000020

00000024

00000028

0000002c

00000030

00000034

00000038

0000003c

00000040

00000044

00000048

0000004c

00000050

00000054

00000000

8c020000

8c030004

00432020

00822820

00a43022

00c5382a

00e64024

39090007

312a000f

0c00000c

01287820

03e05820

8c0c0000

11820002

8c020000

8c030004

8c100007

15820001

14620002

8c020000

8c030008

Begin:

nop

lw$2,0x00($0) #TestLW

lw$3,0x04($0)

add$4,$2,$3 #TestAddNoiJRsenhayve

add$5,$4,$2 #TestSub

sub$6,$5,$4

slt$7,$6,$5 #TestSLT

and$8,$7,$6 #TestAnd

xori$9,$8,7 #TestXori,andi

andi$10,$9,15

jalread31 #TestJAL

add$t7,$t1,$t0 #Themvaodetestconhayhaykhong

read31:

add$11,$31,$0

lw$12,0x00($0) #&12=$2=2

beq$12,$2,TestBEQ#TestBEQ(Branch)

lw$2,0x00($0)

lw$3,0x04($0)

TestBEQ:

lw$s0,0x07($0)

bne$12,$2,TestBNE1#TestBNE:$12=&2=>NotBranch

bne$3,$2,TestBNE

TestBNE1:

lw$2,0x00($0)

lw$3,0x08($0)

TestBNE:

Page 16: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

16

00000058

0000005c

00000060

00000064

00000068

0000006c

00000070

00000074

00000078

ac03000c

00000000

00000000

0800001d

00000000

00000000

00000000

8c11000c

02200008

sw$3,0x0C($0) #TestSW

nop

nop

jTestJR #TestJ

nop

nop

nop

TestJR:

lw$s1,0x0C($0) #s0=8

jr$s1 #TestJR

Testbench:

`timescale1ps/100fs`include"MIPSSingleCycle.v"moduleTEST_MIPSSingleCycle(); regclk,reset; MIPSSingleCycleMIPS_CPU(clk,reset); initialbegin $monitor($time,"clk=%b,reset=%b",clk,reset); reset=0; clk=1; #50 reset=1; #50 reset=0;end always#4500clk=~clk;endmodule//Chọnclk=4500psđểthỏamãnthờigianhoàntất1lệnhcủaMIPS

CÁCKẾTQUẢMÔPHỎNG

1. KhốiMIPControl:La�nlươtchocacđa�uvaolaOpcodevaFuncttươngưngvơicaclenh

FormatR,JR,LW,SW,BNE,BEQ,XORI,ANDI,JAL,J.Vasosanhke� tquavơibang1.

2.

Page 17: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

17

3. KhốiALUControl:La�nlươtđưacacgiatricuaALUOp(la�ytưMIPCTL)vaFunctđe�

kie�mtraxemgiatriALUControlcođungvơibang2haykhông.

Page 18: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

18

4. KếtquảmôphỏngcủaMIPSingleCycle:

Page 19: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

19

Phầnnhậnxét:

Dưatrencacke� tquamophongthımoduleMIPSingleCyclecuanhomđathưc

hienđươccaccaulenhchınhxac.Tuynhienconconhưngnhươcđie�mlachưa

tınhtoanto� iưuđươcthơigiantre� cuacaclenh.

Nhưngnhươcđie�mseđươctımhie�uvagiaiquye� ttrươckhitie�nhanhthưchien

ModulePipeline.

Page 20: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

20

Phầnphụlục:

Bảng1:

Instruction RegDest ALUSrc MemToReg RegWrite MemRead MemWrite BranchNE BranchEQ Jump JumpReg SignExtend ALUOp Opcode funct funct[5:0]

ADD 1 0 0 1 0 0 0 0 0 0 0 add 0x00 0x20 10 0000

SUB 1 0 0 1 0 0 0 0 0 0 0 sub 0x00 0x22 10 0010

SLT 1 0 0 1 x x 0 0 0 0 x slt 0x00 0x2A 10 1010

JR 0 0 0 0 0 0 1 0 0 1 0 xx 0x00 0x08 00 1000

AND 1 0 0 1 0 0 0 0 0 0 0 and 0x00 0x24 10 0100

LW 0 1 1 1 1 0 0 0 0 0 1 add 0x23 xx 10 0011

SW x 1 x 0 0 1 0 0 0 0 1 add 0x2B xx 10 1011

BEQ x 0 x 0 0 0 1 1 0 0 1 sub 0x04 xx 00 0100

BNE x 0 x 0 x x 1 0 0 0 1 sub 0x05 xx 00 0101

XORI 0 1 0 1 x x 0 0 0 0 0 xor 0x0E xx 00 1110

ANDI 0 1 0 1 x x 0 0 0 0 0 and 0x0c xx 00 1100

J x x x x x x x 0 1 0 x xx 0x02 xx 00 0010

JAL 2 x x 1 x x x 0 1 0 x xx 0x03 xx 00 0011

*Ghichu:

Nhưngvitrıxxlalenhcothe� thưchienmakhongca�nthongquakho� iALU.

Nhưngvitrıđanhda�ulaxtưclakhongca�nquantamđe�ngiatricuabitđie�ukhie�nđovılenhseđitheo1pathkhac.

-

Page 21: Thiet Ke MIPS Single Cycle

ĐồánCấutrúcmáytính–Nhóm3–PhạmNgọcLuân,PhanNgọcĐiệp,NguyễnVănThiện

21

Bảng2:

ALUOp Funct field Operation

ALUOp2 ALUOp1 ALUOp0 F5 F4 F3 F2 F1 F0

0 0 0 1 0 0 0 0 0 000

0 0 0 1 0 0 0 1 0 010

0 0 0 1 0 1 0 1 0 011

0 0 0 0 0 1 0 0 0 001

0 0 0 1 0 0 1 0 0 100

0 0 1 x x x x x x 000

0 0 1 x x x x x x 000

0 1 0 x x x x x x 010

0 1 0 x x x x x x 010

0 1 1 x x x x x x 001

1 0 0 x x x x x x 100

1 1 1 x x x x x x 001

1 1 1 x x x x x x 001

*Ghichu:Nhưngvitrımauđoladolenhkhongca�nthưchienthongquakho� iALU,vıvaytacothe� choALUlamba� tcưlenhnaotuy

y.Ơ� đaynhomchonlenhXORvıđayla1trongnhưnglenhđơngiannha� ttrongALU.Ngoairacothe� chonlenhANDhoaccaclenh

khactuyvaongươithie� tke� .

---Hết---