Đồ án cấu trúc máy tính

32 1.3K 0
Đồ án cấu trúc máy tính

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt Project 1: MIPS 32 by 32 Register File Giới thiệu : - File ghi có nhiệm vụ dùng để lưu giữ giá trị tạm thời để phục vụ cho - trình tính toán xử lý sau File ghi gồm có 32 ghi từ R0 đến R31 ghi gồm có - 32 bits Các ghi xây dựng từ DFF với kích khởi sườn lên + Nhiệm vụ DFF tín hiệu reset = cho đầu Q = + đầu Q = d tín hiệu enable =  Vì ghi 32 bits xây dựng từ 32 DFF Sơ đồ khối: Read Register Read Register Write Register 32 Write Data Read Data 32 Read Data 32 RegWrite - Trong đó: + với bits Read Register xác định ghi nguồn thứ rs + với bits Read Register xác định ghi nguồn thứ hai rt Nhóm: Page Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt + với bits Write Register xác định ghi đích rd + Read data đọc liệu ghi rs + Read data đọc liệu ghi rt + Write data 32 bits liệu ghi vào ghi rd bits RegWrite - set = Từ bits để xác định ghi cần chọn ta sử dụng giải mã 5:32 Xây dựng giải mã 5:32 từ giãi mã 2:4 3:8 Nhóm: Page Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt Sơ đồ mạch của giải mã 2-4 3-8 : 2-into-4 decoder S1 S0 S1 S0 D0 D0 D1 D1 D2 D2 D3 D3 - Để đọc liệu từ ghi ta sử dụng multiplex 32-32 + Bộ mux32-32 xây dựng từ 32 mux32-1 mà mux32-1 xây dựng từ mux4-1 mux 8-1 Nhóm: Page Đồ án cấu trúc máy tính Nhóm: Page GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính Code Code Testbench cho file ghi: `timescale ps / 100 fs module RegFileStimulus(); parameter ClockDelay = 5000; reg [4:0] ReadRegister1, ReadRegister2, WriteRegister; Nhóm: Page GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt reg [31:0] WriteData; reg RegWrite, clk,reset; wire [31:0] ReadData1, ReadData2; integer i; regfile reg1(ReadData1,ReadData2,WriteData, ReadRegister1,ReadRegister2,WriteRegister,RegWrite,clk,reset); initial reset=0; initial clk = 0; always #(ClockDelay/2) clk = ~clk; initial begin $monitor($time, " ReadData1=%h, ReadData2=%h, WriteData=%h, WriteReg=%d, Reg1=%d, Reg2=%d, RegWrite=%b, clk=%b", ReadData1, ReadData2, WriteData, WriteRegister, ReadRegister1, ReadRegister2, RegWrite,clk); // ghi du lieu vao ghi for (i=1; i A – (-B) < (-A) – B > A 1 GVHD: Hồ Viết Việt B 1 Binvert 0 1 Bmux 1 Cin 1 Cout 1 Sum 1 Overflow 1 1 Cin Cout Sum Overflow 1 Bảng thu gọn A+B < (-A) + (-B) > 3.4 A B X X Binvert X X Bmux  Overflow = ~A*~Bmux*Cin + A*Bmux*~Cin Cờ Carryout : - Cờ carryout ALU bit thứ 31 Xác định bits slt : - Lệnh slt $t1,$t2,$t3 + Bit slt set rs < rt ngược lại + Do rs < rt => rs – rt < bits MSB Output , ta dựa vào xác định bits slt + Có trường hợp xảy : Khi không Overflow rs –rt < => MSB = Khi có Overflow rs – rt < => MSB =  Vd : 5ten – 6ten = 0101 – 0110 = 0101 + 1010 = 1111 (ok!) -7ten – 6ten = 1001 – 0110 = 1001 + 1010 = 0011 (overflow!) => bit slt= MSB xor Overflow Bảng thể mối quan hệ Slt MSB , Overflow Nhóm: Page 18 Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt A B Cin MSB Overflow Slt 0 0 0 0 1 0 1 1 0 0 1 1 0 1 0 1 1 1 Bảng Karnaugh AB AB AB AB Cin 00 01 11 10 0 1 1 0  Slt = AB + A*~Cin + B*~Cin Nhóm: Page 19 Đồ án cấu trúc máy tính ALU bit : 5.1 Carry-Lookaheader Nhóm: Page 20 GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính - GVHD: Hồ Viết Việt Sơ đồ sử dụng Ripple Carry tức sử dụng theo kiểu nối tiếp nên làm chậm trình xử lý tính toán khối ALU  Vì ta sử dụng phương pháp Carry Lookahead giúp cải thiện trình tính toán cờ nhớ Carry sử dụng theo phương pháp song song • Ta có cộng full adder 1bit : Nhóm: Page 21 Đồ án cấu trúc máy tính – GVHD: Hồ Viết Việt Đặt gi = bi pi = a i + bi  c1 = g + p0 • c0 c = g1 + p1 • g + p1 • p • c0 c3 = g + p • g1 + p • p1 • g + p • p1 • p • c …… c = g + p3 • g + p3 • p • g1 + p3 • p • p1 • g + p3 • p • p1 • p • c0 - Carry Lookaheader 16 bit xây dựng từ bits Vì adder 32 bit ALU gồm Carry Lookaheader 16 bits Nhóm: Page 22 Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt CarryIn a0 b0 a1 b1 a2 b2 a3 b3 CarryIn Result0 ALU0 P0 G0 pi gi Carry-lookahead unit C1 a4 b4 a5 b5 a6 b6 a7 b7 a8 b8 a9 b9 a10 b10 a11 b11 a12 b12 a13 b13 a14 b14 a15 b15 ci + CarryIn Result4 ALU1 P1 G1 pi + gi + C2 ci + CarryIn Result8 11 ALU2 P2 G2 pi + gi + C3 ci + CarryIn Result12 15 ALU3 P3 G3 pi + gi + C4 ci + CarryOut 5.2 Mux 4-1 : - Trong Alu bit ta phải sử dụng mux 4-1 để chọn đầu phép toán add , sub , xor , slt Bộ mux dựa vào bit ALU Control mà xác định đầu Nhóm: Page 23 Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt Code : `timescale ps / 100 fs module ALUStimulus(); parameter ClockDelay = 50000; reg [31:0] BussA, BussB; reg [1:0] ALUControl; wire [31:0] Output; wire zero, overflow, CarryOut, negative; ALU alu1(Output, CarryOut, zero, overflow, negative, BussA, BussB, ALUControl); initial begin $monitor($time, " ALUControl=%b, BussA=%h, BussB=%h, Output=%h, Zero=%b, CarryOut= %b, Overflow=%b, Negative=%b", ALUControl,BussA,BussB,Output,zero,CarryOut,overflow,negative); /* Addition unit testing */ ALUControl=00; BussA=32'h00000DEF; BussB=32'h00000ABC; // Should output 000018AB #(ClockDelay); BussA=32'h00001234; BussB=32'h00000105; // Should output 00001339 #(ClockDelay); BussA=32'h7FFFFFFF; BussB=32'h00000001; // Should output 80000000, overflow, negative #(ClockDelay); BussA=32'hC0000000; BussB=32'h60000000; // output 20000000 , carry #(ClockDelay); /* Subtraction unit testing */ ALUControl=10; BussA=32'h00000DEF; BussB=32'h00000ABC; // Should output 00000333 #(ClockDelay); BussA=32'h00001234; BussB=32'h00000105; // Should output 0000112F #(ClockDelay); BussA=32'h80000000; BussB=32'h00000001; // Should output 7FFFFFFF, overflow #(ClockDelay); BussA=32'h00000003; BussB=32'h00000007; // carry , negative , fffffffc #(ClockDelay); BussA=32'h0000125A; BussB=32'h0000125A; // output , zero #(ClockDelay); BussA=32'h40000000; BussB=32'hA0000000; // Should output A0000000, overflow , carry ,negative #(ClockDelay); /* Xor */ ALUControl=01; BussA=32'h12000042; BussB=32'h51240002; // output 43240040 #(ClockDelay); BussA=32'h0AB0F04D; BussB=32'h12EC897E; // output 185C7933 #(ClockDelay); end endmodule // ALU module ALU(Output, CarryOut, zero, overflow, negative, BussA, BussB, ALUControl); input[31:0]BussA,BussB; input[1:0] ALUControl; output[31:0] Output; output CarryOut, zero, overflow, negative; wire [15:0] p0,p1,g0,g1; wire[15:1] ci0,ci1; wire gnd=0; wire nega=1; wire B31mux; alu_1b f0(BussA[0],BussB[0],ALUControl[1],ALUControl[1],ALUControl,slt,g0[0],p0[0],Output[0]); alu_1b f1(BussA[1],BussB[1],ALUControl[1],ci0[1],ALUControl,gnd,g0[1],p0[1],Output[1]); alu_1b f2(BussA[2],BussB[2],ALUControl[1],ci0[2],ALUControl,gnd,g0[2],p0[2],Output[2]); alu_1b f3(BussA[3],BussB[3],ALUControl[1],ci0[3],ALUControl,gnd,g0[3],p0[3],Output[3]); alu_1b f4(BussA[4],BussB[4],ALUControl[1],ci0[4],ALUControl,gnd,g0[4],p0[4],Output[4]); alu_1b f5(BussA[5],BussB[5],ALUControl[1],ci0[5],ALUControl,gnd,g0[5],p0[5],Output[5]); Nhóm: Page 24 Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt alu_1b f6(BussA[6],BussB[6],ALUControl[1],ci0[6],ALUControl,gnd,g0[6],p0[6],Output[6]); alu_1b f7(BussA[7],BussB[7],ALUControl[1],ci0[7],ALUControl,gnd,g0[7],p0[7],Output[7]); alu_1b f8(BussA[8],BussB[8],ALUControl[1],ci0[8],ALUControl,gnd,g0[8],p0[8],Output[8]); alu_1b f9(BussA[9],BussB[9],ALUControl[1],ci0[9],ALUControl,gnd,g0[9],p0[9],Output[9]); alu_1b f10(BussA[10],BussB[10],ALUControl[1],ci0[10],ALUControl,gnd,g0[10],p0[10],Output[10]); alu_1b f11(BussA[11],BussB[11],ALUControl[1],ci0[11],ALUControl,gnd,g0[11],p0[11],Output[11]); alu_1b f12(BussA[12],BussB[12],ALUControl[1],ci0[12],ALUControl,gnd,g0[12],p0[12],Output[12]); alu_1b f13(BussA[13],BussB[13],ALUControl[1],ci0[13],ALUControl,gnd,g0[13],p0[13],Output[13]); alu_1b f14(BussA[14],BussB[14],ALUControl[1],ci0[14],ALUControl,gnd,g0[14],p0[14],Output[14]); alu_1b f15(BussA[15],BussB[15],ALUControl[1],ci0[15],ALUControl,gnd,g0[15],p0[15],Output[15]); alu_1b f16(BussA[16],BussB[16],ALUControl[1],ci16,ALUControl,gnd,g1[0],p1[0],Output[16]); alu_1b f17(BussA[17],BussB[17],ALUControl[1],ci1[1],ALUControl,gnd,g1[1],p1[1],Output[17]); alu_1b f18(BussA[18],BussB[18],ALUControl[1],ci1[2],ALUControl,gnd,g1[2],p1[2],Output[18]); alu_1b f19(BussA[19],BussB[19],ALUControl[1],ci1[3],ALUControl,gnd,g1[3],p1[3],Output[19]); alu_1b f20(BussA[20],BussB[20],ALUControl[1],ci1[4],ALUControl,gnd,g1[4],p1[4],Output[20]); alu_1b f21(BussA[21],BussB[21],ALUControl[1],ci1[5],ALUControl,gnd,g1[5],p1[5],Output[21]); alu_1b f22(BussA[22],BussB[22],ALUControl[1],ci1[6],ALUControl,gnd,g1[6],p1[6],Output[22]); alu_1b f23(BussA[23],BussB[23],ALUControl[1],ci1[7],ALUControl,gnd,g1[7],p1[7],Output[23]); alu_1b f24(BussA[24],BussB[24],ALUControl[1],ci1[8],ALUControl,gnd,g1[8],p1[8],Output[24]); alu_1b f25(BussA[25],BussB[25],ALUControl[1],ci1[9],ALUControl,gnd,g1[9],p1[9],Output[25]); alu_1b f26(BussA[26],BussB[26],ALUControl[1],ci1[10],ALUControl,gnd,g1[10],p1[10],Output[26]); alu_1b f27(BussA[27],BussB[27],ALUControl[1],ci1[11],ALUControl,gnd,g1[11],p1[11],Output[27]); alu_1b f28(BussA[28],BussB[28],ALUControl[1],ci1[12],ALUControl,gnd,g1[12],p1[12],Output[28]); alu_1b f29(BussA[29],BussB[29],ALUControl[1],ci1[13],ALUControl,gnd,g1[13],p1[13],Output[29]); alu_1b f30(BussA[30],BussB[30],ALUControl[1],ci1[14],ALUControl,gnd,g1[14],p1[14],Output[30]); alu_1b f31(BussA[31],BussB[31],ALUControl[1],ci1[15],ALUControl,gnd,g1[15],p1[15],Output[31]); // xac dinh cac bit g,p cua bo 16b calook_16b d1(ALUControl[1],p0,g0,ci0,gg0,pg0); calook_16b d2(ci16,p1,g1,ci1,gg1,pg1); // xac dinh carryout and and0(pre_c16,pg0,ALUControl[1]); or or0(ci16,pre_c16,gg0); // c1= g0 + p0*c0 and and1(pre_c32_1,pg1,gg0); // c2= g1+ p1*g0 + p1*p0*c0 and and2(pre_c32_2,pg0,pg1,ALUControl[1]); or or1(carryOut,pre_c32_1,pre_c32_2,gg1); chonb pl(carryOut,ALUControl[1],CarryOut0); not an1(notcary,ALUControl[0]); // de loai bo carry xor va slt ko can hien thi and an2(CarryOut,notcary,CarryOut0); // xac dinh bit slt chonb q4(BussB[31],ALUControl[1],B31mux); sslt q1(BussA[31],B31mux,ci1[15],slt); // xac dinh flag zero testzero q2(Output,zero); // xac dinh overflow oveflows q3(BussA[31],B31mux,ci1[15],overflow0); and t1(overflow,notcary,overflow0); // xac dinh negative and an(negative,Output[31],nega); endmodule module alu_1b(a,b,bsel,cin,opcode,slt,g,p,result); input a,b,bsel,cin,slt; input[1:0] opcode; output g,p,result; wire rxor,bchon; chonb f1(b,bsel,bchon); pfa f2(a,bchon,cin,g,p,sum); xor s(rxor,a,bchon); mux4_1 f3({slt,sum,rxor,sum},result,opcode); endmodule module testzero(result,zeroflag); Nhóm: Page 25 Đồ án cấu trúc máy tính input[31:0] result; output zeroflag; or o1(r1,result[3],result[2],result[1],result[0]), o2(r2,result[7],result[6],result[5],result[4]), o3(r3,result[11],result[10],result[9],result[8]), o4(r4,result[15],result[14],result[13],result[12]), o5(r5,result[19],result[18],result[17],result[16]), o6(r6,result[23],result[22],result[21],result[20]), o7(r7,result[27],result[26],result[25],result[24]), o8(r8,result[31],result[30],result[29],result[28]), o9(r9,r1,r2,r3,r4), o10(r10,r5,r6,r7,r8), o11(rt,r9,r10); not n(zeroflag,rt); endmodule module chonb(b,bsel,bchon); input b,bsel; output bchon; xor x1(bchon,b,bsel); endmodule module sslt(a,b,cin,bitslt); input a,b,cin; output bitslt; not n(ncin,cin); and a1(ab,a,b), a2(a_ncin,a,ncin), a3(b_ncin,b,ncin); or o1(bitslt,ab,a_ncin,b_ncin); endmodule module oveflows(a,b,cin,overflow_flag); input a,b,cin; output overflow_flag; not n1(na,a), n2(nb,b), n3(ncin,cin); and a1(t1,na,nb,cin), a2(t2,a,b,ncin); or o1(overflow_flag,t1,t2); endmodule module negative(msb,negati_flag); input msb; output negati_flag; wire t=1'b1; and a(negati_flag,msb,t); endmodule module pfa(a,b,cin,g,p,sum); input a,b,cin; output g,p,sum; and a1(g,a,b); or o1(p,a,b); xor x1(sum,a,b,cin); endmodule module calook_4b(cin,p,g,c1,c2,c3,gr,pr); input cin; input[3:0] g,p; output c1,c2,c3,gr,pr; ci_pg n1(g[0],p[0],cin,c1); ci_pg n2(g[1],p[1],c1,c2); ci_pg n3(g[2],p[2],c2,c3); pg4 s1(g,p,gr,pr); endmodule Nhóm: Page 26 GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính module calook_16b(cin,p,g,ci,g_out,p_out); input cin; input [15:0] p,g; output [15:1] ci; output g_out,p_out; wire[3:0] gr,pr; calook_4b n1(cin,p[3:0],g[3:0],ci[1],ci[2],ci[3],gr[0],pr[0]); ci_pg w1(gr[0],pr[0],cin,ci[4]); calook_4b n2(ci[4],p[7:4],g[7:4],ci[5],ci[6],ci[7],gr[1],pr[1]); ci_pg w2(gr[1],pr[1],ci[4],ci[8]); calook_4b n3(ci[8],p[11:8],g[11:8],ci[9],ci[10],ci[11],gr[2],pr[2]); ci_pg w3(gr[2],pr[2],ci[8],ci[12]); calook_4b n4(ci[12],p[15:12],g[15:12],ci[13],ci[14],ci[15],gr[3],pr[3]); pg4 k1(gr,pr,g_out,p_out); endmodule module ci_pg(gi,pi,ci,ci_out); input gi,pi,ci; output ci_out; and a1(t,pi,ci); or o1(ci_out,gi,t); endmodule module pg4(g,p,g_out,p_out); input[3:0] g,p; output g_out,p_out; and a7(p_out,p[3],p[2],p[1],p[0]); and a8(gr1,p[3],g[2]), a9(gr2,p[3],p[2],g[1]), a10(gr3,p[3],p[2],p[1],g[0]); or o4(g_out,g[3],gr1,gr2,gr3); endmodule Kết mô : Nhóm: Page 27 GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt Project 3:MIPS Single-Cycle CPU Giới thiệu : - Ở project trước hoàn thành xong khối RegFile ALU Trong project kết hợp chúng lại với để hoàn thành CPU đơn giản thực lệnh : LW , SW , J , BNE, ADD , SUB , XOR SLT Sơ đồ khối : Instruction [25– 0] 26 Shift left Jump address [31– 0] 28 M u x M u x ALU Add result Zero ALU ALU result Address PC+4 [31– 28] Add Instruction [31– 26] PC Instruction [25– 21] Read address Read register Instruction [20– 16] Instruction [31– 0] Instruction memory Control Instruction [15– 11] Shift left RegDst Jump Branch MemRead MemtoReg ALUOp MemWrite ALUSrc RegWrite M u x Read data Read register Registers Read Write data register M u x Write data Write data Instruction [15– 0] 16 Instruction [5– 0] Nhóm: Page 28 Sign extend 32 ALU control Read data Data memory M u x Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt 2.1 Giới thiệu khối : - Instruction : khối chứa lệnh để CPU thực thi - Data memory : nhớ liệu CPU - Register : 32 ghi phục vụ cho việc thực thi lệnh - ALU : khối tính toán xử lý trung tâm - MainControl : cung cấp tín hiệu điều khiển cho CPU - Ngoài có khối nhỏ khác giúp hoàn thiện trình xử lý CPU - Trong CPU khối quan trọng khối MainControl , khối cung cấp toàn tín hiệu điều khiển CPU hoạt động xác Khối MainControl : - Có đầu vào bits trường Opcode bit [31:26] instruction Và có đầu tín hiệu điều khiển : + j : bit xác định lệnh J thực + Branch : bit xác định lệnh BNE + RegDst : bit xác định ghi đích file ghi + Alusrc : bit xác định chọn đầu vào thứ hai cho khối ALU + Memtoreg : bit xác định đầu Writedata + Regwrite : bit để xác định có ghi liệu vào ghi hay không + Memread : bit xác định đọc liệu từ nhớ + Memwrite : bit xác định ghi liệu vào nhớ + AluOp : bit làm đầu vào khối ALUcontrol cho Bit alucontrol bit xác định phép toán cần thực Bảng xác định bit : INSTR OP [5:0] J Regdst Alusrc Memto reg Reg write Mem read Mem write bran R 000000 0 0 LW 100011 0 1 1 0 SW 101011 X X 0 BNE 000101 X X 0 J 000010 X X X 0 X Nhóm: Page 29 Aluop [1:0] 10 00 00 01 XX Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt Khối ALUcontrol : Instr ALUOp [1:0] AluFunction[5:0] LW , SW 00 XXXXXX BNE 01 XXXXXX R 1X XX0000 R 1X XX0110 R 1X XX0010 R 1X XX1010  OPER [1] =  OPER [0] = Nhóm: Page 30 Operation[1:0] 00 10 00 01 10 11 Đồ án cấu trúc máy tính MÔ PHỎNG CÁC LỆNH SẼ THỰC HIỆN : QUAY : NHAY : EXIT : LW $16 , 4($17) LW $18, 8($17) BNE $16, $18,NHAY SW $18, 24($17) LW $11, 24($17) J NEXT ADD $19, $16, $18 J QUAY XOR $20, $16, $19 SLT $8 , $18, $20 SW $8 , 28($17) SUB $10, $18, $16 LW $12, 8($10) LW $13, 28($17) - Giả sử ô nhớ có liệu: datamem[0]=32'd0; datamem[1]=32'd6; datamem[2]=32'd14; datamem[3]=32'd6; datamem[4]=32'd99; datamem[5]=32'd5; - Đây mã máy vào khối Instruction instrmem[0]=32'h8E300004; instrmem[1]=32'h8E320008; instrmem[2]=32'h16120003; instrmem[3]=32'hAE320018; instrmem[4]=32'h8E2B0018; instrmem[5]=32'h08000008; instrmem[6]=32'h02129820; instrmem[7]=32'h08000003; instrmem[8]=32'h0213A026; instrmem[9]=32'h0254402A; instrmem[10]=32'hAE28001C; instrmem[11]=32'h02505022; instrmem[12]=32'h8D4C0008; instrmem[13]=32'h8E2D001C; CODE : Nhóm: Page 31 GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính Nhóm: Page 32 GVHD: Hồ Viết Việt [...]... Nhóm: Page 18 Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt A B Cin MSB Overflow Slt 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 1 0 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 1 Bảng Karnaugh AB AB AB AB Cin 00 01 11 10 0 0 1 1 1 1 0 0 1 0  Slt = AB + A*~Cin + B*~Cin Nhóm: Page 19 Đồ án cấu trúc máy tính 5 ALU 1 bit : 5.1 Carry-Lookaheader Nhóm: Page 20 GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính - GVHD:... trúc máy tính - GVHD: Hồ Viết Việt Sơ đồ trên sử dụng Ripple Carry tức là sử dụng theo kiểu nối tiếp nên sẽ làm chậm quá trình xử lý tính toán của khối ALU  Vì vậy ta sẽ sử dụng phương pháp Carry Lookahead sẽ giúp cải thiện quá trình tính toán vì cờ nhớ Carry được sử dụng theo phương pháp song song • Ta có bộ cộng full adder 1bit : Nhóm: Page 21 Đồ án cấu trúc máy tính – GVHD: Hồ Viết Việt Đặt gi = ai... mô phỏng Nhóm: Page 15 GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt Project 2 : MIPS ALU 1 Giới thiệu : - Trong project này chúng ta xây dựng khối ALU 32 bits với nhiệm vụ thực hiện các lệnh số học đơn giản như ADD, SUB , XOR , SLT - ALU 32 bits được xây dựng từ 32 bộ alu 1 bit - Đây là khối xử lý mọi công việc tính toán của bộ vi xử lý 2 Sơ đồ khối : Bus A 32 32 32 bit ALU Bus B Zero... CarryOut ALU Control Nhóm: Page 16 Output Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt ALU CONTROL LINES 00 01 10 11 FUNCTION Add XOR Sub SLT Nguyên lý hoạt động của khối ALU: - Khối ALU có 2 đầu vào A,B mỗi đầu vào 32 bits - Khối ALU sẽ dựa vào 2 bits ALU Control mà sẽ xác định phép toán cần xử lý Vd: ALU Control = 10 thì sẽ thực hiện phép A – B - Kết quả các phép toán sẽ được đưa ra ở Output 32 bits - Ngoài... Nhóm: Page 28 Sign extend 32 ALU control Read data Data memory 1 M u x 0 Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt 2.1 Giới thiệu các khối : - Instruction : đây là khối chứa các lệnh để CPU thực thi - Data memory : đây là bộ nhớ dữ liệu của CPU - Register : là 32 thanh ghi phục vụ cho việc thực thi lệnh - ALU : đây là khối tính toán xử lý trung tâm - MainControl : cung cấp tín hiệu điều khiển cho CPU... ALU3 P3 G3 pi + 3 gi + 3 C4 ci + 4 CarryOut 5.2 Mux 4-1 : - Trong bộ Alu 1 bit ta phải sử dụng bộ mux 4-1 để chọn đầu ra của một trong 4 phép toán add , sub , xor , slt Bộ mux sẽ dựa vào 2 bit ALU Control mà sẽ xác định đầu ra Nhóm: Page 23 Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt 6 Code : `timescale 1 ps / 100 fs module ALUStimulus(); parameter ClockDelay = 50000; reg [31:0] BussA, BussB; reg [1:0]... : Nhóm: Page 27 GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt Project 3:MIPS Single-Cycle CPU 1 Giới thiệu : - Ở 2 project trước chúng ta đã hoàn thành xong các khối RegFile và ALU Trong project này chúng ta sẽ kết hợp chúng lại với nhau để hoàn thành một bộ CPU đơn giản có thể thực hiện các lệnh như : LW , SW , J , BNE, ADD , SUB , XOR và SLT 2 Sơ đồ khối : Instruction [25– 0] 26 Shift... Overflow : - Cờ Overflow chỉ xuất hiện trong các trường hợp sau : Phép toán A+B A+B A–B A B A ≥0 ... A*~Cin + B*~Cin Nhóm: Page 19 Đồ án cấu trúc máy tính ALU bit : 5.1 Carry-Lookaheader Nhóm: Page 20 GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính - GVHD: Hồ Viết Việt Sơ đồ sử dụng Ripple Carry tức... 32 mux32-1 mà mux32-1 xây dựng từ mux4-1 mux 8-1 Nhóm: Page Đồ án cấu trúc máy tính Nhóm: Page GVHD: Hồ Viết Việt Đồ án cấu trúc máy tính Code Code Testbench cho file ghi: `timescale ps / 100... Đây khối xử lý công việc tính toán vi xử lý Sơ đồ khối : Bus A 32 32 32 bit ALU Bus B Zero 32 Overflow CarryOut ALU Control Nhóm: Page 16 Output Đồ án cấu trúc máy tính GVHD: Hồ Viết Việt ALU

Ngày đăng: 22/01/2016, 19:39

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan