Difference between revisions of "CSC270 Homework 5 Solution 2012"

From dftwiki3
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
--[[User:Thiebaut|D. Thiebaut]] 18:24, 12 March 2012 (EDT)
 
--[[User:Thiebaut|D. Thiebaut]] 18:24, 12 March 2012 (EDT)
 
----
 
----
<onlysmith>
+
<onlydft>
 
=PDF=
 
=PDF=
 
[[Media:CSC270Homework5Solutions2012.pdf|Pdf]]
 
[[Media:CSC270Homework5Solutions2012.pdf|Pdf]]
  
 
=Source=
 
=Source=
 +
 +
For problem #2, since we associated Red ON with the state where Q0, Q1, and Q2 are 0, then all we need to do is clear D2, D1, and D0 when the command is 1.  So we AND the functions of Problem 1 that generate D2, D1, and D0 with NOT( cmd ).  No analysis necessary!
  
 
<source lang="python">
 
<source lang="python">
Line 31: Line 33:
 
     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, Y, R...
+
         # 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 circuit signals
+
         # 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 49:
 
         #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 62:
  
 
     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, Y, R...
+
         # 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 circuit signals
+
         # 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 78:
 
         #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 138: Line 144:
 
"""</sourcr>
 
"""</sourcr>
  
</onlysmith>
+
</onlydft>
  
 
<br />
 
<br />

Latest revision as of 11:10, 22 January 2016

--D. Thiebaut 18:24, 12 March 2012 (EDT)



...