01-布尔逻辑的习题

一,基础芯片的实现:使用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);
  }

5,使用以上门,构建Mux门(选择器)
(1)原理:
  sel || out
  0      a
  1      b
f(a,b,s) = abs’+ab’s’+abs+a’bs = (b+b’)as’+ (a+a’)bs = as’+bs
(2)描述:
  芯片名:Mux
  输入:a,b,sel
  输出:out
  功能:if sel=0 out=a else out=b
(3)实现:
  CHIP Mux{
    IN a,b,sel;
    OUT out;
    PARTS:
    Not(a=sel,out=notSel);
    And(a=a,b=notSel,out=and1);
    And(a=b,b=sel,out=and2);
    Or(a=and1,b=and2,out=out);
  }

6.实现DMux(分发器)
(1)原理:
  sel || a b
  0 in 0
  1 0 in
  所以:a=in*s’ b=in*s
(2)描述:
  芯片名:DMux
  输入:in,sel
  输出:a,b
  功能:if sel=0 a=in b=0 else a=0 b=in
(3)实现:
  CHIP DMux{
    IN in,sel;
    OUT a, b;
    PARTS:
    Not(in=sel,out=notSel);
    And(a=in,b=notSel,out=a);
    And(a=in,b=sel,out=b)
  }

二,使用基本逻辑门,构建多位逻辑门

1,实现多位Not

(1)原理:a

(2)描述:
  芯片名:
Not16
  输入:
in[16]  //16位管脚
  输出:
out[16]
   功能:
For i=0..15 out[i] = Not(in[i])
(3)实现:

  CHIP Not16{

    IN in[16];

    OUT out[16];

    PARTS: 

    Not(in=in[0],out=out[0]);

    Not(in=in[1],out=out[1]);

    .....                                       //重复以上步骤,但是真正实验的时候不能这么写

    Not(in=in[15],out=out[15]);

}

2,实现多位And

(1)原理:a

(2)描述:
  芯片名:
And16
  输入:
a[16],b[16]
  输出:
out[16]
   功能:
For i=0..15  out[i]=And(a[i],b[i])
(3)实现:

  CHIP And16{

    IN in[16];

    OUT out[16];

    PARTS:

    And(a=a[0],b=b[0],out=out[0]);

    And(a=a[1],b=b[1],out=out[1]);

    ...

    And(a=a[15],b=b[15],out=out[15]);

}

3,多位Or

(2)描述:
  芯片名:
Or16
  输入:
a[16],b[16]
  输出:
out[16]
   功能:
For i=0..15  out[i] = Or(a[i],b[i]);

4,多位Mux

(2)描述:
  芯片名:
Mux16
  输入:
a[16],b[16],sel
  输出:
out[16]
   功能:
if sel=0 For i=0..15 out[i]=a[i]

              else For i=0..15 out[i]=b[i]

 

posted on 2016-10-15 14:54  桃枝妖妖  阅读(1013)  评论(0编辑  收藏  举报

导航