Difference between revisions of "CSC270 Homework 4 Solution 2011"

From dftwiki3
Jump to: navigation, search
(Created page with "--~~~~ ---- <onlydft> =Extra Credit= <code><pre> # solution for Homework #4 ...")
 
 
(5 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
 
<onlydft>
 
<onlydft>
 +
 +
=Problem #1=
 +
==Logic Diagrams==
 +
Here are some pictures from Tiffany's answers.
 +
<br />
 +
<br />
 +
[[Image:CSC270Hw4Prob1a.png]]
 +
<br />
 +
<br />
 +
[[Image:CSC270Hw4Prob1b.png]]
 +
<br />
 +
<br />
 +
One picture from Elizabeth's answer.  the "d=0" signal is connected to the most significant input congtrol bit.
 +
<br />
 +
<br />
 +
[[Image:CSC270Hw4Prob1c.png]]
 +
<br />
 +
<br />
 +
For the last diagram, the design is correct, but could have been simplified by setting the d input to 0 and leaving I8 to I15 unconnected (we use the symbol NC in diagrams to indicate the fact that an input or output is "not connected" to anything.
 +
 +
==Code==
 +
<code><pre>
 +
# solution program for hw4                                                                                                                                     
 +
# D. Thiebaut                                                                                                                                                 
 +
#                                                                                                                                                             
 +
def mux4To1( I0, I1, I2, I3, C0, C1 ):
 +
    inputs = ( I0, I1, I2, I3 )
 +
    return inputs[ C0 + 2*C1 ]
 +
 +
def decode3To8( I2, I1, I0 ):
 +
    outputs = [0, 0, 0, 0, 0, 0, 0, 0]
 +
    outputs[ I0 + I1*2 + I2*4 ] = 1
 +
    return outputs
 +
 +
def main():
 +
    #--- verification of the majority voter ---                                                                                                               
 +
    print "Majority voter verification"
 +
    print "a b c | f "
 +
    print "------+---"
 +
    for a in [0,1]:
 +
        for b in [0,1]:
 +
            for c in [0,1]:
 +
                f = mux4To1( 0, c, c, 1, a, b )
 +
                print "%d %d %d | %d" % ( a, b, c, f )
 +
 +
    #--- verification of decoder ---                                                                                                                           
 +
    print "\n\nDecoder verification"
 +
    print "a b c | I7 I6 I5 I4 I3 I2 I1 I0"
 +
    print "------+------------------------"
 +
    for a in [0,1]:
 +
        for b in [0,1]:
 +
            for c in [0,1]:
 +
                I7, I6, I5, I4, I3, I2, I1, I0 = decode3To8( a, b, c )
 +
                print "%d %d %d | %2d %2d %2d %2d %2d %2d %2d %2d" \
 +
                    % (a, b, c,  I7, I6, I5, I4, I3, I2, I1, I0 )
 +
 +
 +
main()
 +
 +
 +
</pre></code>
 +
==Output==
 +
<code><pre>
 +
Majority voter verification
 +
a b c | f
 +
------+---
 +
0 0 0 | 0
 +
0 0 1 | 0
 +
0 1 0 | 0
 +
0 1 1 | 1
 +
1 0 0 | 0
 +
1 0 1 | 1
 +
1 1 0 | 1
 +
1 1 1 | 1
 +
 +
 +
Decoder verification
 +
a b c | I7 I6 I5 I4 I3 I2 I1 I0
 +
------+------------------------
 +
0 0 0 |  1  0  0  0  0  0  0  0
 +
0 0 1 |  0  1  0  0  0  0  0  0
 +
0 1 0 |  0  0  1  0  0  0  0  0
 +
0 1 1 |  0  0  0  1  0  0  0  0
 +
1 0 0 |  0  0  0  0  1  0  0  0
 +
1 0 1 |  0  0  0  0  0  1  0  0
 +
1 1 0 |  0  0  0  0  0  0  1  0
 +
1 1 1 |  0  0  0  0  0  0  0  1
 +
 +
</pre></code>
  
 
=Extra Credit=
 
=Extra Credit=
Line 57: Line 146:
  
 
</pre></code>
 
</pre></code>
 +
 +
=RS Flip-Flops with NAND/NOR and XOR/XOR=
 +
 +
* We cannot store both 1 or 0 in the NAND/NOR.
 +
* Similarly, we cannot store 1 or 0 in the XOR/XOR. 
 +
* Some of you used the kits to verify this.  VERY GOOD IDEA!
  
 
</onlydft>
 
</onlydft>

Latest revision as of 12:16, 1 March 2011

--D. Thiebaut 10:44, 1 March 2011 (EST)



...