⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control.vhd

📁 Plasma IP Core 你可以利用这个组件在FPGA中设计MIPS结构的CPU
💻 VHD
📖 第 1 页 / 共 2 页
字号:
   when "000011" =>   --JAL    r[31]=s->pc_next; s->pc_next=(s->pc&0xf0000000)|target;      c_source := C_FROM_PC_PLUS4;      rd := "011111";      pc_source := FROM_OPCODE25_0;   when "000010" =>   --J      s->pc_next=(s->pc&0xf0000000)|target;       pc_source := FROM_OPCODE25_0;   when "000100" =>   --BEQ    branch=r[rs]==r[rt];      a_source := A_FROM_PC;      b_source := B_FROM_IMMX4;      alu_function := ALU_ADD;      pc_source := FROM_BRANCH;      branch_function := BRANCH_EQ;   when "000101" =>   --BNE    branch=r[rs]!=r[rt];      a_source := A_FROM_PC;      b_source := B_FROM_IMMX4;      alu_function := ALU_ADD;      pc_source := FROM_BRANCH;      branch_function := BRANCH_NE;   when "000110" =>   --BLEZ   branch=r[rs]<=0;      a_source := A_FROM_PC;      b_source := b_FROM_IMMX4;      alu_function := ALU_ADD;      pc_source := FROM_BRANCH;      branch_function := BRANCH_LEZ;   when "000111" =>   --BGTZ   branch=r[rs]>0;      a_source := A_FROM_PC;      b_source := B_FROM_IMMX4;      alu_function := ALU_ADD;      pc_source := FROM_BRANCH;      branch_function := BRANCH_GTZ;   when "001000" =>   --ADDI   r[rt]=r[rs]+(short)imm;      b_source := B_FROM_SIGNED_IMM;      c_source := C_FROM_ALU;      rd := rt;      alu_function := ALU_ADD;   when "001001" =>   --ADDIU  u[rt]=u[rs]+(short)imm;      b_source := B_FROM_SIGNED_IMM;      c_source := C_FROM_ALU;      rd := rt;      alu_function := ALU_ADD;   when "001010" =>   --SLTI   r[rt]=r[rs]<(short)imm;      b_source := B_FROM_SIGNED_IMM;      c_source := C_FROM_ALU;      rd := rt;      alu_function := ALU_LESS_THAN_SIGNED;   when "001011" =>   --SLTIU  u[rt]=u[rs]<(unsigned long)(short)imm;      b_source := B_FROM_IMM;      c_source := C_FROM_ALU;      rd := rt;      alu_function := ALU_LESS_THAN;   when "001100" =>   --ANDI   r[rt]=r[rs]&imm;      b_source := B_FROM_IMM;      c_source := C_FROM_ALU;      rd := rt;      alu_function := ALU_AND;   when "001101" =>   --ORI    r[rt]=r[rs]|imm;      b_source := B_FROM_IMM;      c_source := C_FROM_ALU;      rd := rt;      alu_function := ALU_OR;   when "001110" =>   --XORI   r[rt]=r[rs]^imm;      b_source := B_FROM_IMM;      c_source := C_FROM_ALU;      rd := rt;      alu_function := ALU_XOR;   when "001111" =>   --LUI    r[rt]=(imm<<16);      c_source := C_FROM_IMM_SHIFT16;      rd := rt;   when "010000" =>   --COP0      alu_function := ALU_OR;      c_source := C_FROM_ALU;      if opcode(23) = '0' then  --move from CP0         rs := '1' & opcode(15 downto 11);         rt := "000000";         rd := '0' & opcode(20 downto 16);      else                      --move to CP0         rs := "000000";         rd(5) := '1';         pc_source := FROM_BRANCH;   --delay possible interrupt         branch_function := BRANCH_NO;      end if;   when "010001" =>   --COP1   when "010010" =>   --COP2   when "010011" =>   --COP3   when "010100" =>   --BEQL   lbranch=r[rs]==r[rt];      a_source := A_FROM_PC;      b_source := B_FROM_IMMX4;      alu_function := ALU_ADD;      pc_source := FROM_LBRANCH;      branch_function := BRANCH_EQ;   when "010101" =>   --BNEL   lbranch=r[rs]!=r[rt];      a_source := A_FROM_PC;      b_source := B_FROM_IMMX4;      alu_function := ALU_ADD;      pc_source := FROM_LBRANCH;      branch_function := BRANCH_NE;   when "010110" =>   --BLEZL  lbranch=r[rs]<=0;      a_source := A_FROM_PC;      b_source := B_FROM_IMMX4;      alu_function := ALU_ADD;      pc_source := FROM_LBRANCH;      branch_function := BRANCH_LEZ;   when "010111" =>   --BGTZL  lbranch=r[rs]>0;      a_source := A_FROM_PC;      b_source := B_FROM_IMMX4;      alu_function := ALU_ADD;      pc_source := FROM_LBRANCH;      branch_function := BRANCH_GTZ;   when "100000" =>   --LB     r[rt]=*(signed char*)ptr;      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      rd := rt;      c_source := C_FROM_MEMORY;      mem_source := MEM_READ8S;    --address=(short)imm+r[rs];   when "100001" =>   --LH     r[rt]=*(signed short*)ptr;      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      rd := rt;      c_source := C_FROM_MEMORY;      mem_source := MEM_READ16S;   --address=(short)imm+r[rs];   when "100010" =>   --LWL    //Not Implemented      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      rd := rt;      c_source := C_FROM_MEMORY;      mem_source := MEM_READ32;   when "100011" =>   --LW     r[rt]=*(long*)ptr;      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      rd := rt;      c_source := C_FROM_MEMORY;      mem_source := MEM_READ32;   when "100100" =>   --LBU    r[rt]=*(unsigned char*)ptr;      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      rd := rt;      c_source := C_FROM_MEMORY;      mem_source := MEM_READ8;    --address=(short)imm+r[rs];   when "100101" =>   --LHU    r[rt]=*(unsigned short*)ptr;      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      rd := rt;      c_source := C_FROM_MEMORY;      mem_source := MEM_READ16;    --address=(short)imm+r[rs];   when "100110" =>   --LWR    //Not Implemented   when "101000" =>   --SB     *(char*)ptr=(char)r[rt];      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      mem_source := MEM_WRITE8;   --address=(short)imm+r[rs];   when "101001" =>   --SH     *(short*)ptr=(short)r[rt];      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      mem_source := MEM_WRITE16;   when "101010" =>   --SWL    //Not Implemented      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      mem_source := MEM_WRITE32;  --address=(short)imm+r[rs];   when "101011" =>   --SW     *(long*)ptr=r[rt];      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_SIGNED_IMM;      alu_function := ALU_ADD;      mem_source := MEM_WRITE32;  --address=(short)imm+r[rs];   when "101110" =>   --SWR    //Not Implemented   when "101111" =>   --CACHE   when "110000" =>   --LL     r[rt]=*(long*)ptr;   when "110001" =>   --LWC1    when "110010" =>   --LWC2    when "110011" =>   --LWC3    when "110101" =>   --LDC1    when "110110" =>   --LDC2    when "110111" =>   --LDC3    when "111000" =>   --SC     *(long*)ptr=r[rt]; r[rt]=1;   when "111001" =>   --SWC1    when "111010" =>   --SWC2    when "111011" =>   --SWC3    when "111101" =>   --SDC1    when "111110" =>   --SDC2    when "111111" =>   --SDC3    when others =>   end case;   if c_source = C_FROM_NULL then      rd := "000000";   end if;   if intr_signal = '1' or is_syscall = '1' then      rs := "111111";  --interrupt vector      rt := "000000";      rd := "101110";  --save PC in EPC      alu_function := ALU_OR;      shift_function := SHIFT_NOTHING;      mult_function := MULT_NOTHING;      branch_function := BRANCH_YES;      a_source := A_FROM_REG_SOURCE;      b_source := B_FROM_REG_TARGET;      c_source := C_FROM_PC;      pc_source := FROM_LBRANCH;      mem_source := MEM_FETCH;      exception_out <= '1';   else      exception_out <= '0';   end if;   rs_index <= rs;   rt_index <= rt;   rd_index <= rd;   imm_out <= imm;   alu_func <= alu_function;   shift_func <= shift_function;   mult_func <= mult_function;   branch_func <= branch_function;   a_source_out <= a_source;   b_source_out <= b_source;   c_source_out <= c_source;   pc_source_out <= pc_source;   mem_source_out <= mem_source;end process;end; --logic

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -