




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、湘潭大學(xué)計算機(jī)原理 實(shí)驗(yàn)四 多周期MIPS CPU + 存儲器實(shí)驗(yàn)預(yù)習(xí)報告實(shí)驗(yàn)四 多周期MIPS CPU +存儲器實(shí)驗(yàn)一. 實(shí)驗(yàn)?zāi)康?、深入理解MIPS-CPU指令系統(tǒng)的功能和工作原理;2、 掌握多周期CPU的工作原理和邏輯功能實(shí)現(xiàn);3、熟練掌握用 Verilog HDL 語言設(shè)計多周期存儲器的 方法;4、熟練掌握對多周期存儲器的仿真實(shí)驗(yàn)驗(yàn)證和硬件測 試兩種調(diào)試方法;5、通過對多周期CPU的運(yùn)行情況進(jìn)行觀 察和分析,進(jìn)一步加深理解。二. 實(shí)驗(yàn)設(shè)備硬件:現(xiàn)代計算機(jī)組成原理實(shí)驗(yàn)系統(tǒng)Nios 32位嵌入式系統(tǒng)實(shí)驗(yàn)開發(fā)平臺 EP1C12Q240Corei3-3240 CPU 的內(nèi)存 軟件:Quartu
2、sll Microsoft Windows xp三. 實(shí)驗(yàn)內(nèi)容1、設(shè)計一個32位MIPS多周期CPU :口體的要求如卜:至少運(yùn)行下列的6類32條MIPS指令。 算術(shù)邏輯指令and、 sub、 addi邏輯運(yùn)算指令and、0r、 xor、 andi 、 ori 、 xori 位 移指令 sll 、 srl 、 sra 條件分玄扌旨令 beq、bne、 無條 件跳轉(zhuǎn)指令j、jr數(shù)據(jù)傳送指令lw、sw 2.設(shè)計一個 存儲器四. 實(shí)驗(yàn)原理與步驟實(shí)現(xiàn)上述原理框圖根據(jù)功能將其分劃分為控制單元(cunit)、執(zhí)行單元(eunit)、指令單元(iunit)以及存儲單元(munit)四大模塊。.控制單元(cun
3、it)足多周期微處理器的核心 控制微 處理器取指令、指令譯碼和指令執(zhí)行等工作。主要指令譯碼 器控制器(outputs control)、算術(shù)邏輯運(yùn)算控制器(ALUcontrol)兩 個子模塊組成。.執(zhí)行單元(eunit)主要寄存器堆(registers)和算術(shù)邏輯單元(ALU)兩個子模塊組成。其中寄存器是微處理器最基 本的兒索MIPS系統(tǒng)的寄存器堆32個32位寄存器組成而ALU則是微處理巖的主英功能部件 執(zhí)行加、減、比較等 算術(shù)運(yùn)算和與、或、或非、異或等邏輯運(yùn)算。指令單元(iunit) 的作用是決定下一條指令的地址PC伯o.存儲單元(munit)存儲器(memory)、指令寄存器 (instr
4、uction register)和存儲數(shù)據(jù)寄存 器(memory dataregister) 組成。五. 實(shí)驗(yàn)源代碼寄存器元件代碼:module regfile (rna,rnb,d,wn,we,clk,clrn,qa,qb);put 4:0rna,rnb,wn;input31:0d;inputwe,clk,clrn;output 31:0qa,qb;reg31:0register 1:31;assignqa :=(rna =二 0)0 :registerrna;assignqb =(rnb=0) 0 :registerrnb;always (posedge clk or negedge cl
5、rn) begin if(clrn = 0) begininteger i;for (i=1; ia4:0;4b1111:cal=$signed(b)a4:0;endcaseendfunction endmodule其他部件:module f (reg_dest,jal,wn);input 4:0reg_dest; inputjal; output 4:0 wn; assignwn = reg_dest | 5jal; endmodulemodule sa (di,dot); input4:0 di; output31:0dot; assign dot = 27b0,di; endmodule
6、module out4 (out); output31:0 out; assign out=32h4; endmodulemodule e (immin,sext,immediate,offset);input15:0 immin; inputsext; output 31:0immediate,offset; wiree = sext & immin15;wire 15:0 imm = 16e; assign offset =assignimm13:0,immin15:0,1b0,1b0;immediate = imm,immin15:0; endmodulemodule xxbine(ad
7、dress,pc,add);input25:0address;input3:0pc;output31:0add;assignadd =pc3:0,address25:0,1b0,1b0;endmodulemoduleconvertl(dain,sain,op,func,rs,rt,rd,imm,addr);input31:0 dain; output 4:0 sain,rs,rt,rd;output5:0 op,func; output 15:0 imm; output 25:0 addr; assign sain = dain10:6; assign op = dain31:26; assi
8、gn func = dain5:0; assign rs = dain25:21; assign rt = dain20:16;assign rd = dain15:11;assign imm =dain15:0;assignaddr =dain25:0;endmodulemodule convert2 (pc,pcout); input 31:0 pc; output 3:0 pcout; assign pcout = pc31:28;endmodule存儲器內(nèi)的測試數(shù)據(jù):-Copyright (C) 1991-20XX Altera Corporation-Your use of Alte
9、ra Corporations design tools,logic functions - and other software and tools, and its AMPP partner logic - functions, and any output files from any of the foregoing - (including device programming or simulation files), and any -associated documentation or information are expressly subject - to the te
10、rms and conditions of the Altera Program License - Subscription Agreement, Altera MegaCore Function License - Agreement, or other applicable license agreement, including, - without limitation, that your use is for the sole purpose of- programming logic devices manufactured by Altera andsold by- Alte
11、raoritsauthorizeddistributors.Pleaserefer tothe -applicableagreement for further details.-Quartus II generated MemoryInitialization File (.mif)DEPTH= 64;%Memorydepth and width are requiredWIDTH =32;%Enter a decimal numberADDRESS_RADI)= HEX; -dress and value radixes are optional DATA_RADIX = HEX; %En
12、ter BIN, DEC, HEX, or OCT; unless %otherwise specified, radixes = HEXCONTENT BEGIN0.3F : 00000000; % Range-Every address from 0to 3F = 00000000 0 : 3c010000; % (00) main: lui r1,0 # address of data0 1: 34240080; %(04) ori r4,r1,0x80# address of data0 2 : 20XX0004; % (08)addi r5, r0, 4 # counter 3 :
13、0c000018; %(0c) call: jal sum # call function 4: ac820XX0; %(10) swr2, 0(r4) # store result 5 : 8c890000; % (14) lwr9, 0(r4) # check sw 6: 01244022; % (18) sub r8,r9, r4 # sub: r8 16 = ffff8000(arith) r8, r8, 15# 15 = 0001ffff(logic) finish # dead loopr8,r0, r0 # sumr9, 0(r4) # load datar4, 4 #addre
14、ss + 4r8, r8, r9 # sumr5, -1 # counter-1r5, r0, loop # finish r2, r8, 0 # move resultto v0 r31 # return% % % % % % % % % % % % % % % %六. EDA階段的實(shí)驗(yàn)結(jié)果仿真結(jié)果如上圖。七. 測試時的電路總體結(jié)構(gòu)及其說明實(shí)驗(yàn)電路圖八. 測試計劃及其相關(guān)說明輸出說明:于引腳及輸出需要,故下表ir對應(yīng)ir31.O 且將顯示 高四位,pc對應(yīng)pc31.O 且將顯示低兩位,alu對應(yīng)alu31.O 且將顯示低兩位輸入 clockmem_clk pc 輸出 alu irclock
15、輸入 mem_clk pc 輸出 alu ir九. 關(guān)于實(shí)驗(yàn)電路設(shè)計的其他說明于引腳及輸出需要,故只輸出ir、pc、aluir31.0切將顯示ir高四位,pc31.O低兩位,alu31.O 低兩 位,q、adr、fromm、a、b、tom 將不會輸出十.前期實(shí)驗(yàn)總結(jié)本次實(shí)驗(yàn),不僅加深了我對多周期CPU及存儲器相關(guān)知識的理解,而且?guī)椭约夯貞浐蛷?fù)習(xí)了單周期CPU方面的知識,比如如何用 Verilog HDL描述ALU模塊、一些數(shù)據(jù)選擇 器、符號擴(kuò)展電路、以及寄存器。實(shí)驗(yàn)四 多周期MIPS CPU +存儲器實(shí)驗(yàn)一. 實(shí)驗(yàn)?zāi)康?、深入理解MIPS-CPU指令系統(tǒng)的功能和工作原理;2、 掌握多周期CP
16、U的工作原理和邏輯功能實(shí)現(xiàn);3、熟練掌握用 Verilog HDL 語言設(shè)計多周期存儲器的 方法;4、熟練掌握對多周期存儲器的仿真實(shí)驗(yàn)驗(yàn)證和硬件測 試兩種調(diào)試方法;5、通過對多周期CPU的運(yùn)行情況進(jìn)行觀 察和分析,進(jìn)一步加深理解。二. 實(shí)驗(yàn)設(shè)備硬件:現(xiàn)代計算機(jī)組成原理實(shí)驗(yàn)系統(tǒng)Nios 32位嵌入式系統(tǒng)實(shí)驗(yàn)開發(fā)平臺 EP1C12Q240Corei3-3240CPU 的內(nèi)存 軟件:QuartusllMicrosoft Windows xp三. 實(shí)驗(yàn)內(nèi)容1、設(shè)計一個32位MIPS多周期CPU 具體的妥求如下:至少運(yùn)行下列的6類32條MIPS指令。算術(shù)邏輯指令and、 sub、 addi邏輯運(yùn)算扌旨令
17、 and、 0r、 xor、 andi 、 ori 、 xori 位 移指令sll、srl、sra條件分支扌旨令 beq、bne、無條 件跳轉(zhuǎn)指令j、jr 數(shù)據(jù)傳送指令lw、sw 2.設(shè)計一個 存儲器四. 實(shí)驗(yàn)原理與步驟實(shí)現(xiàn)上述原理框圖根據(jù)功能將其分劃分為控制單元(cunit)、執(zhí)行單元(eunit)、指令單元(iunit)以及存儲單元(munit)四大模塊。.控制單元(cunit)是多周期微處理器的核心 控制微 處理器取指令、指令譯碼和指令執(zhí)行等工作。主要指令譯碼 器控制器(outputs control)、算術(shù)邏輯運(yùn)算控制器(ALUcontrol)兩 個子模塊組成。.執(zhí)行單元(eunit)
18、主要寄存器堆(registers) 和算術(shù)邏輯單元(ALU)兩個子模塊組成。其中寄存器是微處理器最基 本的兒索MIPS系統(tǒng)的寄存器堆32個32位寄存器組成而ALU則是微處理器 的主戲功能部件 執(zhí)行加、減r比較等 算術(shù)運(yùn)算和與、或、或非、異或等邏輯運(yùn)算。指令單元(iunit) 的作用是決定下一條指令的地址PC值O.存儲單元(munit)存儲器(memory)、指令寄存器 (instruction register)和存儲數(shù)據(jù)寄存 器(memory dataregister) 組成。五. 實(shí)驗(yàn)源代碼寄存器元件代碼:module regfile (rna,rnb,d,wn,we,clk,clrn,q
19、a,qb);put 4:0rna,rnb,wn;input31:0d;inputwe,clk,clrn;output 31:0qa,qb;reg31:0register 1:31;assignqa =(rna =:=0)0 :registerrna;assignqb =:(rnb=0) 0 :registerrnb;always (posedge clk or negedge clrn) begin if(clrn = 0) begininteger i;for (i=1; i32;i=i+1) registeri = 0; end else beginif(wn != 0) & (we =
20、1)registerwn = d; endend endmodule32位四選一選擇器:module mux4x32 (a0,a1,a2,a3,s,y); input 31:0a0,a1,a2,a3; input 1:0 s; output 31:0 y;function 31:0 select; i叩 ut 31:0 a0,a1,a2,a3;put1:0 s; case (s)2b00: select = a0;2b01: select = a1;2b10: select = a2;2b11:select = a3; endcase endfunction assign y = select
21、 (a0,a1,a2,a3,s); endmoduler1-r31 /read /read /reset/write5位二選一選擇器:module mux2x5 (a0,a1,s,y);input 4:0a0,a1;input s; output4:0 y; assign y = s a1 : a0;endmodule32位二選一選擇器:module mux2x32 (a0,a1,s,y); input 31:0a0,a1;input s; output 31:0 y; assign y = s a1 : a0;endmodule存儲器元件:module mcmen(clk,dataout,
22、datain, addr, we, inclk,outclk); input 31:0 datain; input 31:0 addr;input elk, we, inclk, outclk; output 31:0 dataout;wire write_enable = we &clk; lpm_ram_dq ram(.data(datain),.address(addr7:2),.we(write_enable ),.inclock(inclk),.outclock(outclk),.q(dataout);defparam _width = 32; defparam _widthad =
23、 6;defparam _indata = defparam _outdata = defparam _file= defparam _address_control =endmodule控制部件:module mccu (op, func, z, clock, resetn, wpc, wir, wmem, wreg, iord, regrt, m2reg, aluc, shift, alusrca, alusrcb, pcsource, jal, sext, state); input 5:0op,func; input z, clock, resetn; output reg wpc,
24、wir, wmem,wreg, iord, regrt, m2reg; output reg 3:0 aluc; output reg 1:0 alusrcb, pcsource; output reg shift, alusrca, jal, sext; output reg 2:0 state;reg2:0 next_state;parameter2:0sif3b000,/IF statesid = 3b001,/ IDstatesexe = 3b010,/ EXE statesmem3b011,/ MEM stateswb = 3b100;/ WBstatewirer_type,i_ad
25、d,i_sub,i_and,i_or,i_xor,i_sll,i_srl,i_sra,ir;wirei_addi,i_andi,i_ori,i_xori,iw,i_sw,i_beq,i_bne,i_lui,i_j,i_jal;and(r_type,op5,op4,op3,op2,op1,op0);and(i_add,r_type,func5,func4,func3,func2,func1,funcO );func5,func4,func3,func2, func1,funcO);func5,func4,func3,func2,func1,funcO);func5,func4,func3, fu
26、nc0);func5,func4,func3, func1,funcO);and(i_sub,r_type, and(i_and,r_type, and(i_or,r_type,func2,func1,and(i_xor,r_type,func2,and(i_sll,r_type,func5,func4,func3,func2 ,func1,funcO);and(i_srl,r_type,func5,func4,func3,func2,func1,funcO);an d(i_sra,r_type,fun c5,fun c4,fun c3,fun c2,func1,funcO);and(i_jr,r_type,fun c5,fun c4,fun
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 臨沂職業(yè)學(xué)院《意大利文學(xué)史》2023-2024學(xué)年第二學(xué)期期末試卷
- 教具及類似用具項(xiàng)目安全評估報告
- 長春工程學(xué)院《車輛設(shè)計》2023-2024學(xué)年第二學(xué)期期末試卷
- 北京化工大學(xué)《建筑模型》2023-2024學(xué)年第二學(xué)期期末試卷
- 江蘇省蘇州市市轄區(qū)市級名校2025年初三下學(xué)期期中考試物理試題(文理)試卷含解析
- 同濟(jì)大學(xué)《醫(yī)學(xué)美容護(hù)理》2023-2024學(xué)年第二學(xué)期期末試卷
- 天津音樂學(xué)院《當(dāng)代世界文學(xué)》2023-2024學(xué)年第一學(xué)期期末試卷
- 河北公安警察職業(yè)學(xué)院《燃?xì)廨斉湔n程設(shè)計》2023-2024學(xué)年第二學(xué)期期末試卷
- 燕山大學(xué)《法語》2023-2024學(xué)年第一學(xué)期期末試卷
- 長沙醫(yī)學(xué)院《互聯(lián)網(wǎng)金融服務(wù)營銷》2023-2024學(xué)年第二學(xué)期期末試卷
- 醫(yī)院患者自殺應(yīng)急預(yù)案
- 幼兒園大班繪本《愛書的孩子》無聲PPT
- DB3311T 132-2020 住宅小區(qū)物業(yè)服務(wù)規(guī)范
- (中職)門店運(yùn)營實(shí)務(wù)教學(xué)ppt課件(完整版)
- 2022更新國家開放大學(xué)電大《計算機(jī)應(yīng)用基礎(chǔ)(專)》終結(jié)性考試大作業(yè)答案任務(wù)一
- 3.無人機(jī)在風(fēng)電系統(tǒng)應(yīng)用解決方案
- 廣東省異地就醫(yī)備案登記表
- 人教鄂教版四年級下冊科學(xué)全冊教案
- SIEMENS-S120變頻器硬件、軟件培訓(xùn)(高端培訓(xùn))課件
- CA6132普通車床使用說明書
評論
0/150
提交評論