设为首页
加入收藏
联系站长
首页 | 文章中心 | 下载中心 | 本站商品 | 学习资料 | 
您现在的位置: 电子爱好者 >> 文章中心 >> 数字电路 >> 正文 用户登录 新用户注册
[VHDL实例]三人表决器(三种不同的描述方式)          【字体:
[VHDL实例]三人表决器(三种不同的描述方式)
作者:佚名    文章来源:本站原创    点击数:    更新时间:2006-2-17

-- Three-input Majority Voter
-- The entity declaration is followed by three alternative architectures which achieve
the same functionality in different ways.
 
ENTITY maj IS
   PORT(a,b,c : IN BIT; m : OUT BIT);
END maj;
--Dataflow style architecture
ARCHITECTURE concurrent OF maj IS
BEGIN
   --selected signal assignment statement (concurrent)
    WITH a&b&c SELECT
        m <= '1' WHEN "110"|"101"|"011"|"111",'0' WHEN OTHERS;
END concurrent;
 
--Structural style architecture
ARCHITECTURE structure OF maj IS
 
   --declare components used in architecture
   COMPONENT and2 PORT(in1, in2 : IN BIT; out1 : OUT BIT);
   END COMPONENT;
   COMPONENT or3 PORT(in1, in2, in3 : IN BIT; out1 : OUT BIT);
   END COMPONENT;
   --declare local signals
   SIGNAL w1, w2, w3 : BIT;
 
BEGIN
   --component instantiation statements.
   --ports of component are mapped to signals
   --within architecture by position.
   gate1 : and2 PORT MAP (a, b, w1);
   gate2 : and2 PORT MAP (b, c, w2);     
   gate3 : and2 PORT MAP (a, c, w3);     
   gate4 : or3 PORT MAP (w1, w2, w3, m);     
END structure;
 
--Behavioural style architecture using a look-up table
ARCHITECTURE using_table OF maj IS
BEGIN
   PROCESS(a,b,c)
      CONSTANT lookuptable : BIT_VECTOR(0 TO 7) := "00010111";
      VARIABLE index : NATURAL;
   BEGIN
      index := 0; --index must be cleared each time process executes
      IF a = '1' THEN index := index + 1; END IF;
      IF b = '1' THEN index := index + 2; END IF;
      IF c = '1' THEN index := index + 4; END IF;
      m <= lookuptable(index);
   END PROCESS;
END using_table;

 

文章录入:admin    责任编辑:admin 
  • 上一篇文章: [VHDL实例]最高优先级编码器

  • 下一篇文章: [VHDL实例]8位总线收发器:74245(注2)
  • 发表评论】【告诉好友】【打印此文】【关闭窗口
       最新热点    最新推荐    相关文章
  • [VHDL实例]地址译码(for m68…

  • [VHDL实例]加法器描述

  • [VHDL实例]8位相等比较器

  • [VHDL实例]解复用器

  • [VHDL实例]三态总线(注2)

  • |VHDL实例|双向总线(注2)

  • [VHDL实例]多路选择器(使用c…

  • [VHDL实例]多路选择器(使用w…

  • [VHDL实例]多路选择器(使用i…

  • [VHDL实例]多路选择器(使用…

  • 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)  
    {$PopAnnouceWindow(400,440)}