减少比较
上一篇 / 下一篇 2007-12-11 16:19:05 / 个人分类:示例代码
相关阅读:
- IP软核及硬核的优劣势比较 (vfdff, 2007-10-07)
-
引用 删除 zhongyunde / 2007-12-11 17:22:35
-
function Jexp (Pexp,ai,aq,bi,bq,ci,cq,di,dq:std_logic_vector) return std_logic_vector is
variable Cexp :std_logic_vector(1 downto 0); -- 0~~3
variable Ti,Tq,temp :std_logic_vector(2 downto 0);
type rom_type is array(0 to 7) of Std_Logic_Vector(1 downto 0);
constant table : rom_type := ("00","01","10","10","11","11","11","11");
variable result :std_logic_vector(1 downto 0);
begin
Ti := (ai or bi) or (ci or di);
Tq := (aq or bq) or (cq or dq);
temp := Ti or Tq;
Cexp := table(conv_integer(temp));
result(1) := Cexp(1) or Pexp(1);
result(0) := (Cexp(1) and Cexp(0)) or (Pexp(1) and Pexp(0)) or
(not Pexp(1) and Cexp(0)) or (not Cexp(1) and Pexp(0));
return result;
end function Jexp;
进一步优化,把最会的 if 语句也去掉
