EDN首页   博客首页

日志档案

发表于 2008-3-16 17:20:41

0

标签: 无标签

一个加法器的程序错误的改进

library  ieee;
use  ieee.std_logic_1164.all;
use  ieee.std_logic_unsigned.all;

entity adder is
   port (
   in1  : in bit_vector;
   in2  : in bit_vector;
   pout : out bit_vector
   );
end adder; 
architecture func of adder is
begin
   process(in1,in2)
   begin
   pout <= in1 + in2 after 2 ns;
   end process;
end  func;

一开始的这个加法器的程序,在编译时通不过,出现了can't determine definition of operator'+'的这样的错误,上网找了一下,发现和我一样碰到这个问题的菜鸟(我也一样)还不在少数,经过老师的指导才知道,原来是定义输入输出数据的类型时错了,没有指明数据是多少位的,还有,after 2ns也是没必要加的,因为延迟时间只是在硬件的时候才用到.

改正的程序:

library  ieee;
use  ieee.std_logic_1164.all;
use  ieee.std_logic_unsigned.all;
entity adder is
   port (
   in1  : in STD_LOGIC_VECTOR(0 to 1);
   in2  : in STD_LOGIC_VECTOR(0 to 1);
   pout : out STD_LOGIC_VECTOR(0 to 1)
   );
end adder; 
architecture func of adder is
begin
   process(in1,in2)
   begin
   pout <= in1+in2 ;
   end process;
end  func;

系统分类: CPLD/FPGA   |   用户分类: 无分类   |   来源: 无分类   |   【推荐给朋友】   |   【添加到收藏夹】

    阅读(343)    回复(0)  

投一票您将和博主都有获奖机会!