资源描述:
《杭电计组实验9-实现R-I型指令CPU设计实验》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验报告2018年_月_日成绩:姓名阳光男学号16041321班级16052317专业计算机科学与技术课程名称《计算机组成原理与系统结构试验》任课老师张翔老师指导老师张翔老师机位号无实验序号9实验名称《实验九实现R・I型指令的CPU设计实验》实验时间2018/6/2实验地点1教221实验设备号个人电脑一、实验程序源代码顶层RI型指令CPU模块测试文件:moduletest;//Inputsregrst;regelk;//OutputswireZF;wireOF;wire[31:0]F;wire[31:0]M_R_Data;
2、//InstantiatetheUnitUnderTest(UUT)TOPRICPUuut(.rst(rst),.clk(clk),•ZF(ZF),.OF(OF),・F(F),.M_R_Data(M_R_Data));initialbegin11InitializeInputsrst=0;elk=0;//Wait100nsforglobalresettofinish#100;clk=l;//Addstimulushereforeverbegin#50;clk=~clk;endendendmodule顶层LED验证模块:mo
3、duleTOP_LED(clk_100MH乙oclk,rst,SW,LED);inputclk_100MHz;inputoclk,rst;input[3:0]SW;outputreg[7:0]LED;wirerclk;wireZF,OF;wire[31:0]F;wire[31:0]M_R_Data;xiaodoudoudong(clk_100MHz,oclk,rclk);TOPRICPU(clk100MHz,rst/rclk,ZF,OF,F,MRData);always@(*)begincase(SW)3,b0000:LE
4、D=F[7:0];3*b0001:LED=F[15:8];3,b0010:LED=F[23:16];3*b0011:LED=F[31:24];3,b0100:LED=M_R_Data[7:0];3,b0101:LED=M_R_Data[15:8];3,b0110:LED=M_R_Data[23:16];3,b0111:LED=M_R_Data[31:24];S^llllrbeginLED[7:2]=0;LED[l]=OF;LED[0]=ZF;enddefault:LED=O;endcaseendendmodule[31:0
5、]F,output顶层RI型指令CPU模块moduleTOP_RI_CPU(inputrst,inputclk,outputZF,outputOF,output[31:0]M_R_Data);wireWrite_Reg;wire[31:0]lnst_code;wire[4:0]rs;wire[4:0]rt;wire[4:0]rd;wire[31:O]rs_data;wire[31:0]rt_data;wire[31:O]rd_data;wire[31:0]imm_data;wire[15:0]imm;wirerd_rt_s
6、;wireimm_s;wireMem_Write;wirealumems;wire[31:0]W_Addr;wire[31:0]W_Data;wire[31:0]R_Data_A;wire[31:0]R_Data_B;wire[31:0]F;wire[31:0]ALU_B;wire[2:0]ALU_OP;pcpc_connect(clk,rst,lnst_code);OP_YIMAop(lnst_code,ALU_OP』sjtjcbWrite_Reg」mmjcl_rt_s」mm_s,rt」mm_s,Mem_Write,al
7、u_mem_s);assignW_Addr=(rd_rt_s)?rt:rd;assignimm_data=(imm_s)?{{16{imm[15]}},imm}:{{16{llb0}},imm};Register_fileR_connect(rs/rt/W_Addr,Write_Reg/W_Data/~clk,rst/R_Data_A/R_Data_B);assignALU_B=(rtm_s)?imm_data:R_Data_B;ALUALU_cormect(R_Data_A,ALU_B,F,ALU_OP,ZFQF);wi
8、reclk_tmp;wired_outn;regd_out=0;assignclk_tmp=clkAd_out;assignd_outn二~d_out;always@(posedgeclk_tmp)begind_out<=d_outn;endRAM_BData_Mem(.clka(clk_tmp),//