(VHDL小程序001)用VHDL设计比较器

code如下:

entity compare is

     port(

          in1,in2:in bit_vector;

          pout:out bit

          );

end compare;

 

architecture func of compare is

begin

     process(in1,in2)

     variable left:integer;

     variable right:integer;

     begin

          left:=bit_to_int(in1);

          right:=bit_to_int(in2);

          if(left<right) then pout<='1';

          else pout<='0';

          end if;

     end process;

end func;

=================================

变量相当于数据存储器,信号相当于信号连接线,常量相当电源与地。

用变量存数据,用的存储器比信号较少。

变量立即赋值,信号延时赋值。

posted @ 2008-08-12 11:22  安达米特  阅读(1536)  评论(0编辑  收藏  举报