




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、16位CPU的設(shè)計(jì)要求:此模型機(jī)的功能是將存儲(chǔ)區(qū)的數(shù)據(jù)塊復(fù)制到另一個(gè)存儲(chǔ)區(qū)。匯編代碼如下: START:LOADI R1,0010H ;源操作數(shù)地址送R1LOADI R2,0030H ;目的操作數(shù)地址送R2LOADI R6,002FH ;結(jié)束地址送R6NEXT:LOAD R3,R1 ;取數(shù)STORE R2,R3 ;存數(shù)BRANCHGTI START ;如果R1R6,則轉(zhuǎn)向STARTINC R1 ;修改源地址INC R2 ;修改目的地址BRANCHI NEXT ;轉(zhuǎn)向NEXT1. 16位CPU的組成結(jié)構(gòu)2. 指令系統(tǒng)的設(shè)計(jì)一、 指令格式1) 單字指令格式2) 雙字指令格式二、 指令操作碼操作碼指
2、令功能00001LOAD裝載數(shù)據(jù)到寄存器00010STORE將寄存器的數(shù)據(jù)存入到存儲(chǔ)器00100LOADI將立即數(shù)裝入到寄存器00101BRANCHI無(wú)條件轉(zhuǎn)移到由立即數(shù)指定的地址00110BRANCHGTI如果源寄存器內(nèi)容大于目的寄存器的內(nèi)容,則轉(zhuǎn)移到由立即數(shù)指定的地址00111INC寄存器內(nèi)容加1指令依據(jù)以上設(shè)計(jì)的指令系統(tǒng),則完成數(shù)據(jù)塊復(fù)制的程序如下:地址機(jī)器碼指令 功能說(shuō)明0000H0001H2001H0010HLOADI R1,0010H源操作數(shù)地址送R10002H0003H2002H0030HLOADI R2,0030H目的操作數(shù)地址送R20004H0005H2006H002FHLO
3、ADI R6,002FH結(jié)束地址送R60006H080BHLOAD R3,R1取數(shù)0007H101AHSTORE R2,R3存數(shù)0008H 0009H300EH0000HBRANCHGTI 0000如果R1大于R6,則轉(zhuǎn)向地址0000000AH3801HINC R1修改源地址000BH3802HINC R2修改目的地址000CH000DH2800H0006HBRANCHI 0006H轉(zhuǎn)向00006H,實(shí)現(xiàn)循環(huán)3. VHDL設(shè)計(jì)一、 程序包:說(shuō)明運(yùn)算器的功能、移動(dòng)寄存器的操作、比較器的比較類型和用于CPU控制的狀態(tài)類型。library ieee;use ieee.std_logic_1164.a
4、ll;use ieee.std_logic_arith.all;package cpu_lib is subtype t_shift is unsigned (3 downto 0);constant shftpass :unsigned(3 downto 0):=0000;constant sftl :unsigned(3 downto 0):=0001;constant sftr:unsigned(3 downto 0):=0010;constant rotl :unsigned(3 downto 0):=0011;constant rotr :unsigned(3 downto 0):=
5、0100;subtype t_alu is unsigned(3 downto 0);constant alupass :unsigned(3 downto 0):=0000;constant andOp :unsigned(3 downto 0):=0001;constant orOp:unsigned(3 downto 0):=0010;constant notOp :unsigned(3 downto 0):=0011;constant xorOp :unsigned(3 downto 0):=0100;constant plus :unsigned(3 downto 0):=0101;
6、constant alusub :unsigned(3 downto 0):=0110;constant inc :unsigned(3 downto 0):=0111;constant dec :unsigned(3 downto 0):=1000;constant zero:unsigned(3 downto 0):=1001;subtype t_comp is unsigned 2 downto 0);constant eq :unsigned(2 downto 0):=000;constant neq :unsigned(2 downto 0):=001;constant gt:uns
7、igned(2 downto 0):=010;constant gte :unsigned(2 downto 0):=011;constant lt :unsigned(2 downto 0):=100;constant lte :unsigned(2 downto 0):=101;subtype t_reg is std_logic_vector(2 downto 0);type state is (reset1,reset2,reset3,reset4,reset5,reset6,execute,nop,load,store,move,load2,load3,load4,store2,st
8、ore3,store4,move2,move3,move4,incPc,incPc2,incPc3,incPc4,incPc5,incPc6,loadPc,loadPc2,loadPc3,loadPc4,bgtI2,bgtI3,bgtI4,bgtI5,bgtI6,bgtI7,bgtI8,bgtI9,bgtI10,braI2,braI3,braI4,braI5,braI6,loadI2,loadI3,loadI4,loadI5,loadI6,inc2,inc3,inc4);subtype bit16 is std_logic_vector(15 downto 0);end cpu_lib;二、基
9、本部件的設(shè)計(jì)1) 運(yùn)算器的設(shè)計(jì) 功能library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use work.cpu_lib.all;entity alu is port(a,b:in bit16;sel:in t_alu;c:out bit16);end alu;architecture rt1 of alu is beginprocess(a,b,sel)begincase sel iswhen alupass= c c c c c c c c c c c if a=b then compout =1
10、 after 1ns;else compout if a/=b then compout =1 after 1ns;else compout if ab then compout =1 after 1ns;else compout if a=b then compout =1 after 1ns;else compout if ab then compout =1 after 1ns;else compout if a=b then compout =1 after 1ns;else compout compout y y y y y y=0000000000000000 after 1 ns
11、;end case;end process;end rt1;4) 寄存器library ieee;use ieee.std_logic_1164.all;use work.cpu_lib.all;entity reg is port(a:in bit16;clk:in std_logic;q:out bit16);end reg;architecture rt1 of reg isbeginprocessbeginwait until clkevent and clk=1;q=a after 1ns;end process;end rt1;5) 寄存器組library ieee;use iee
12、e.std_logic_1164.all;use ieee.std_logic_unsigned.all;use work.cpu_lib.all;entity regarray is port(data:in bit16;sel:in t_reg;en,clk:in std_logic;q:out bit16);end regarray;architecture rt1 of regarray is type t_ram is array (0 to 7) of bit16;signal temp_data:bit16;beginprocess(clk,sel)variable ramdat
13、a:t_ram;beginif clkevent and clk=1 then ramdata(conv_integer(sel):=data;end if;temp_data=ramdata(conv_integer(sel) after 1 ns;end process;process(en,temp_data)beginif en=1 then q=temp_data after 1 ns; else q=ZZZZZZZZZZZZZZZZ after 1 ns;end if;end process;end rt1;6) 三態(tài)寄存器library ieee;use ieee.std_log
14、ic_1164.all;use ieee.std_logic_unsigned.all;use work.cpu_lib.all;entity trireg isport(a:in bit16;en,clk:in std_logic;q:out bit16);end trireg;architecture rt1 of trireg issignal val:bit16;beginprocessbeginwait until clkevent and clk=1;val=a;end process;process(en,val)beginif en=1 then q=val after 1 n
15、s;elsif en=0 then q=ZZZZZZZZZZZZZZZZ after 1 ns;else q=XXXXXXXXXXXXXXXX after 1 ns;end if;end process;end rt1;7) 控制器采用狀態(tài)機(jī)實(shí)現(xiàn)library IEEE;use IEEE.std_logic_1164.all;use work.cpu_lib.all;entity control isport( clock,reset,compout:in std_logic; instrReg:in bit16;progCntrWr,progCntrRd,addrRegWr,outRegWr
16、,outRegRd:out std_logic;shiftSel:out t_shift; aluSel:out t_alu; compSel:out t_comp;opRegRd,opRegWr,instrWr,regRd,regWr,rw,vma:out std_logic;regSel:out t_reg );end control;architecture rtl of control issignal current_state, next_state : state;beginprocess( current_state, instrReg, compout)beginprogCn
17、trWr = 0; progCntrRd = 0; addrRegWr = 0; outRegWr = 0;outRegRd = 0; shiftSel = shftpass; aluSel = alupass; compSel = eq;opRegRd = 0; opRegWr = 0; instrWr = 0; regSel = 000;regRd = 0; regWr = 0; rw = 0; vma aluSel=zero after 1 ns; shiftSel=shftpass; next_state aluSel=zero; shiftSel=shftpass; outRegWr
18、=1; next_state outRegRd=1; next_state outRegRd=1; progCntrWr=1;addrRegWr=1; next_state vma=1; rw = 0; next_state vma=1; rw=0;instrWr=1; next_state case instrReg(15 downto 11) iswhen 00000 = next_state regSel=instrReg(5 downto 3); regRd=1;next_state regSel=instrReg(2 downto 0); regRd=1;next_state reg
19、Sel=instrReg(5 downto 3); regRd=1; aluSel=alupass;shiftSel=shftpass; next_state progcntrRd=1; alusel=inc; shiftsel=shftpass;next_state progcntrRd=1; alusel=inc; shiftsel=shftpass;next_state regSel=instrReg(5 downto 3); regRd=1;next_state regSel=instrReg(2 downto 0); regRd=1; alusel=inc;shiftsel=shft
20、pass; next_statenext_state regSel = instrReg(5 downto 3); regRd = 1;addrregWr = 1; next_state vma = 1; rw = 0; next_state vma = 1; rw = 0; regSel = instrReg(2 downto 0);regWr = 1; next_state regSel = instrReg(2 downto 0); regRd = 1;addrregWr = 1; next_state regSel = instrReg(5 downto 3); regRd = 1;n
21、ext_state regSel = instrReg(5 downto 3); regRd = 1; rw = 1; next_state regSel = instrReg(5 downto 3); regRd = 1;aluSel =alupass;shiftsel = shftpass; outRegWr = 1; next_state outRegRd = 1; next_state outRegRd = 1;regSel = instrReg(2 downto 0); regWr = 1; next_state progcntrRd = 1; alusel = inc; shift
22、sel = shftpass;outregWr = 1; next_state outregRd = 1; next_state outregRd = 1; progcntrWr=1; addrregWr=1;next_state vma = 1; rw = 0; next_state vma = 1; rw = 0;regSel = instrReg(2 downto 0);regWr = 1; next_state progcntrRd = 1; alusel = inc; shiftsel = shftpass;outregWr = 1; next_state outregRd = 1;
23、 next_state outregRd=1; progcntrWr=1; addrregWr=1;next_state vma=1; rw=0; next_state vma = 1; rw = 0;progcntrWr = 1; next_state regSel = instrReg(5 downto 3); regRd = 1;opRegWr = 1; next_state opRegRd = 1; regSel = instrReg(2 downto 0);regRd = 1; compsel = gt; next_state opRegRd = 1 after 1 ns;regSe
24、l = instrReg(2 downto 0); regRd = 1; compsel = gt;if compout = 1 then next_state = bgtI5;else next_state progcntrRd=1; alusel=inc; shiftSel=shftpass;next_state progcntrRd = 1; alusel = inc; shiftsel = shftpass;outregWr = 1; next_state outregRd = 1; next_state outregRd = 1;progcntrWr = 1; addrregWr =
25、 1; next_state vma = 1; rw = 0; next_state vma = 1; rw = 0; progcntrWr = 1; next_state regSel = instrReg(2 downto 0); regRd = 1; alusel = inc;shiftsel = shftpass; outregWr = 1; next_state outregRd = 1; next_state outregRd = 1; regsel = instrReg(2 downto 0);regWr = 1; next_state progcntrRd = 1; next_state progcntrRd = 1; addrRegWr = 1; next_state vma = 1; rw = 0; next_state vma = 1; rw = 0; instr
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年音樂(lè)教師資格考試卷及答案
- 2025年社會(huì)工作與社會(huì)福利專業(yè)試卷及答案
- 2025年社會(huì)工作實(shí)務(wù)課程考試試卷及答案
- 2025年房地產(chǎn)經(jīng)營(yíng)管理考試試卷及答案
- 2025年機(jī)械設(shè)計(jì)基礎(chǔ)試題及答案
- 2025年教師資格證考試試卷及答案
- 石料加工銷售合同協(xié)議書
- 七級(jí)書法考試試題及答案
- 餐飲房租租賃合同協(xié)議書
- 2025年節(jié)能型泵及環(huán)保用泵項(xiàng)目合作計(jì)劃書
- 電網(wǎng)工程設(shè)備材料信息參考價(jià)2025年第一季度
- 江蘇南京茉莉環(huán)境投資有限公司招聘筆試題庫(kù)2025
- 吸氧并發(fā)癥預(yù)防及處理
- 針刺傷預(yù)防與處理(中華護(hù)理學(xué)會(huì)團(tuán)體標(biāo)準(zhǔn))
- 2024年安徽省初中學(xué)業(yè)水平考試生物試題含答案
- 2024年浙江省中考英語(yǔ)試題卷(含答案解析)
- MOOC 理解馬克思-南京大學(xué) 中國(guó)大學(xué)慕課答案
- 說(shuō)明書hid500系列變頻調(diào)速器使用說(shuō)明書s1.1(1)
- RTO處理工藝PFD計(jì)算
- 最美中鋁人申報(bào)表
- 柑橘采摘機(jī)器人的結(jié)構(gòu)設(shè)計(jì)說(shuō)明書
評(píng)論
0/150
提交評(píng)論