基于vhdl的三人表决器(三种不同的描述方式)源码

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;
 

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GJZGRB

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值