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

📄 sparc_disas.vhd

📁 free hardware ip core about sparcv8,a soc cpu in vhdl
💻 VHD
📖 第 1 页 / 共 2 页
字号:
  variable op1    : std_logic_vector(1 downto 0);  variable op2    : std_logic_vector(2 downto 0);  variable op3    : std_logic_vector(5 downto 0);  variable opf    : std_logic_vector(8 downto 0);  variable cond   : std_logic_vector(3 downto 0);  variable rs1, rs2, rd : std_logic_vector(4 downto 0);  variable addr   : std_logic_vector(31 downto 0);  variable annul  : std_ulogic;  variable i      : std_ulogic;  variable simm : std_logic_vector(12 downto 0);  variable insn	: pc_op_type;begin    op1   := op(31 downto 30);    op2   := op(24 downto 22);    op3   := op(24 downto 19);    opf   := op(13 downto 5);    cond  := op(28 downto 25);    annul := op(29);    rs1   := op(18 downto 14);    rs2   := op(4 downto 0);    rd    := op(29 downto 25);    i     := op(13);    simm  := op(12 downto 0);    insn.op := op;    insn.pc := pc;    case op1 is    when CALL =>       addr := pc + (op(29 downto 0) & "00");      return(tostf(pc) & bb & "call" & bl2 & tost(addr));    when FMT2 =>      case op2 is      when SETHI =>	if rd = "00000" then          return(tostf(pc) & bb & "nop");	else          return(tostf(pc) & bb & "sethi" & bl2 & "%hi(" &		tost(op(21 downto 0) & "0000000000") & "), " & ireg2st(rd));	end if;      when BICC | FBFCC =>         addr(31 downto 24) := (others => '0');        addr(1 downto 0) := (others => '0');        addr(23 downto 2) := op(21 downto 0);        if addr(23) = '1' then          addr(31 downto 24) := (others => '1');        else          addr(31 downto 24) := (others => '0');        end if;        addr := addr + pc;	if op2 = BICC then          if op(29) = '1' then            return(tostf(pc) & bb & 'b' & branchop(insn) & ",a" & bl2 & 		tost(addr));          else            return(tostf(pc) & bb & 'b' & branchop(insn) & bl2 & 		tost(addr));	  end if;	else          if op(29) = '1' then            return(tostf(pc) & bb & "fb" & fbranchop(insn) & ",a" & bl2 & 		tost(addr));          else            return(tostf(pc) & bb & "fb" & fbranchop(insn) & bl2 & 		tost(addr));	  end if;	end if;--      when CBCCC => cptrap := '1';      when others => return(tostf(pc) & bb & "unimp");      end case;    when FMT3 =>      case op3 is      when IAND => return(tostf(pc) & bb & "and" & bl2 & regres(insn,hex));      when IADD => return(tostf(pc) & bb & "add" & bl2 & regres(insn,dec));      when IOR  => 	if ((i = '0') and (rs1 = "00000") and (rs2 = "00000")) then	  return(tostf(pc) & bb & "clr" & bl2 & ireg2st(rd));	elsif ((i = '1') and (simm = "0000000000000")) or (rs1 = "00000") then	  return(tostf(pc) & bb & "mov" & bl2 & regres(insn,hex));	else	  return(tostf(pc) & bb & "or " & bl2 & regres(insn,hex));	end if;      when IXOR => return(tostf(pc) & bb & "xor" & bl2 & regres(insn,hex));      when ISUB => return(tostf(pc) & bb & "sub" & bl2 & regres(insn,dec));      when ANDN => return(tostf(pc) & bb & "andn" & bl2 & regres(insn,hex));      when ORN  => return(tostf(pc) & bb & "orn" & bl2 & regres(insn,hex));      when IXNOR =>	if ((i = '0') and ((rs1 = rd) or (rs2 = "00000"))) then	  return(tostf(pc) & bb & "not" & bl2 & ireg2st(rd));	else	  return(tostf(pc) & bb & "xnor" & bl2 & ireg2st(rd));	end if;      when ADDX => return(tostf(pc) & bb & "addx" & bl2 & regres(insn,dec));      when SUBX => return(tostf(pc) & bb & "subx" & bl2 & regres(insn,dec));      when ADDCC => return(tostf(pc) & bb & "addcc" & bl2 & regres(insn,dec));      when ANDCC => return(tostf(pc) & bb & "andcc" & bl2 & regres(insn,hex));      when ORCC => return(tostf(pc) & bb & "orcc" & bl2 & regres(insn,hex));      when XORCC => return(tostf(pc) & bb & "xorcc" & bl2 & regres(insn,hex));      when SUBCC => return(tostf(pc) & bb & "subcc" & bl2 & regres(insn,dec));      when ANDNCC => return(tostf(pc) & bb & "andncc" & bl2 & regres(insn,hex));      when ORNCC => return(tostf(pc) & bb & "orncc" & bl2 & regres(insn,hex));      when XNORCC => return(tostf(pc) & bb & "xnorcc" & bl2 & regres(insn,hex));      when ADDXCC => return(tostf(pc) & bb & "addxcc" & bl2 & regres(insn,hex));      when UMAC   => return(tostf(pc) & bb & "umac" & bl2 & regres(insn,dec));      when SMAC   => return(tostf(pc) & bb & "smac" & bl2 & regres(insn,dec));      when UMUL   => return(tostf(pc) & bb & "umul" & bl2 & regres(insn,dec));      when SMUL   => return(tostf(pc) & bb & "smul" & bl2 & regres(insn,dec));      when UMULCC => return(tostf(pc) & bb & "umulcc" & bl2 & regres(insn,dec));      when SMULCC => return(tostf(pc) & bb & "smulcc" & bl2 & regres(insn,dec));      when SUBXCC => return(tostf(pc) & bb & "subxcc" & bl2 & regres(insn,dec));      when UDIV   => return(tostf(pc) & bb & "udiv" & bl2 & regres(insn,dec));      when SDIV   => return(tostf(pc) & bb & "sdiv" & bl2 & regres(insn,dec));      when UDIVCC => return(tostf(pc) & bb & "udivcc" & bl2 & regres(insn,dec));      when SDIVCC => return(tostf(pc) & bb & "sdivcc" & bl2 & regres(insn,dec));      when TADDCC => return(tostf(pc) & bb & "taddcc" & bl2 & regres(insn,dec));      when TSUBCC => return(tostf(pc) & bb & "tsubcc" & bl2 & regres(insn,dec));      when TADDCCTV => return(tostf(pc) & bb & "taddcctv" & bl2 & regres(insn,dec));      when TSUBCCTV => return(tostf(pc) & bb & "tsubcctv" & bl2 & regres(insn,dec));      when MULSCC => return(tostf(pc) & bb & "mulscc" & bl2 & regres(insn,dec));      when ISLL => return(tostf(pc) & bb & "sll" & bl2 & regres(insn,dec));      when ISRL => return(tostf(pc) & bb & "srl" & bl2 & regres(insn,dec));      when ISRA => return(tostf(pc) & bb & "sra" & bl2 & regres(insn,dec));      when RDY  =>         if rs1 /= "00000" then	  return(tostf(pc) & bb & "mov" & bl2 & "%asr" &	         tostd(rs1) & ", " & ireg2st(rd));	else	  return(tostf(pc) & bb & "mov" & bl2 & "%y, " & ireg2st(rd));        end if;      when RDPSR  => return(tostf(pc) & bb & "mov" & bl2 & "%psr, " & ireg2st(rd));      when RDWIM  => return(tostf(pc) & bb & "mov" & bl2 & "%wim, " & ireg2st(rd));      when RDTBR  => return(tostf(pc) & bb & "mov" & bl2 & "%tbr, " & ireg2st(rd));      when WRY  =>	if (rs1 = "00000") or (rs2 = "00000") then          if rd /= "00000" then	    return(tostf(pc) & bb & "mov" & bl2	         & regimm(insn,hex,false) & ", %asr" & tost(rd));	  else	    return(tostf(pc) & bb & "mov" & bl2 & regimm(insn,hex,false) & ", %y");	  end if;	else          if rd /= "00000" then	    return(tostf(pc) & bb & "wr " & bl2 & "%asr" 	         & regimm(insn,hex,false) & ", %asr" & tost(rd));	  else	    return(tostf(pc) & bb & "wr " & bl2 & regimm(insn,hex,false) & ", %y");	  end if;	end if;      when WRPSR  =>	if (rs1 = "00000") or (rs2 = "00000") then	  return(tostf(pc) & bb & "mov" & bl2 & regimm(insn,hex,false) & ", %psr");	else	  return(tostf(pc) & bb & "wr " & bl2 & regimm(insn,hex,false) & ", %psr");	end if;      when WRWIM  =>	if (rs1 = "00000") or (rs2 = "00000") then	  return(tostf(pc) & bb & "mov" & bl2 & regimm(insn,hex,false) & ", %wim");	else	  return(tostf(pc) & bb & "wr " & bl2 & regimm(insn,hex,false) & ", %wim");	end if;      when WRTBR  =>	if (rs1 = "00000") or (rs2 = "00000") then	  return(tostf(pc) & bb & "mov" & bl2 & regimm(insn,hex,false) & ", %tbr");	else	  return(tostf(pc) & bb & "wr " & bl2 & regimm(insn,hex,false) & ", %tbr");	end if;      when JMPL => 	if (rd = "00000") then	  if (i = '1') and (simm = "0000000001000") then	    if (rs1 = "11111") then return(tostf(pc) & bb & "ret");	    elsif (rs1 = "01111") then return(tostf(pc) & bb & "retl");	    else return(tostf(pc) & bb & "jmp" & bl2 & regimm(insn,dec,true));	    end if;	  else return(tostf(pc) & bb & "jmp" & bl2 & regimm(insn,dec,true));	  end if;	else return(tostf(pc) & bb & "jmpl" & bl2 & regres(insn,dec));	end if;      when TICC =>         return(tostf(pc) & bb & 't' & branchop(insn) & bl2 & regimm(insn,hex,false));      when FLUSH =>         return(tostf(pc) & bb & "flush" & bl2 & regimm(insn,hex,false));      when RETT =>         return(tostf(pc) & bb & "rett" & bl2 & regimm(insn,dec,true));      when RESTORE => 	if (rd = "00000") then	  return(tostf(pc) & bb & "restore");	else	  return(tostf(pc) & bb & "restore" & bl2 & regres(insn,hex));	end if;      when SAVE => 	if (rd = "00000") then return(tostf(pc) & bb & "save");	else return(tostf(pc) & bb & "save" & bl2 & regres(insn,dec)); end if;      when FPOP1 =>         case opf is	when FITOS => return(tostf(pc) & bb & "fitos" & bl2 & freg2(insn));	when FITOD => return(tostf(pc) & bb & "fitod" & bl2 & freg2(insn));	when FSTOI => return(tostf(pc) & bb & "fstoi" & bl2 & freg2(insn));                      	when FDTOI => return(tostf(pc) & bb & "fdtoi" & bl2 & freg2(insn));                      	when FSTOD => return(tostf(pc) & bb & "fstod" & bl2 & freg2(insn));	when FDTOS => return(tostf(pc) & bb & "fdtos" & bl2 & freg2(insn));	when FMOVS => return(tostf(pc) & bb & "fmovs" & bl2 & freg2(insn));	when FNEGS => return(tostf(pc) & bb & "fnegs" & bl2 & freg2(insn));	when FABSS => return(tostf(pc) & bb & "fabss" & bl2 & freg2(insn));	when FSQRTS => return(tostf(pc) & bb & "fsqrts" & bl2 & freg2(insn));	when FSQRTD => return(tostf(pc) & bb & "fsqrtd" & bl2 & freg2(insn));	when FADDS => return(tostf(pc) & bb & "fadds" & bl2 & freg3(insn));	when FADDD => return(tostf(pc) & bb & "faddd" & bl2 & freg3(insn));	when FSUBS => return(tostf(pc) & bb & "fsubs" & bl2 & freg3(insn));	when FSUBD => return(tostf(pc) & bb & "fsubd" & bl2 & freg3(insn));	when FMULS => return(tostf(pc) & bb & "fmuls" & bl2 & freg3(insn));	when FMULD => return(tostf(pc) & bb & "fmuld" & bl2 & freg3(insn));	when FSMULD => return(tostf(pc) & bb & "fsmuld" & bl2 & freg3(insn));	when FDIVS => return(tostf(pc) & bb & "fdivs" & bl2 & freg3(insn));	when FDIVD => return(tostf(pc) & bb & "fdivd" & bl2 & freg3(insn));        when others => return(tostf(pc) & bb & "unknown FOP1: " & tost(op));	end case;      when FPOP2 =>         case opf is	when FCMPS => return(tostf(pc) & bb & "fcmps" & bl2 & fregc(insn));	when FCMPD => return(tostf(pc) & bb & "fcmpd" & bl2 & fregc(insn));	when FCMPES => return(tostf(pc) & bb & "fcmpes" & bl2 & fregc(insn));	when FCMPED => return(tostf(pc) & bb & "fcmped" & bl2 & fregc(insn));        when others => return(tostf(pc) & bb & "unknown FOP2: " & tost(insn.op));	end case;      when CPOP1 => 	return(tostf(pc) & bb & "cpop1" & bl2 & tost("000"&opf) & ", " &creg3(insn));      when CPOP2 => 	return(tostf(pc) & bb & "cpop2" & bl2 & tost("000"&opf) & ", " &creg3(insn));      when others => return(tostf(pc) & bb & "unknown opcode: " & tost(insn.op));      end case;    when LDST =>      case op3 is      when STC => 	return(tostf(pc) & bb & "st" & bl2 & stparcp(insn, rd, dec));      when STF => 	return(tostf(pc) & bb & "st" & bl2 & stparf(insn, rd, dec));      when ST => 	if rd = "00000" then	  return(tostf(pc) & bb & "clr" & bl2 & stparc(insn, rd, dec));	else	  return(tostf(pc) & bb & "st" & bl2 & stpar(insn, rd, dec));	end if;      when STB => 	if rd = "00000" then	  return(tostf(pc) & bb & "clrb" & bl2 & stparc(insn, rd, dec));	else	  return(tostf(pc) & bb & "stb" & bl2 & stpar(insn, rd, dec));	end if;      when STH => 	if rd = "00000" then	  return(tostf(pc) & bb & "clrh" & bl2 & stparc(insn, rd, dec));	else	  return(tostf(pc) & bb & "sth" & bl2 & stpar(insn, rd, dec));	end if;      when STDC => 	return(tostf(pc) & bb & "std" & bl2 & stparcp(insn, rd, dec));      when STDF => 	return(tostf(pc) & bb & "std" & bl2 & stparf(insn, rd, dec));      when STCSR => 	return(tostf(pc) & bb & "st" & bl2 & "%csr, [" & regimm(insn,dec,true) & "]");      when STFSR => 	return(tostf(pc) & bb & "st" & bl2 & "%fsr, [" & regimm(insn,dec,true) & "]");      when STDCQ => 	return(tostf(pc) & bb & "std" & bl2 & "%cq, [" & regimm(insn,dec,true) & "]");      when STDFQ => 	return(tostf(pc) & bb & "std" & bl2 & "%fq, [" & regimm(insn,dec,true) & "]");      when ISTD => 	return(tostf(pc) & bb & "std" & bl2 & stpar(insn, rd, dec));      when STA => 	return(tostf(pc) & bb & "sta" & bl2 & stpara(insn, rd, dec));      when STBA => 	return(tostf(pc) & bb & "stba" & bl2 & stpara(insn, rd, dec));      when STHA => 	return(tostf(pc) & bb & "stha" & bl2 & stpara(insn, rd, dec));      when STDA => 	return(tostf(pc) & bb & "stda" & bl2 & stpara(insn, rd, dec));      when LDC => 	return(tostf(pc) & bb & "ld" & bl2 & ldparcp(insn, rd, dec));      when LDF => 	return(tostf(pc) & bb & "ld" & bl2 & ldparf(insn, rd, dec));      when LDCSR => 	return(tostf(pc) & bb & "ld" & bl2 & "[" & regimm(insn,dec,true) & "]" & ", %csr");      when LDFSR => 	return(tostf(pc) & bb & "ld" & bl2 & "[" & regimm(insn,dec,true) & "]" & ", %fsr");      when LD => 	return(tostf(pc) & bb & "ld" & bl2 & ldpar(insn, rd, dec));      when LDUB => 	return(tostf(pc) & bb & "ldub" & bl2 & ldpar(insn, rd, dec));      when LDUH => 	return(tostf(pc) & bb & "lduh" & bl2 & ldpar(insn, rd, dec));      when LDDC => 	return(tostf(pc) & bb & "ldd" & bl2 & ldparcp(insn, rd, dec));      when LDDF => 	return(tostf(pc) & bb & "ldd" & bl2 & ldparf(insn, rd, dec));      when LDD => 	return(tostf(pc) & bb & "ldd" & bl2 & ldpar(insn, rd, dec));      when LDSB => 	return(tostf(pc) & bb & "ldsb" & bl2 & ldpar(insn, rd, dec));      when LDSH => 	return(tostf(pc) & bb & "ldsh" & bl2 & ldpar(insn, rd, dec));      when LDSTUB => 	return(tostf(pc) & bb & "ldstub" & bl2 & ldpar(insn, rd, dec));      when SWAP   => 	return(tostf(pc) & bb & "swap" & bl2 & ldpar(insn, rd, dec));      when LDA => 	return(tostf(pc) & bb & "lda" & bl2 & ldpara(insn, rd, dec));      when LDUBA => 	return(tostf(pc) & bb & "lduba" & bl2 & ldpara(insn, rd, dec));      when LDUHA => 	return(tostf(pc) & bb & "lduha" & bl2 & ldpara(insn, rd, dec));      when LDDA => 	return(tostf(pc) & bb & "ldda" & bl2 & ldpara(insn, rd, dec));      when LDSBA => 	return(tostf(pc) & bb & "ldsba" & bl2 & ldpara(insn, rd, dec));      when LDSHA => 	return(tostf(pc) & bb & "ldsha" & bl2 & ldpara(insn, rd, dec));      when LDSTUBA => 	return(tostf(pc) & bb & "ldstuba" & bl2 & ldpara(insn, rd, dec));      when SWAPA   => 	return(tostf(pc) & bb & "swapa" & bl2 & ldpara(insn, rd, dec));      when others => return(tostf(pc) & bb & "unknown opcode: " & tost(op));      end case;    when others => return(tostf(pc) & bb & "unknown opcode: " & tost(op));    end case;end;procedure print_insn(ndx: integer; pc, op, res : std_logic_vector(31 downto 0);	 valid, trap, wr, rest : boolean) isbegin  if valid then    if trap then print ("cpu" & tost(ndx) &": " & ins2st(pc, op) & "  (trapped)");    elsif rest then print ("cpu" & tost(ndx) &": " & ins2st(pc, op) & "  (restart)");    elsif wr then print ("cpu" & tost(ndx) & ": " & ins2st(pc, op) & "  [" & tost(res) & "]");    else print ("cpu" & tost(ndx) & ": " & ins2st(pc, op)); end if;  end if;end;procedure print_fpinsn(ndx: integer; pc, op : std_logic_vector(31 downto 0);                       res : std_logic_vector(63 downto 0);                       dpres, valid, trap, wr : boolean) isbegin  if valid then    if trap then print ("cpu" & tost(ndx) &": " & ins2st(pc, op) & "  (trapped)");    elsif wr then      if dpres then print ("cpu" & tost(ndx) & ": " & ins2st(pc, op) & "  [" & tost(res) & "]");      else print ("cpu" & tost(ndx) & ": " & ins2st(pc, op) & "  [" & tost(res(63 downto 32)) & "]"); end if;    else print ("cpu" & tost(ndx) & ": " & ins2st(pc, op)); end if;  end if;end;end;-- pragma translate_on

⌨️ 快捷键说明

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