码迷,mamicode.com
首页 > 其他好文 > 详细

01-布尔逻辑的习题

时间:2016-10-15 16:17:15      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

一,基础芯片的实现:使用Nand门,构建基本芯片
1,使用Nand门实现Not门

(1)原理:  Not(a) = Nand(a,a)

  (2) 描述:

    芯片名:Not
  输入:a
  输出:out
  功能:if a=0 out=1 else out=0

(3)实现:

  CHIP Not{
    IN in;
    OUT out;
    PARTS:
    Nand(a=in,b=in,out=out);
  }

2,使用Not门,Nand门实现And门

(1)原理: And(a,b) =Not (Nand(a,b))

  (2) 描述:

  芯片名:And
  输入:a,b
  输出:out
  功能:if a=b=1 out=1 else out=0

(3)实现:

  CHIP And{
    IN a,b;
    OUT out;
    PARTS:
    Nand(a=a,b=b,out=nandOut);
    Not(in=nandOut,out=out);
   }

3,使用Not门,And门,构建Or门

(1)原理:

  (i) x y   Or

         0 0     0

         0 1     1

     1 0     1

         1 1     1

      (ii) 只看0 描述为  x‘y‘ 再取反 (x‘y‘)‘    所以 x Or y = (x‘y‘)‘   或者只看1,为 x Or y = x‘y+xy‘+xy

      这里选用了第一种,所以 Or(x,y) = Not(And(Not(x),Not(y)))

  (2) 描述:

  芯片名:Or
  输入:a,b
  输出:out
  功能:if a=b=0 out=0 else out=1

(3)实现:

  CHIP Or{
    IN a,b;
    OUT out;
    PARTS:
    Not(a=a,out=nota);
    Not(b=b,out=notb);
    And(a=nota,b=notb,out=w1);
    Not(a=w1,out=out);
    }

4,使用Not门,And门,Or门构建Xor门
(1)原理:
  a b || Xor
  0 0 0
  0 1 1
  1 0 1
  1 1 0
只看Xor为1的那一项,a Xor b = a’b+ab’ 所以:Xor(a,b) = Or(And(Not(a),b),And(a,Not(b)))
(2)描述:
  芯片名:Xor
  输入:a,b
  输出:out
  功能:if a=b out=0 else out=1

(3)实现:
  CHIP Xor{
    IN a,b;
    OUT out;
    PARTS:
    Not(a=a,out=nota);
    Not(b=b,out=notb);
    And(a=nota,b=b,out=w1);
    And(a=a,b=notb,out=w2);
    Or(a=w1,b=w2,out=out);
  }

01-布尔逻辑的习题

标签:

原文地址:http://www.cnblogs.com/wisdom-share/p/5964431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!