Difference between revisions of "CSC270 Homework 5 Solution 2012"
Line 31: | Line 31: | ||
for step in range( 20 ): | for step in range( 20 ): | ||
− | # the Q1 and Q2 outputs go through combinational logic to generate the new values | + | # the Q0, Q1 and Q2 outputs go through combinational logic to generate the new values |
− | # of D1, D2, and the outputs G | + | # of D1, D2, and the outputs G, R... |
D2 = NOT( Q2 ) & Q1 & NOT( Q0 ) | D2 = NOT( Q2 ) & Q1 & NOT( Q0 ) | ||
D1 = ( Q0 & Q1 ) | ( Q2 ^ Q1 ) ^ Q0 | D1 = ( Q0 & Q1 ) | ( Q2 ^ Q1 ) ^ Q0 | ||
D0 = NOT( Q2 ) & NOT( Q1 ) | ( Q2 & Q0 ) | D0 = NOT( Q2 ) & NOT( Q1 ) | ( Q2 & Q0 ) | ||
+ | |||
+ | # the outputs. Green is the opposite of Red. | ||
R = NOT( Q1 ) & NOT( Q0 ) | R = NOT( Q1 ) & NOT( Q0 ) | ||
G = NOT( R ) | G = NOT( R ) | ||
− | # show the stable | + | # show the stable signals |
print( "Q2Q1Q0 = %d %d %d | GR = %d %d" % ( Q2, Q1, Q0, G, R ) ) | print( "Q2Q1Q0 = %d %d %d | GR = %d %d" % ( Q2, Q1, Q0, G, R ) ) | ||
Line 45: | Line 47: | ||
#input( "> " ) | #input( "> " ) | ||
− | # as soon as the clock has ticked, D1 and D2 get latched in the flipflops | + | # as soon as the clock has ticked, D0, D1 and D2 get latched in the flipflops |
− | # and Q1 and Q2 reflect the values captured. | + | # and Q0, Q1 and Q2 reflect the values captured. |
Q0 = D0 | Q0 = D0 | ||
Q1 = D1 | Q1 = D1 | ||
Line 58: | Line 60: | ||
for cmd in [0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,1,1,0]: | for cmd in [0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,1,1,0]: | ||
− | # the Q1 and Q2 outputs go through combinational logic to generate the new values | + | # the Q0, Q1 and Q2 outputs go through combinational logic to generate the new values |
− | # of D1, D2, and the outputs G | + | # of D1, D2, and the outputs G, R... |
D2 = NOT(cmd) & ( NOT( Q2 ) & Q1 & NOT( Q0 ) ) | D2 = NOT(cmd) & ( NOT( Q2 ) & Q1 & NOT( Q0 ) ) | ||
D1 = NOT(cmd) & (( Q0 & Q1 ) | ( Q2 ^ Q1 ) ^ Q0 ) | D1 = NOT(cmd) & (( Q0 & Q1 ) | ( Q2 ^ Q1 ) ^ Q0 ) | ||
D0 = NOT(cmd) & (NOT( Q2 ) & NOT( Q1 ) | ( Q2 & Q0 )) | D0 = NOT(cmd) & (NOT( Q2 ) & NOT( Q1 ) | ( Q2 & Q0 )) | ||
+ | |||
+ | # outputs. | ||
R = NOT( Q1 ) & NOT( Q0 ) | R = NOT( Q1 ) & NOT( Q0 ) | ||
G = NOT( R ) | G = NOT( R ) | ||
− | # show the stable | + | # show the stable signals |
print( "cmd Q2Q1Q0 = %d %d %d %d | GR = %d %d" % ( cmd, Q2, Q1, Q0, G, R ) ) | print( "cmd Q2Q1Q0 = %d %d %d %d | GR = %d %d" % ( cmd, Q2, Q1, Q0, G, R ) ) | ||
Line 72: | Line 76: | ||
#input( "> " ) | #input( "> " ) | ||
− | # as soon as the clock has ticked, D1 and D2 get latched in the flipflops | + | # as soon as the clock has ticked, D0, D1 and D2 get latched in the flipflops |
− | # and Q1 and Q2 reflect the values captured. | + | # and Q0, Q1 and Q2 reflect the values captured. |
Q0 = D0 | Q0 = D0 | ||
Q1 = D1 | Q1 = D1 |
Revision as of 07:32, 13 March 2012
--D. Thiebaut 18:24, 12 March 2012 (EDT)