|
基于MIPS_RISC指令集的用VHDL語言寫的可以在quartus軟件運(yùn)行成功的16位cpu模型機(jī)源碼及CPU芯片邏輯技術(shù)設(shè)計(jì)書分享,以及全國大學(xué)生計(jì)算機(jī)設(shè)計(jì)大賽參考,本設(shè)計(jì)僅僅只是基礎(chǔ)設(shè)計(jì),滿足5條機(jī)器指令執(zhí)行,若需要更多要求,可以自行更改邏輯設(shè)計(jì)滿足不同要求。注意還有現(xiàn)成的設(shè)計(jì)原稿哦,文件大小限制,去繁從簡為主!
總體狀態(tài)轉(zhuǎn)換圖
畫出QuartusⅡ環(huán)境下的數(shù)據(jù)通路總圖
七、編寫匯編語言,調(diào)試程序,給出結(jié)果
為了方便輸入與編碼,指令格式自己譯成 操作碼/尋址方式/目的寄存器/源寄存器
總體仿真波形圖
1.ALU
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity ALU is
port(
input1,input2:in std_logic_vector(15 downto 0); --兩個(gè)操作數(shù)
choice:in std_logic_vector(5 downto 0); --選擇進(jìn)行的運(yùn)算
result:buffer std_logic_vector(15 downto 0); --結(jié)果輸出
result2:buffer std_logic_vector(15 downto 0); --結(jié)果輸出
psw :buffer std_logic_vector(15 downto 0) --PSW,psw(0)為C,psw(1)為Z,psw(2)為S,psw(3)為O
);
end ALU;
architecture alu_b of ALU is
signal q : std_logic_vector(16 downto 0); --中間變量
signal result3:std_logic_vector(32 downto 0); --中間變量
begin
process(input1,input2,choice,q,psw)
variable i : integer;
variable p :std_logic_vector(15 downto 0);
begin
if choice="000001" then --ADD
q<=('0' & input1) + ('0' & input2);
psw(0) <=q(16);
psw(2) <=q(15);
if q(15 downto 0)= "0000000000000000" then
psw(1)<= '1';
else
psw(1)<= '0';
end if;
result <= q(15 downto 0);
elsif choice="000010"then --ADDU
result <= input1 + input2;
elsif choice="000011" then --SUB
q<=('0'&input1) - ('0'& input2);
psw(0) <=q(16);
psw(2) <=q(15);
if q(15 downto 0)= "0000000000000000" then
psw(1)<= '1';
else
psw(1)<= '0';
end if;
result <= q(15 downto 0);
elsif choice="000100" then --SUBU
result <= input1 - input2;
--elsif choice="000101" then --IMUL
-- result3<= ('0'&input1) * ('0'& input2);
-- psw(0) <=result3(32);
-- psw(2) <=result3(31);
-- if result3(31 downto 0)= "00000000000000000000000000000000" then
-- psw(1)<= '1';
--else
-- psw(1)<= '0';
--end if;
-- result<=result3(31 downto 16);
-- result2<=result3(15 downto 0);
--elsif choice="000110" then --IDIV
-- q<= ('0'&input1) mod ('0'& input2);
-- psw(0) <=q(16);
-- psw(2) <=q(15);
-- if q(15 downto 0)= "0000000000000000" then
-- psw(1)<= '1';
-- else
-- psw(1)<= '0';
-- end if;
-- result <=q(15 downto 0);
-- result2 <=input1 rem input2;
elsif choice="000111" then --INC
q(15 downto 0)<= "0000000000000001" + input1;
result <=q(15 downto 0);
elsif choice="001000" then --DEC
q(15 downto 0)<= input1 - "0000000000000001" ;
result <=q(15 downto 0);
elsif choice="001001" then --CMP
q<=('0'&input1) - ('0'& input2);
psw(0) <=q(16);
psw(2) <=q(15);
if q(15 downto 0)= "0000000000000000" then
psw(1)<= '1';
else
psw(1)<= '0';
end if;
elsif choice="001010" then --NEG
q<="10000000000000000" - ('0'&input1);
psw(0) <=q(16);
psw(2) <=q(15);
if q(15 downto 0)= "0000000000000000" then
psw(1)<= '1';
else
psw(1)<= '0';
end if;
result <=q(15 downto 0);
elsif choice="001011" then --NOT
result <= not input1;
elsif choice="001100" then --AND
psw(0) <='0';
psw(3) <='0';
result <= input1 and input2;
psw(2) <= result(15);
if result(15 downto 0)= "0000000000000000" then
psw(1)<= '1';
else
psw(1)<= '0';
end if;
elsif choice="001101" then --OR
psw(0) <='0';
psw(3) <='0';
result <= input1 or input2;
psw(2) <= result(15);
if result(15 downto 0)= "0000000000000000" then
psw(1)<= '1';
else
psw(1)<= '0';
end if;
elsif choice="001110" then --XOR
psw(0) <='0';
psw(3) <='0';
result <= input1 xor input2;
psw(2) <= result(15);
if result(15 downto 0)= "0000000000000000" then
psw(1)<= '1';
else
psw(1)<= '0';
end if;
elsif choice="001111" then --TEST
psw(0) <='0';
psw(3) <='0';
q(15 downto 0) <= input1 xor input2;
psw(2) <= q(15);
if q(15 downto 0)= "0000000000000000" then
psw(1)<= '1';
else
psw(1)<= '0';
end if;
elsif choice="010000" then --SHL
-- function f(bits,shift)
-- for i in 1 to bits loop
-- case shift is
-- when shift="1001"
-- p:='0' & p(15 downto 1);
-- when shift="1010"
-- p:=p(15 downto 1) & '0' ;
-- when shift ="1011" then
-- p:=p(14 downto 0)& p(15);
-- when shift ="1100" then
-- p:=p(0) & p(15 downto 1) ;
-- end loop;
-- end function
end if;
全部資料51hei下載地址:
MIPS_16位CPU設(shè)計(jì).rar
(11.97 MB, 下載次數(shù): 21)
2019-11-20 12:20 上傳
點(diǎn)擊文件名下載附件
|
評分
-
查看全部評分
|