找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2887|回复: 0
打印 上一主题 下一主题
收起左侧

基于quartus 2 9.0c 软件的MIPS指令集16位CPU设计

[复制链接]
跳转到指定楼层
楼主
  基于MIPS_RISC指令集的用VHDL语言写的可以在quartus软件运行成功的16位cpu模型机源码及CPU芯片逻辑技术设计书分享,以及全国大学生计算机设计大赛参考,本设计仅仅只是基础设计,满足5条机器指令执行,若需要更多要求,可以自行更改逻辑设计满足不同要求。注意还有现成的设计原稿哦,文件大小限制,去繁从简为主!

总体状态转换图


画出QuartusⅡ环境下的数据通路总图



七、编写汇编语言,调试程序,给出结果

为了方便输入与编码,指令格式自己译成 操作码/寻址方式/目的寄存器/源寄存器


总体仿真波形图


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);  --两个操作数
     choice:in std_logic_vector(5 downto 0);          --选择进行的运算
     result:buffer std_logic_vector(15 downto 0);     --结果输出
     result2:buffer std_logic_vector(15 downto 0);     --结果输出
     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设计.rar (11.97 MB, 下载次数: 18)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表