全加器门

时间:2014-01-02 21:52:48

标签: logic

我不知道这个问题是否被认为与stackoverflow有关(我很抱歉,如果不是,但我已经搜索过,并且没有在任何地方找到答案)。

我编写了一个完整的加法器

输出:

Truth Table : 

a1  a2   b1   b2   S1   S2   C
______________________________
0   0    0    0    0    0    0
0   0    0    1    0    1    0
0   0    1    0    1    0    0
0   0    1    1    1    1    0
0   1    0    0    0    1    0
0   1    0    1    0    0    1
0   1    1    0    1    1    0
0   1    1    1    1    0    1
1   0    0    0    1    0    0
1   0    0    1    1    1    0
1   0    1    0    0    1    0
1   0    1    1    0    0    1
1   1    0    0    1    1    0
1   1    0    1    1    0    1
1   1    1    0    0    0    1
1   1    1    1    0    1    1

如果有人计算过这个,他们可以告诉我输出是否正确

2 个答案:

答案 0 :(得分:2)

a1  a2   b1   b2   S1   S2   C   a  b  s  c
______________________________
0   0    0    0    0    0    0   0  0  0  0 nothing plus nothing is nothing
0   0    0    1    0    1    0   0  2  2  0 nothing plus two is two
0   0    1    0    1    0    0   0  1  1  0 nothing plus one is one
0   0    1    1    1    1    0   0  3  3  0 nothing plus three is three
0   1    0    0    0    1    0   2  0  2  0 two plus nothing is two
0   1    0    1    0    0    1   2  2  0  1 two plus two is four (four not in 0-3)
0   1    1    0    1    1    0   2  1  3  0 two plus 1 is three
0   1    1    1    1    0    1   2  3  1  1 two plus three is five (one and four)  
1   0    0    0    1    0    0   1  0  1  0 one plus nothing is one
1   0    0    1    1    1    0   1  2  3  0 one plus two is three
1   0    1    0    0    1    0   1  1  2  0 one plus one is two
1   0    1    1    0    0    1   1  3  0  1 one plus three is four
1   1    0    0    1    1    0   3  0  3  0 three plus nothing is three
1   1    0    1    1    0    1   3  2  1  1 three plus two is five (one and four)
1   1    1    0    0    0    1   3  1  0  1 three plus one is four
1   1    1    1    0    1    1   3  3  2  1 three plus three is 6 (two and four)

看起来正确。以略微不同的方式排序您的16行将使它们以更合理的顺序流动。

答案 1 :(得分:0)

这是一个加法器!只需检查它是否正在添加。我们来看看这一行:

 a2 a1     b2 b1     C S2 S2 
  1  0      1  1     1  0  1 

在这里,我以更容易阅读的方式重新排序列:首先是高阶位。

a输入为10 = 2(基数为10)。 b输入为11 = 3(基数为10)。输出为101,其中 是5(基数10)。所以这个是正确的:2 + 3 == 5.

我会让你检查其他行。