CPU设计实验报告文档(英文版)
cpu中央处理器中英文对照外文翻译文献

中英文资料翻译中央处理器设计摘要CPU(中央处理单元)是数字计算机的重要组成部分,其目的是对从内存中接收的指令进行译码,同时对存储于内部寄存器、存储器或输入输出接口单元的数据执行传输、算术运算、逻辑运算以及控制操作。
在外部,CPU为转换指令数据和控制信息提供一个或多个总线并从组件连接到它。
在通用计算机开始的第一章,CPU作为处理器的一部分被屏蔽了。
但是CPU有可能出现在很多电脑之间,小,相对简单的所谓微控制器的计算机被用在电脑和其他数字化系统中,以执行限制或专门任务。
例如,一个微控制器出现在普通电脑的键盘和检测器中,但是这些组件也被屏蔽。
在这种微控制器中,与我们在这一章中所讨论的CPU可能十分不同。
字长也许更短,(或者说4或8个字节),编制数量少,指令集有限。
相对而言,性能差,但对完成任务来说足够了。
最重要的是它的微控制器的成本很低,符合成本效益。
在接下去的几页里,我考虑的是两个计算机的CPU,一个是一个复杂指令集计算机( CISC),另一个是精简指令集计算机(RISC)。
在详细的设计检查之后,我们比较了两个CPU的性能,并提交了用来提高性能的一些方法的简要概述。
最后,我们讨论了关于一般数字系统设计的设计思路。
1.双CPU的设计正如我们前一章提到的,一个典型的CPU通常被分成两部分:数据路径和控制单元。
该数据路径由一个功能单元、登记册和内部总线组成,为在功能单元、存储器以及其他计算机组件之间提供转移信息的途径。
这个数据途径有可能是流水线,也有可能不是。
控制单元由一个程序计数器,一个指令寄存器,控制逻辑,和可能有其他硬或微程序组成。
如果数据途径是流水线那么控制单元也有可能是流水线。
电脑的CPU是一个部分,要么是复杂指令集计算机( CISC),要么是精简指令集计算机(RISC),有自己的指令集架构。
本章的目的是提交两个CPU的设计,用来说明指令集,数据路径,和控制单元的构造特征的合并。
该设计将自上而下,但随着先前组件设计的重新使用,来说明指令集构架在数据路径和控制单元上的影响,数据路径上的单元的影响力。
实验4 简单CPU设计与仿真

预做实验报告4简单CPU设计与仿真一、实验目的理解并掌握CPU的基本电路结构及其设计方法,学会使用Verilog HDL对电路进行行为建模、结构建模以及仿真测试。
二、实验内容利用Verilog HDL设计一个简单的CPU模型,并进行仿真测试。
要求该处理机能够实现下列指令系统:31262521201615540指令000000rd rs1rs2and rd,rs1,rs2 000001rd rs1imme andi rd,rs1,imme 000010rd rs1rs2or rd,rs1,rs2 000011rd rs1imme ori rd,rs1,imme 000100rd rs1rs2add rd,rs1,rs2 000101rd rs1imme addi rd,rs1,imme 000110rd rs1rs2sub rd,rs1,rs2 000111rd rs1imme subi rd,rs1,imme 001000rd rs1imme load rd,rs1,imme 001001rd rs1imme store rd,rs1,imme 001010disp bne disp001011disp beq disp001100disp branch disp 要求把指令的执行分为以下5个步骤,每个步骤用一个时钟周期。
1、取指令及PC+1周期2、指令译码、读寄存器及转移周期3、ALU执行或者存储器地址计算周期4、ALU指令结束周期或者存储器访问周期5、写回周期三、实验环境PC机1台、Modelsim仿真软件1套。
四、实验步骤1、电路结构设计与逻辑设计多周期处理机的总体电路图P C寄存器堆ALUABZERO 存储器Addres sDataou t Detain CSOEWE WRITEMEMALUOPZEROWRITEZEROM U XM U X M U X1偏移量符号扩展立即数符号扩展WRITEREG DI AD A1A2Q2Q1SELLOADSELST偏移量立即数Rd rs1rs2RdWRITEPCM U XI RM U XSELLDSTSELALUASELALUBAB IM WRITEIRZEROOPCODE 控制部件控制信2、建立Verilog 模型module TOP(clk,rst,start,memwe,memin,memaddr,zero,n,v,c,dataout);input clk,rst,start,memwe;input [31:0]memin;input [4:0]memaddr;output [31:0]dataout;output n,v,c,zero;wire clk,rst;wire writepc,selldst,writemem,writeir,selload,selst,writereg,selalua,writezero;wire [5:0]opcode;wire [1:0]aluop,selalub;wire zero;datapathu0(writepc,selldst,writemem,writeir,selload,selst,writereg,selalua,selalub,aluop,w ritezero,clk,rst,memin,memaddr,memwe,zero,n,v,c,opcode,dataout);controlu1(clk,start,zero,opcode,writepc,selldst,writemem,writeir,selload,selst,writereg,se lalua,selalub,aluop,writezero);endmodulemoduledatapath(writepc,selldst,writemem,writeir,selload,selst,writereg,selalua,selalub,alZEROuop,writezero,clk,rst,memin,memaddr,memwe,zero,n,v,c,opcode,dataout); inputwritepc,selldst,writemem,writeir,selload,selst,writereg,selalua,writezero,clk,rst,m emwe;input[1:0]selalub,aluop;input[4:0]memaddr;input[31:0]memin;output zero,n,v,c;output[5:0]opcode;output[31:0]dataout;wire[4:0]pcout,address,memaddr,mux3out;wire[31:0]memin,mux4out,mux5out,imme,disp;wire memwe,zero1;wire[31:0]dataout,Q1,datain,irout,f,aluout;pc pc1(pcout,aluout[4:0],writepc,clk,rst);mux21_5mux1(address,pcout,aluout[4:0],selldst);memorymem(dataout,datain,address,writemem,memin,memaddr,memwe,clk,rst);//memin,memaddr,memweÊÇΪÁËÔڼĴæÆ÷ÖÐÊäÈëÊý¾Ý¶øÓÃir ir1(irout,dataout,clk,rst,writeir);mux21_32mux2(f,aluout,dataout,selload);mux21_5mux3(mux3out,irout[4:0],irout[25:21],selst);registerfileregisterfile(Q1,datain,f,clk,rst,writereg,irout[25:21],irout[20:16],mux3out); mux21_32mux4(mux4out,Q1,{27'b0,pcout},selalua);assignimme={irout[15],irout[15],irout[15],irout[15],irout[15],irout[15],irout[15],irout[1 5],irout[15],irout[15],irout[15],irout[15],irout[15],irout[15],irout[15],irout[15],iro ut[15:0]};assigndisp={irout[25],irout[25],irout[25],irout[25],irout[25],irout[25],irout[25:0]}; mux41_32mux5(mux5out,datain,imme,32'd1,disp,selalub);ALU alu1(aluop,mux4out,mux5out,aluout,n,v,c,zero1);dff zeroflag(zero,zero1,clk,rst,writezero);assign opcode=irout[31:26];endmodulemodulecontrol(clk,start,zero,opcode,writepc,selldst,writemem,writeir,selload,selst,writer eg,selalua,selalub,aluop,writezero);input clk,start,zero;input[5:0]opcode;output writepc,selldst,writemem,writeir,selload,selst,writereg,selalua,writezero;output[1:0]selalub,aluop;reg[3:0]q;wire[3:0]d;wire zero;always@(posedge clk)beginif(start)q<=4'd0;elseq<=d;endassignd[0]=(~q[3]&~q[2]&~q[1]&~q[0])|((~q[3]&~q[2]&~q[1]&q[0])&(~opcode[3]&op code[0]))|((~q[3]&~q[2]&~q[1]&q[0])&(opcode[3]&~opcode[2]&~opcode[1]&op code[0]))|(~q[3]&~q[2]&q[1]&q[0])|(~q[3]&q[2]&~q[1]&q[0]);assignd[1]=((~q[3]&~q[2]&~q[1]&q[0])&(~opcode[3]&~opcode[0]))|((~q[3]&~q[2]&~q [1]&q[0])&(~opcode[3]&opcode[0]))|(~q[3]&~q[2]&q[1]&~q[0])|(~q[3]&~q[2]& q[1]&q[0])|(q[3]&~q[2]&~q[1]&~q[0]);assignd[2]=((~q[3]&~q[2]&~q[1]&q[0])&(opcode[3]&~opcode[2]&~opcode[1]&~opcod e[0]))|((~q[3]&~q[2]&~q[1]&q[0])&(opcode[3]&~opcode[2]&~opcode[1]&opcod e[0]))|(~q[3]&~q[2]&q[1]&~q[0])|(~q[3]&~q[2]&q[1]&q[0]);assignd[3]=(~q[3]&q[2]&~q[1]&~q[0])|(~q[3]&q[2]&~q[1]&q[0])|(q[3]&~q[2]&~q[1]& ~q[0]);assignwritepc=(~q[3]&~q[2]&~q[1]&~q[0])|((~q[3]&~q[2]&~q[1]&q[0])&((opcode[3]& opcode[2]&~opcode[1]&~opcode[0])|(opcode[3]&~opcode[2]&opcode[1]&~opco de[0]&~zero)|(opcode[3]&~opcode[2]&opcode[1]&opcode[0]&zero)));assignselldst=(~q[3]&q[2]&~q[1]&~q[0])|(~q[3]&q[2]&~q[1]&q[0])|(q[3]&~q[2]&~q[1] &~q[0])|(q[3]&~q[2]&~q[1]&q[0])|(q[3]&~q[2]&q[1]&~q[0]);assign writemem=q[3]&~q[2]&~q[1]&q[0];assign writeir=~q[3]&~q[2]&~q[1]&~q[0];assignselload=(~q[3]&q[2]&~q[1]&~q[0])|(q[3]&~q[2]&~q[1]&~q[0])|(q[3]&~q[2]&q[1] &~q[0]);assign selst=(~q[3]&q[2]&~q[1]&q[0])|(q[3]&~q[2]&~q[1]&q[0]);assignwritereg=(~q[3]&q[2]&q[1]&~q[0])|(~q[3]&q[2]&q[1]&q[0])|(q[3]&~q[2]&q[1] &~q[0]);assign selalua=(~q[3]&~q[2]&~q[1]&~q[0])|(~q[3]&~q[2]&~q[1]&q[0]); assign selalub[1]=(~q[3]&~q[2]&~q[1]&~q[0])|(~q[3]&~q[2]&~q[1]&q[0]);assignselalub[0]=(~q[3]&~q[2]&~q[1]&q[0])|(~q[3]&~q[2]&q[1]&q[0])|(~q[3]&q[2]&~ q[1]&~q[0])|(~q[3]&q[2]&~q[1]&q[0])|(~q[3]&q[2]&q[1]&q[0])|(q[3]&~q[2]&~q [1]&~q[0])|(q[3]&~q[2]&~q[1]&q[0])|(q[3]&~q[2]&q[1]&~q[0]);assign writezero=(~q[3]&q[2]&q[1]&~q[0])|(~q[3]&q[2]&q[1]&q[0]);assignaluop[1]=(~q[3]&~q[2]&~q[1]&~q[0])|(~q[3]&~q[2]&~q[1]&q[0])|((~q[3]&~q[2] &q[1]&~q[0])&(~opcode[3]&opcode[2]))|((~q[3]&~q[2]&q[1]&q[0])&(~opcode[ 3]&opcode[2]))|(~q[3]&q[2]&~q[1]&~q[0])|(~q[3]&q[2]&~q[1]&q[0])|((~q[3]&q[2]&q[1]&~q[0])&(~opcode[3]&opcode[2]))|((~q[3]&q[2]&q[1]&q[0])&(~opcode[3]&opcode[2]))|(q[3]&~q[2]&~q[1]&~q[0])|(q[3]&~q[2]&~q[1]&q[0])|(q[3]&~q[ 2]&q[1]&~q[0]);assignaluop[0]=((~q[3]&~q[2]&q[1]&~q[0])&(~opcode[3]&opcode[1]))|((~q[3]&~q[2] &q[1]&q[0])&(~opcode[3]&opcode[1]))|((~q[3]&q[2]&q[1]&~q[0])&(~opcode[3] &opcode[1]))|((~q[3]&q[2]&q[1]&q[0])&(~opcode[3]&opcode[1])); endmodulemodule memory(dataout,datain,address,we,memin,memaddr,memwe,clk,reset); output[31:0]dataout;input[31:0]datain,memin;input[4:0]address,memaddr;input clk,reset,we,memwe;wire we1;wire[4:0]address1;wire[31:0]decoderout;wire[31:0]regen;wire[31:0]datain1;wire[31:0]q0,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15,q16,q17,q18,q19,q20,q21, q22,q23,q24,q25,q26,q27,q28,q29,q30,q31;assign address1=memwe?memaddr:address;assign datain1=memwe?memin:datain;decoder dec0(decoderout,address1);assign we1=we|memwe;assign regen[0]=decoderout[0]&we1;assign regen[1]=decoderout[1]&we1;assign regen[2]=decoderout[2]&we1;assign regen[3]=decoderout[3]&we1;assign regen[4]=decoderout[4]&we1;assign regen[5]=decoderout[5]&we1;assign regen[6]=decoderout[6]&we1;assign regen[7]=decoderout[7]&we1;assign regen[8]=decoderout[8]&we1;assign regen[9]=decoderout[9]&we1; assign regen[10]=decoderout[10]&we1; assign regen[11]=decoderout[11]&we1; assign regen[12]=decoderout[12]&we1; assign regen[13]=decoderout[13]&we1; assign regen[14]=decoderout[14]&we1; assign regen[15]=decoderout[15]&we1; assign regen[16]=decoderout[16]&we1; assign regen[17]=decoderout[17]&we1; assign regen[18]=decoderout[18]&we1; assign regen[19]=decoderout[19]&we1; assign regen[20]=decoderout[20]&we1; assign regen[21]=decoderout[21]&we1; assign regen[22]=decoderout[22]&we1; assign regen[23]=decoderout[23]&we1; assign regen[24]=decoderout[24]&we1; assign regen[25]=decoderout[25]&we1; assign regen[26]=decoderout[26]&we1; assign regen[27]=decoderout[27]&we1; assign regen[28]=decoderout[28]&we1; assign regen[29]=decoderout[29]&we1; assign regen[30]=decoderout[30]&we1; assign regen[31]=decoderout[31]&we1; register reg0(q0,datain1,clk,reset,regen[0]); register reg1(q1,datain1,clk,reset,regen[1]); register reg2(q2,datain1,clk,reset,regen[2]); register reg3(q3,datain1,clk,reset,regen[3]); register reg4(q4,datain1,clk,reset,regen[4]); register reg5(q5,datain1,clk,reset,regen[5]); register reg6(q6,datain1,clk,reset,regen[6]); register reg7(q7,datain1,clk,reset,regen[7]); register reg8(q8,datain1,clk,reset,regen[8]); register reg9(q9,datain1,clk,reset,regen[9]); register reg10(q10,datain1,clk,reset,regen[10]); register reg11(q11,datain1,clk,reset,regen[11]); register reg12(q12,datain1,clk,reset,regen[12]); register reg13(q13,datain1,clk,reset,regen[13]); register reg14(q14,datain1,clk,reset,regen[14]); register reg15(q15,datain1,clk,reset,regen[15]); register reg16(q16,datain1,clk,reset,regen[16]); register reg17(q17,datain1,clk,reset,regen[17]); register reg18(q18,datain1,clk,reset,regen[18]); register reg19(q19,datain1,clk,reset,regen[19]); register reg20(q20,datain1,clk,reset,regen[20]);register reg21(q21,datain1,clk,reset,regen[21]);register reg22(q22,datain1,clk,reset,regen[22]);register reg23(q23,datain1,clk,reset,regen[23]);register reg24(q24,datain1,clk,reset,regen[24]);register reg25(q25,datain1,clk,reset,regen[25]);register reg26(q26,datain1,clk,reset,regen[26]);register reg27(q27,datain1,clk,reset,regen[27]);register reg28(q28,datain1,clk,reset,regen[28]);register reg29(q29,datain1,clk,reset,regen[29]);register reg30(q30,datain1,clk,reset,regen[30]);register reg31(q31,datain1,clk,reset,regen[31]);mux_32mux0(dataout,q0,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15,q16,q17,q 18,q19,q20,q21,q22,q23,q24,q25,q26,q27,q28,q29,q30,q31,address); endmodule3、设计测试文件`timescale1ns/1nsmodule TOP_test;reg clk,rst,start,memwe;reg[31:0]memin;reg[4:0]memaddr;wire zero,n,v,c;wire[31:0]dataout;TOP u(clk,rst,start,memwe,memin,memaddr,zero,n,v,c,dataout);always#50clk=~clk;initialbeginclk=1;rst=0;start=0;#20rst=1;//load instruction and data to memory.#100rst=0;memwe=1;memin=32'b001000_00000_11111_0000000000010000;//load r0,r31,16memaddr=5'd0;#100memwe=1;memin=32'b001001_00000_11111_0000000000010001;//store r0,r31,17memaddr=5'd1;#100memwe=1;memin=32'b001000_00001_11111_0000000000010001;//load r1,r31,17memaddr=5'd2;#100memwe=1;memin=32'b000001_00010_00000_0101010101010101;//andi r2,r0,16'b0101010101010101memaddr=5'd3;#100memwe=1;memin=32'b000101_00011_00010_0000000000001011;//addi r3,r2,16'b0000000000001011memaddr=5'd4;#100memwe=1;memin=32'b001100_11111111111111111111111011;//branch-5memaddr=5'd5;#100memwe=1;memin=32'hFFFF_FFFF;//load data to memorymemaddr=5'd16;//start to execuit instructions.#100memwe=0;start=1;#100start=0;#10000$stop;endendmodule注意:测试的完备性。
CPU大作业实验报告

实验目的1.深入理解基本模型计算机的功能、组成知识;2.深入学习计算机各类典型指令的执行流程;3.学习硬布线控制器的设计过程和相关技术;4.在掌握部件单元电路实验的基础上,进一步将单元电路组成系统,构造一台基本模型计算机;5.定义20条MIPS指令集的典型指令,并编写相应的汇编程序,能在模型机上调试,掌握计算机整机概念;6.通过熟悉较完整的计算机的设计,全面了解并掌握硬布线控制方式计算机的设计方法,真正理解利用软件进行硬件设计的方法和技巧。
实验原理在部件实验过程中,各部件单元的控制信号是人为模拟产生的,而本实验将能在硬布线控制下自动产生各部件单元控制信号,实现特定的功能。
实验选择了MIPS体系结构中比较典型的指令,使用QuartusII软件工具,通过原理图以及VHDL语言设计CPU的逻辑电路来实现这些指令。
另外还用MIPS汇编语言编写了用于CPU测试的简单程序,对所设计的CPU逻辑电路进行功能仿真模拟,以验证CPU逻辑电路的正确性。
实验涉及到的R指令有ADD、SUB、AND、OR、XOR、SLL、SRL、SRA、JR;I 指令有ADDI、ANDI、ORI、XORI、LW、SW、BEQ、BNE、LUI;J指令有J、JAL。
指令格式如下图所示。
单周期CPU的逻辑电路图跳转指令寄存器指定是从32位的寄存器堆中选择出一个32位的寄存器用于读或写数据。
由于JAL指令要把分支延迟槽下一条指令的指令地址保存在寄存器31号中,故需要设置一个控制信号CALL,当CALL=1时,选择31号寄存器,为JAL跳转指令提供寄存器,当CALL=0时,从32位的寄存器堆中根据地址选择出一个32位的寄存器用于读或写数据。
它的真值表如表9-1所示,电路符号如图9-1所示。
表9-1 跳转指令寄存器指定的真值表CALL 1 0输入REGN[4..0] X REGN[4..0]输出WN[4..0] 11111 REGN[4..0]原理图设计跳转指令寄存器指定元件图5-10-2跳转指令寄存器指定电路符号由描述和真值表创建跳转指令寄存器指定的原理图,如图5-10-2所示:图5-10-1跳转指令寄存器指定的原理图VHDL设计跳转指令寄存器指定元件由于VHDL语法的多样性和灵活性。
cpu的实验报告

cpu的实验报告CPU的实验报告引言:计算机是现代社会不可或缺的工具,而CPU(Central Processing Unit)则是计算机的核心部件之一。
CPU负责执行计算机指令,处理数据和控制计算机的各种操作。
本文将对CPU进行实验,并对实验结果进行分析和总结,以便更好地理解和掌握CPU的工作原理。
一、实验目的本次实验的目的是通过对CPU的实验,深入了解CPU的结构和工作原理,掌握CPU的运行过程和性能评估方法。
二、实验过程1. CPU的结构CPU主要由控制单元和算术逻辑单元组成。
控制单元负责解析和执行指令,算术逻辑单元负责进行算术和逻辑运算。
实验中,我们对CPU的各个部件进行了详细的分析和研究。
2. CPU的指令执行过程CPU的指令执行过程包括取指、译码、执行和写回四个阶段。
在实验中,我们通过模拟CPU的指令执行过程,对每个阶段进行了详细的观察和记录,并分析了每个阶段的作用和影响因素。
3. CPU的性能评估为了评估CPU的性能,我们进行了一系列的实验。
通过改变CPU的主频、缓存大小和指令集等因素,观察CPU的运行速度和效率,并进行性能比较和分析。
实验结果表明,这些因素对CPU的性能有着重要的影响。
三、实验结果与分析1. CPU的结构分析通过对CPU的结构进行分析,我们发现控制单元和算术逻辑单元之间的协作非常重要。
控制单元负责解析和执行指令,而算术逻辑单元负责进行计算和逻辑运算。
两者之间的紧密配合使得CPU能够高效地运行。
2. 指令执行过程分析通过对CPU的指令执行过程进行分析,我们发现每个阶段都有其特定的作用。
取指阶段负责从内存中读取指令,译码阶段负责解析指令,执行阶段负责执行指令,写回阶段负责将结果写回内存。
每个阶段的效率和性能都对CPU的整体运行速度有着重要的影响。
3. 性能评估结果通过对CPU的性能评估实验,我们发现主频、缓存大小和指令集等因素对CPU 的性能有着重要的影响。
提高主频可以加快CPU的运行速度,增加缓存大小可以提高数据读取和存储的效率,而优化指令集可以提高CPU的指令执行效率。
cpu组成与机器指令执行实验实验报告

cpu组成与机器指令执行实验实验报告CPU组成与机器指令执行实验实验报告一、引言计算机是现代社会不可或缺的工具,而中央处理器(CPU)则是计算机的核心组成部分。
理解CPU的组成和机器指令的执行过程对于深入理解计算机的工作原理至关重要。
本实验旨在通过搭建一个简单的CPU模型,探究CPU的组成结构和机器指令的执行过程。
二、实验原理1. CPU的组成结构CPU主要由运算器、控制器和寄存器组成。
运算器负责进行各种算术和逻辑运算,控制器则负责指挥各个部件的工作,寄存器用于存储数据和指令。
2. 机器指令的执行过程机器指令的执行包括取指令、译码、执行和访存四个阶段。
取指令阶段从内存中读取指令,译码阶段将指令翻译成对应的操作,执行阶段进行运算或逻辑操作,访存阶段用于读取或写入数据。
三、实验过程1. 搭建CPU模型根据实验要求,我们搭建了一个简单的CPU模型,包括运算器、控制器和寄存器。
通过将这些部件连接起来,我们可以模拟CPU的工作过程。
2. 编写指令为了测试CPU的功能,我们编写了一些简单的指令,包括加法、减法和逻辑运算等。
这些指令将被存储在内存中,CPU在执行过程中会逐条读取并执行。
3. 执行指令我们按照预定的顺序执行指令,观察CPU的工作状态和输出结果。
通过这个过程,我们可以更好地理解指令的执行过程和CPU的工作原理。
四、实验结果在实验过程中,我们成功搭建了一个简单的CPU模型,并编写了一些指令进行测试。
通过执行这些指令,我们观察到CPU按照预期工作,并得到了正确的输出结果。
五、实验分析通过本次实验,我们深入了解了CPU的组成结构和机器指令的执行过程。
我们发现,CPU的运算器、控制器和寄存器相互配合,完成了复杂的运算和逻辑操作。
同时,我们也注意到指令的执行过程需要经过多个阶段,每个阶段都起到了重要的作用。
六、实验总结本次实验让我们对CPU的组成与机器指令的执行有了更深入的理解。
通过搭建CPU模型并执行指令,我们亲身体验了CPU的工作过程,加深了对计算机原理的理解。
MIPS单周期CPU实验报告

MIPS单周期CPU实验报告一、实验目的本实验旨在设计一个基于MIPS指令集架构的单周期CPU,具体包括CPU的指令集设计、流水线的划分与控制信号设计等。
通过本实验,可以深入理解计算机组成原理中的CPU设计原理,加深对计算机体系结构的理解。
二、实验原理MIPS(Microprocessor without Interlocked Pipeline Stages)是一种精简指令集(RISC)架构的处理器设计,大大简化了指令系统的复杂性,有利于提高执行效率。
MIPS指令集由R、I、J三种格式的指令组成,主要包括算术逻辑运算指令、存储器访问指令、分支跳转指令等。
在单周期CPU设计中,每个指令的执行时间相同,每个时钟周期只执行一个指令。
单周期CPU的主要部件包括指令内存(IM)、数据存储器(DM)、寄存器文件(RF)、运算单元(ALU)、控制器等。
指令执行过程主要分为取指、译码、执行、访存、写回等阶段。
三、实验步骤1.设计CPU指令集:根据MIPS指令集的格式和功能,设计符合需求的指令集,包括算术逻辑运算指令、存储器访问指令、分支跳转指令等。
2.划分CPU流水线:将CPU的执行过程划分为取指、译码、执行、访存、写回等阶段,确定每个阶段的功能和控制信号。
3.设计控制器:根据CPU的流水线划分和指令集设计,设计控制器实现各个阶段的控制信号生成和时序控制。
4.集成测试:进行集成测试,验证CPU的指令执行功能和正确性,调试并优化设计。
5.性能评估:通过性能评估指标,如CPI(平均时钟周期数)、吞吐量等,评估CPU的性能优劣,进一步优化设计。
四、实验结果在实验中,成功设计了一个基于MIPS指令集架构的单周期CPU。
通过集成测试,验证了CPU的指令执行功能和正确性,实现了取指、译码、执行、访存、写回等阶段的正常工作。
同时,通过性能评估指标的测量,得到了CPU的性能参数,如CPI、吞吐量等。
通过性能评估,发现了CPU的性能瓶颈,并进行了相应的优化,提高了CPU的性能表现。
CPU设计实验报告Word版

实验中央处理器的设计与实现一、实验目的1、理解中央处理器的原理图设计方法。
2、能够设计实现典型MIPS的11条指令。
二、实验要求1、使用Logisim完成数据通路、控制器的设计与实现。
2、完成整个处理器的集成与验证。
3、撰写实验报告,并提交电路源文件。
三、实验环境VMware Workstations Pro + Windows XP + Logisim-win-2.7.1四、操作方法与实验步骤1、数据通路的设计与实现数据通路主要由NPC、指令存储器、32位寄存器文件、立即数扩展部件、ALU、数据存储器构成。
其中指令存储器和数据存储器可直接调用软件库中的ROM和RAM元件直接完成,其余部件的设计如图所示:图1.1 NPC图1.2 32位寄存器图1.3 立即数扩展部件图1.4 ALU2、控制器的设计与实现控制器的主要设计思想如图所示图2.1 控制器设计思想输入000000001101100011101011000100000010输出R-type ORI LW SW BEQ JUMP RegDst100x x x ALUSrc01110x MemtoReg001x x x RegWrite111000 MemWrite000100 Branch000010 Jump000001 Extop x0111x ALUop210000x ALUop1x100x x ALUop0x0001xALUop[2:0]Funct[3:0]指令ALUctr[2:0] 1110000add0101110010sub1101110100and0001110101or0011111010slt111010xxxx ori001000xxxx Lw/sw010011xxxx beq110表2.1 控制器设计真值表图2.2 控制器3、处理器的集成与验证集成:将各个部件按要求链接,具体方式如图所示:图3.1 CPU验证:将指令的16进制表示输入指令存储器,运行后记录寄存器中的数据与标准值进行对照:图3.2 寄存器对照值图3.3 寄存器实际运行值由上两图对照可得CPU的功能实现成功。
CPU实验报告范文

CPU实验报告范文一、实验目的本次实验的目的是设计和实现一个简单的中央处理器(CPU),通过实践掌握CPU的基本工作原理和实现方法。
二、实验原理1.CPU的基本概念中央处理器(CPU)是计算机的核心部件,负责执行计算机指令和控制计算机的操作。
它由运算器、控制器和寄存器组成。
运算器负责执行算术和逻辑运算,包括加法、减法、乘法、除法等。
控制器负责指挥CPU的工作,通过控制总线实现对内存和其他外部设备的访问。
寄存器是CPU内部的存储器,用于暂时存放指令、数据和中间结果。
2.CPU的实现方法CPU的实现采用组合逻辑电路和时序逻辑电路相结合的方法。
组合逻辑电路是由逻辑门构成的电路,它的输入只依赖于当前时刻的输入信号,输出也只与当前时刻的输入信号有关。
而时序逻辑电路则包含存储元件,其输出不仅与当前时刻的输入信号有关,还与之前的输入信号有关。
CPU的实现过程主要包括以下步骤:(1)设计指令集:确定CPU支持的指令集,包括指令的格式和操作码。
(2)设计控制器:根据指令集设计控制器,确定各个指令的执行过程和控制信号。
(3)设计运算器:根据指令集设计运算器,确定支持的算术和逻辑运算。
(4)设计寄存器:确定需要的寄存器数量和位数,设计寄存器的输入输出和工作方式。
3.实验环境和工具本次实验使用的环境和工具如下:(1)硬件环境:计算机、开发板、示波器等。
(2)软件环境:Win10操作系统、Vivado开发工具等。
三、实验步骤1.设计指令集根据实验要求,我们设计了一个简单的指令集,包括加法、减法、逻辑与、逻辑或和移位指令。
每个指令有特定的操作码和操作数。
2.设计控制器根据指令集设计了一个控制器。
控制器根据指令的操作码产生相应的控制信号,控制CPU内部寄存器、运算器和总线的操作。
3.设计运算器根据指令集设计了一个运算器。
运算器包括加法器、减法器、与门和或门等。
它通过输入的操作数和控制信号完成相应的运算操作。
4.设计寄存器根据实验需求确定了所需的寄存器数量和位数。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Southeast University Microprogra m med CPU Design -- COA experimentSchool of Information Science and Engineering04009XXX2012-4-25PurposeThe purpose of this project is to design a simple CPU (Central Processing Unit). This CPU has basic instruction set, and we will utilize its instruction set to generate a very simple program to verify its performance. For simplicity, we will only consider the relationship among the CPU, registers, memory and instruction set. That is to say we only need consider the following items: Read/Write Registers, Read/Write Memory and Execute the instructions.At least four parts constitute a simple CPU: the control unit, the internal registers, the ALU and instruction set, which are the main aspects of our project design and will be studied.Instruction SetSingle-address instruction format is used in our simple CPU design. The instruction word contains two sections: the operation code (opcode), which defines the function of instructions (addition, subtraction, logic operations, etc.); the address part, in most instructions, the address part contains the memory location of the datum to be operated, we called it direct addressing. In some instructions, the address part is the operand, which is called immediate addressing.For simplicity, the size of memory is 256×16 in the computer. The instruction word has 16 bits. The opcode part has 8 bits and address part has 8 bits. The instruction word format can be expressed in Figure 1Figure 1 the instruction formatThe opcode of the relevant instructions are listed in Table 1.In Table 1, the notation [x] represents the contents of the location x in the memory. For example, the instruction word 00000011101110012 (03B916) means that the CPU adds word at location B916 in memory into the accumulator (ACC); the instruction word 00000101000001112 (050716) means if the sign bit of the ACC (ACC [15]) is 0, the CPU will use the address part of the instruction as the address of next instruction, if the sign bit is 1, the CPU will increase the program counter (PC) and use its content 7as the address of the next instruction.Table 1 List of instructions and relevant opcodesAll the instructions except the Division instruction are supported in my design. Internal Registers and MemoryMAR (Memory Address Register)MAR contains the memory location of the word to be read from the memory or written into the memory. Here, READ operation is denoted as the CPU reads from memory, and WRITE operation is denoted as the CPU writes to memory. In our design, MAR has 8 bits to access one of 256 addresses of the memory.MBR (Memory Buffer Register)MBR contains the value to be stored in memory or the last value read from memory. MBR is connected to the address lines of the system bus. In our design, MBR has 16 bits.PC (Program Counter)PC keeps track of the instructions to be used in the program. In our design, PC has 8 bits.IR (Instruction Register)IR contains the opcode part of an instruction. In our design, IR has 8 bits.BR (Buffer Register)BR is used as an input of ALU, it holds other operand for ALU. In our design, BR has 16 bits.ACC (Accumulator)A CC holds one operand for ALU, and generally ACC holds the calculation result of ALU. In my design, ACC has 16 bits.In this designment, ACC is set in ALU for simplification.MR (Multiplier Register)MR is used for implementing the MPY instruction, holding the multiplier at the beginning of the instruction. When the instruction is executed, it holds part of theproduct (the high part of the 32-bit product).LPM_RAM_DQLPM_RAM_DQ is a RAM with separate input and output ports, it works as memory, and its size is 256×16. Although it’s not an internal register of CPU, we need it to simulate and test the performance of CPU.LPM_ROMLPM_ROM is a ROM with separate input and output ports, it works as memory,and its size is 256×32. Although it’s not an internal register of CPU, we need it to simulate and test the performance of CPU.All the registers are positive-edge-triggered.All the reset signals for the registers are synchronized to the clock signal.ALUALU (Arithmetic Logic Unit) is a calculation unit which accomplishes basic arithmetic and logic operations. In our design, some operations must be supported which are listed as followsMicroprogrammed Control UnitWe have learnt the knowledge of Microprogrammed control unit. Here, we only review some terms and basic structures.In the Microprogrammed control, the microprogram consists of some microinstructions and the microprogram is stored in control memory that generates all the control signals required to execute the instruction set correctly. The microinstruction contains some micro-operations which are executed at the same time.Figure 2 Control Unit Micro-architectureFigure 2 shows the key elements of such an implementation. The set of microinstructions is stored in the control memory. The control address register contains the address of the next microinstructions to be read. When a microinstruction is read from the control memory, it is transferred to a control buffer register. The register connects to the control lines emanating from the control unit. Thus, reading a microinstruction from the control memory is the same as executing that microinstruction. The third element shown in the figure is a sequencing unit that loads the control address register and issues a read command.Figure 3 indicates a simple CPU architecture and its use of a variety of internal data paths and control signals. Our CPU design should be based on this architecture. Microprogrammed ControlFor each micro-operation, all that the control unit is allowed to do is generate a set of control signals. Each control line is either on or off, which can be represented by a binary digit for each control line. So we could construct a control word in which each bit represents one control line.The set of microinstructions is stored in the control memory. The control address register contains the address of the next microinstruction to be read. When a microinstruction is read from the control memory, it is transferred to a control buffer register, which register connects to the control lines emanating from the control unit. Thus reading a microinstruction from the control memory is the same as executing that microinstruction!Control signals:In my design,there are 32 bits of control signals,as the fallow table shows.Table 3 Control signalsTable 4 The Sequence of MicroinstructionsTable 5 The meaning of each bit of the 8-bit flag.The Design of MAR、MBR、PC、IR、BR、ACC、ALU、LPM_RAM_DQThe Design of CPU:The Design of romThe Simulation Input WaveformsTestTest of ADD, SUB, JMPGEZ, SHIFTR, AND and NOT. Calculate not( (1+2+3+…+10)/2 or “10011010”), and save the final answer.Table 6 Test Problem 2IR<=MBR(15..0) “02”represents “STORE”LOAD A0(0000) STORE B0(0000)LOAD B0(000A) ADD B1(0009)LOAD B1(0009)SUB A2(0001)ACC<=ACC-BR(09h-01h=08h) JMPGEZSHIFTROR A3(009A)RAMNOTACC<=NOT BR (NOT 009B=FF64h)APPENDIX------------------MAR------------------library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity MAR isport( clk,reset,c18,c19:in std_logic;PC_in: in std_logic_vector(7 downto 0);MBR_in :in std_logic_vector(15 downto 0);MAR_out : out std_logic_vector(7 downto 0));end;architecture behave of MAR isbeginprocess(clk)variable MAR_temp : std_logic_vector(7 downto 0);beginif (rising_edge(clk)) thenif reset='0' thenMAR_temp:=x"00";elsif c18='1' thenMAR_temp:=PC_in;elsif c19='1' thenMAR_temp:=MBR_in(7 downto 0);end if;MAR_out<=MAR_temp;end if;end process;end behave;-------------------------------MBR------------------------------------- library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity MBR isport(clk,reset,c12,c16,c20: in std_logic;MEM_in: in std_logic_vector(15 downto 0);ACC_in: in std_logic_vector(15 downto 0);MR_in: in std_logic_vector(15 downto 0);MBR_out: out std_logic_vector(15 downto 0));end MBR;architecture behave of MBR isbeginprocess(clk)variable MBR_temp: std_logic_vector(15 downto 0);beginif(rising_edge(clk)) thenif reset='0' thenMBR_temp:=x"0000";elsif(c12='1') thenMBR_temp:=ACC_in;elsif(c16='1') thenMBR_temp:=MR_in;elsif(c20='1') thenMBR_temp:=MEM_in;end if;MBR_out<=MBR_temp;end if;end process;end behave;--------------------------------------PC------------------------------------- library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity PC isport(clk,reset,c7,c17: in std_logic;MBR_in: in std_logic_vector(15 downto 0);PC_out: out std_logic_vector(7 downto 0));end PC;architecture behave of PC isbeginprocess(clk)variable PC_temp: std_logic_vector(7 downto 0);beginif(rising_edge(clk)) thenif(reset='0') thenPC_temp:="00000000";end if;if(c7='1') thenPC_temp:=PC_temp+1;elsif(c17='1') thenPC_temp:=MBR_in(7 downto 0);end if;PC_out<=PC_temp;end if;end process;end behave;-----------------------------------IR------------------------------------ library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity IR isport(clk,reset,c14: in std_logic;MBR_in: in std_logic_vector(15 downto 0);IR_out: out std_logic_vector(7 downto 0));end IR;architecture behave of IR isbeginprocess(clk)variable IR_temp:std_logic_vector(7 downto 0);beginif(rising_edge(clk)) thenif reset='0' thenIR_temp:=x"00";end if;if(c14='1') thenIR_temp:=MBR_in(15 downto 8);end if;IR_out<=IR_temp;end if;end process;end behave;-----------------------------------BR------------------------------------ library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity BR isport( clk,reset,c13 :in std_logic;MBR_in :in std_logic_vector(15 downto 0);BR_out :out std_logic_vector(15 downto 0)); end BR;architecture behave of BR isbeginprocess(clk)variable BR_temp :std_logic_vector(15 downto 0);beginif (rising_edge(clk)) thenif reset='0' thenBR_temp:=x"0000";elsif c13='1' thenBR_temp:=MBR_in;end if;BR_out<=BR_temp;end if;end process;end behave;------------------------------ALU-------------------------library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity ALU isport(clk,reset: in std_logic;c:in std_logic_vector(31 downto 0);BR_in,MBR_in:in std_logic_vector(15 downto 0);flag:out std_logic_vector(7 downto 0);ACC_out:out std_logic_vector(15 downto 0);ALU_to_MR: out std_logic_vector(15 downto 0));end ALU;architecture behave of ALU isbeginprocess(clk)variable ACC_temp: std_logic_vector(15 downto 0); variable BR_temp:std_logic_vector(15 downto 0); variable flags: std_logic_vector(7 downto 0):="00000000"; variable COUNTER:integer:=0;variable MR:std_logic_vector(15 downto 0);beginif (rising_edge(clk)) thenif reset='0' thenACC_temp:=x"0000";MR:=x"0000";elsif c(8)='1' thenACC_temp:=x"0000";end if;if c(23)='1' then--------addACC_temp:=ACC_temp+BR_in;elsif c(24)='1' then---------subACC_temp:=ACC_temp-BR_in;elsif c(25)='1' then---------shiftrACC_temp:='0'&ACC_temp(15 downto 1);elsif c(26)='1' then-----------shiftlACC_temp:=ACC_temp(14 downto 0)&'0';elsif c(27)='1' then------------andACC_temp:=ACC_temp and BR_in;elsif c(28)='1' then -----------orACC_temp:=ACC_temp or BR_in;elsif c(29)='1' then------------notACC_temp:=not BR_in;elsif(c(21)='1') then------ ready for MPYif((ACC_temp(15) xor BR_in(15))='1') thenflags:=flags or "00000100";--------- flags(2) end if;if(ACC_temp(15)='1') thenACC_temp:=not (ACC_temp-1);end if;if(BR_in(15)='1') thenBR_temp:=not(BR_in-1);elseBR_temp:=BR_in;end if;MR:="0000000000000000";COUNTER:=0;flags:=flags and "11110111";----- flags(3)elsif(c(30)='1') thenif(ACC_temp(0)='1') thenMR:=MR+BR_temp;end if;ACC_temp:=MR(0)&ACC_temp(15 downto 1);-------ACC shift rightMR:='0'&MR(15 downto 1);-------MR shift right(store the high bits of the product)COUNTER:=COUNTER+1;if(COUNTER=15) then ----COUNTER=16 or 15flags:=flags or "00001000";---------set flags(3) means MPY finished end if;elsif(c(9)='1') then ---------------------finish MPYif(flags(2)='1') then------------------the product is negativeif(ACC_temp="0000000000000000") thenMR:=(not MR)+1;elseACC_temp:=(not ACC_temp)+1;MR:=not MR;end if;MR(15):='1';-------the first bit which is also the sign bit shouldn't be complemented.flags:=flags and "11110011";--------reset flags(2) and flag(3)end if;end if;if(ACC_temp(15)='0') then-------ACC>0flags:=flags and "11111101"; --if ACC>0,flag(1)=ACC_temp(15)=0 elseflags:=flags or "00000010"; --if ACC<0,flag(1)=ACC_temp(15)=1 end if;ALU_to_MR<=MR;flag<=flags;ACC_out<=ACC_temp;end if;end process;end behave;--------------------------CAR------------------------ library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity CAR isport(clk,reset:in std_logic;IR_in:in std_logic_vector(7 downto 0);c: in std_logic_vector(31 downto 0);flags: in std_logic_vector(7 downto 0);addr: out std_logic_vector(7 downto 0) );end CAR;architecture behave of CAR isbeginprocess(clk)variable addtemp: std_logic_vector(7 downto 0); variable opcode: std_logic_vector(7 downto 0); beginif(rising_edge(clk)) thenopcode:=IR_in;if(c(0)='1') thenaddtemp:=addtemp+1;end if;if(c(1)='1') then --clearaddtemp:="00000000";end if;if (c(3)='1') then-------------for JMPGEZaddtemp:=addtemp+1+flags(1);end if;if(c(30)='1') then-------for MPYaddtemp:=addtemp+flags(3);end if;if (c(2)='1') thencase opcode iswhen "00000001"=>------------storeaddtemp:="00001000";-----------------08hwhen "00000010"=>------------loadaddtemp:="00010000";-----------------10hwhen "00000011"=>------------addaddtemp:="00011000";-----------------18hwhen "00000100"=>------------subaddtemp:="00100000";-----------------20hwhen "00000101"=>------------andaddtemp:="00101000";-----------------28hwhen "00000110"=>------------oraddtemp:="00110000";-----------------30hwhen"00000111"=>-------------notaddtemp:="00111000";-----------------38hwhen"00001000"=>------------shiftraddtemp:="01000000";-----------------40hwhen"00001001"=>------------shiftladdtemp:="01000001";-----------------41hwhen"00001010"=>------------jmpgezaddtemp:="01001000";-----------------48hwhen"00001011"=>-------------jmpaddtemp:="01010000";-----------------50hwhen"00001100"=>-------------mpyaddtemp:="01011000";-----------------58hwhen"00001101"=>---------store MRaddtemp:="01100000";-----------------60hwhen"00001110"=>-------------haltaddtemp:="11111111";-----------------ffhwhen others=>NULL;end case;end if;if(flags(0)='1')then --------initaddtemp:="00000000";end if;if(reset='0') then ------addtemp:="00000000";end if;addr<=addtemp;end if;end process; end behave;。