Project #2: Donut Dilemma? IC220

advertisement
IC220 Project #2: Donut Dilemma?
This project is to be completed independently (see details on coversheet pledge).
This means collaboration between students is not permitted. See the instructor for help or clarification.
Background: A Mysterious Benefactor (M.B.) has heard that you are now an expert in designing important logic circuits,
and has requested your help to construct the important “Donut Bonus Machine”.
Your task: The M.B., apparently a donut manufacturer of some kind, has decided to launch a new “Customer
Appreciation Month.” During this promotion:
 The M.B. will install a display above the cash register, showing a number between 0 and 12. However, a
0 (zero) is only displayed (by the “machine” you will build) when the machine is first turned on (or reset).
 Every time a customer makes a purchase, an employee will press the “CLOCK” button, which will cause
a new number (call this “D”) to appear on the display (the new number will always be between 1 and 12).
 The lucky customer will then receive “D” donuts free!
 Every number (between 1 and 12) will appear on the display exactly once, in some fixed order, before the
whole sequence repeats.
 The benefactor owns many donut stores. Each store’s machine will use a different sequence of numbers.
 Each midshipman is to be assigned to one particular store. Your alpha will determine the specific
sequence that you must generate.
Details:
1) Let’s start with a simple two bit example, just to get a feel for how “finite state machines” work in
LogicWorks. Download and open this circuit:
http://www.usna.edu/Users/cs/lmcdowel/courses/ic220/logicworks/ExampleTwoBitSequence.cct
This is a simple 2-bit machine that counts through the sequence 0, 2, 1, 3, 0, 2, 1, 3, 0, ….. forever. Note a
few things about the example circuit:
 Each number is represented by two bits (Q1 and Q0), and these bits are each stored in a flip-flop.
 A few gates (2 AND, 1 OR, and 1 NOT) implement the combinational logic that computes the
next state function.
 A CLOCK binary switch is used to advance to the next state. A RESET binary switch is used to
reset all flip-flops back to zero. But RESET uses “negative logic” – so you must set this switch to
“1” to enable “normal operation” (setting to “0” forces a reset).
 In class we discussed how to build this example “two bit machine” via a truth table and then two
K-maps.
2) Now look at this example of an actual 4-bit “Donut Bonus Machine”:
http://www.usna.edu/Users/cs/lmcdowel/courses/ic220/logicworks/ExampleFourBitSequence.cct
Notes about this machine:
 This particular machine counts through the sequence: 1, 5, 11, 4, 3, 10, 12, 7, 8, 6, 9, 2, 1, ….
 It only returns to zero (0000), briefly, when the RESET switch is used.
 The numbers are stored via 4 bits (flip-flops), Q3 Q2 Q1 Q0. However, to make it easier to view the
sequence, these 4 bits are connected to a “Hex display”, which shows the 4-bit numbers as a single
hex digit.
 You should use this file as a template for your solution (details given below), but your solution will
produce a different sequence of numbers.
3) Use this link to your specific assigned sequence:
http://www.usna.edu/Users/cs/lmcdowel/courses/ic220/projGen/index.html
(be sure to print this page, for reference and to turn in with your final assignment)
4) Print out the results of that link (your sequence). You need this, and will need to turn it in.
5) Read the instructions for your sequence. Pay attention to how “zero” is handled.
6) Now that you know your sequence:
a. On a separate piece of paper, carefully make a “next state table” showing the next state
(Q3’Q2’Q1’Q0’) in terms of the current state (Q3Q2Q1Q0) (you do NOT need include “RESET” in
this – the flip-flops handle that via the separate “Reset” input). Neatness counts. You will turn
this in.
b. Neatly and carefully, minimize the logic needed for Q3’, Q2’, Q1, and Q0’, using one K-Map for each.
This will define the logic that you should hook up to each of the “D” inputs of the flip-flops.
i. Use a separate piece of paper, not scrap paper or the back of your project description!
ii. Neatness counts here. You will have to turn this work in.
iii. Be sure to clearly identify what variable each K-map is for.
iv. Think carefully about your sequence. Do you have any “don’t cares”? If so, you must
identify them and use them intelligently to help simplify things.
7) Make sure you have fully minimized your K-maps before you continue! However, if you do this correctly,
there is no need to try to look for further simplifications after using your K-map (the K-map will give you the
optimal “two level” circuit for your function)
8) IMPORTANT: use this template as the starting point for your design:
http://www.usna.edu/Users/cs/lmcdowel/courses/ic220/logicworks/TEMPLATE_FourBitSequence.cct
a. Keep the flip-flops, switches, probes, and hex display, all in the same place.
b. Add in the appropriate gates to implement your sequence, based on your K-maps.
c. Your overall wire connections should be reasonably tidy. Use the existing vertical wires (below each
of the 4 probes that are up top), and follow the example of the complete “4 bit example” that was
mentioned before.
9) Once everything is wired up, you will probably need to reset the flip-flops to get them in a valid state. Flip
the RESET signal to “0”, then back to “1”.
10) Carefully test your circuit by clicking up and down on the “CLOCK” switch. Does it count through all of the
required 12 states, then repeat? If you have trouble, see the “tips” section later.
11) OPTIONAL (but kind of fun): Once your circuit is working, delete the binary switch for the CLOCK variable
and replace it with an actual “Clock” component from the “Simulation Logic” library inside LogicWorks.
Also, at the bottom of the toolbar there are a set of controls used for managing the overall simulation speed
(including the clock) that look like this:
To see your circuit in action, click on the rightmost button on the picture above (between the slider control
and the number display at far right). Then move the slider to the right to control the speed of the clock –
make it slow at first to make sure things are working. If you can’t click on this button, try first clicking on a
binary switch a few times until the whole simulation starts “running.”
(NOTE: the button on the far left is for “single-stepping”. This can be a little confusing because it does NOT
advance time by one clock cycle – it advances time by some number of nanoseconds. This can be very
confusing because LogicWorks models the propagation delay of signals through gates – so after a step, some
gate outputs may not yet be stable. Thus, I don’t recommend using this button.)
Requirements:
1) All “inputs” to the system (here just RESET and CLOCK) must be labeled and have switches attached.
2) All outputs (here just the 4 state bits) must be labeled and have probes (with labels) attached.
3) The hex display (as in the example) must be present and wired correctly.
4) Place your name and date on the circuit
5) The circuit must work.
6) Your “next state” function must be a “two-level” circuit that uses only AND, OR, and NOT gates (bubbles on
the gate inputs are also fine). This “two-level” result is what you normally get after minimizing with a K-map.
(The “second” level is an OR gate. If, however, you need more than one OR gate in order to combine the
results of the AND gates, that is fine).
7) Keep your design simple and neat.
8) Use only simple gates and the other components mentioned here – do not use adders, registers, etc.
9) Name your file as follows: Project2-section-lastname.cct. Example:
Project2-2001-smith.cct
Grading details (see also specific list of deliverables later)
 If you submit, on-time, all deliverables correctly, your circuit works perfectly, everything (truth tables, Kmaps, and circuit) is tidy and complete, you assessed your circuit correctly (see below), and your circuit was
correctly minimized (including “don’t cares”), you will earn a grade of 100.
 If your final project does not “substantially work” – count through at least 9 of the 12 possible states – then
you will earn a maximum grade of 50 (actual grade will depend upon quality of your next state table and Kmap).
 A late submission that works is worth more credit than a timely submission that does not!
 If your project “substantially works”, but has any error in the sequence, you will earn a maximum grade of 85.
 Testing is essential – how do you know if it works? Therefore, 10 points is based on your correct self
assessment of your project. To earn this 10 points, you must either:
 Circle “All correct and complete” on the coversheet – and have a fully functioning solution
 OR, circle something else – and have a solution that is not fully functional.
 Zero points (out of 10) if nothing is circled about completion on the coversheet.
 -80 pts for a machine that works but is not the correct sequence for your alpha
 -15 points for missing output of http://www.usna.edu/Users/cs/lmcdowel/courses/ic220/projGen/index.html
 -25 points for hardcopy submission without electronic submission to Blackboard
 -20 points for missing “next state table”
 -25 points for missing K-map details
 -10 points if your K-map is about right, but your solution is not fully and correctly minimized
 -20 points for missing printout of your circuit
 -3 points for work that is not stapled together
 Up to -20 points for too many “CLOCK” or “RESET” signals (should be just one of each!)
 -10 pts for a truth table that is crammed onto the project description paper, or not tidy
 -10 pts for K-maps that are crammed onto the project description paper, or not tidy and clear
 -10 pts for a circuit that is not clearly “laid out” (how the wires connect up the gates)
Deliverables: (1 through 5 handed in, stapled together in the following order)
1) Cover sheet (for a project, not homework – see IC220 webpage) with your feedback and pledge
NOTE: You must circle one of the “All correct and complete”, “Mostly correct and complete”, etc. options.
(see grading details above)
2) Output of http://www.usna.edu/Users/cs/lmcdowel/courses/ic220/projGen/index.html for your alpha.
3) Next state table showing states (present and next)
4) Reduction/K-map details, per flip-flop
5) Print-out of your functioning circuit (printing trouble from LogicWorks? Take a screenshot and print that. Or “Edit->
Select all” from LogicWorks and paste into Microsoft Word, then print.)
6) Logic Works file for your circuit (submit via Blackboard)
7) Extra credit functionality (see below)
(turn this is in as a separate file, and print out your circuit)
Extra Credit:
(3 pts) Submit your final, fully-working project early (see calendar for deadline). Electronic AND hardcopy be must
submitted before the early deadline in order to receive this credit.
(Up to 6 pts) You might think that customers would not complain about free donuts, right? Well, sometimes a few unruly
customers may get their donuts (paid + free), then (after the CLOCK button is pushed to display the number for the next
customer), claim that they didn’t get enough free donuts (i.e., that the number was 9, even though it was really 6). To
verify what the number actually was, make a copy of your machine, then implement a version that can go forwards OR
backwards through the sequence. Add a new binary switch called BACKWARDS to your machine. When this signal is 1,
your machine should cycle backwards through the sequence. If BACKWARDS is 0, it should follow the normal
sequence. To do all this, you’ll have to start all over with a more complex “next state table” – now the “next state”
depends on the 4 current state bits AND on the values of the BACKWARDS signal.
Getting this to work, correctly, is worth up to 4 pts. To get the full 6 points, however, you’ll need to figure out
how to correctly simplify a K-map that was 5 inputs (we’ve only done up to 4!). You can talk to your instructor for ideas
on this. Make sure your final K-maps are clear!
Submit this new version AND the original version when you submit your project on Blackboard. Print both.
(continued on next page)
Tips
1) START EARLY! You have to work on your own and there is always the danger of running into some LogicWorks
problem you don’t understand. So be sure to allow enough time to contact/visit the instructor if you have difficulty.
 Then finish early and get some easy extra credit!
2) Look at the example of the “2 bit machine”, and refer to notes from class on how to create this with K-maps.
3) Make sure you know the proper way to produce a K-map with 4 inputs. See class/HW examples.
4) Be careful when doing the next state table and during minimization, then check your work before starting to build the
actual circuit.
5) Remember, the “Reset” signal going into the flip-flops must be “1” to allow normal operation. To reset back to the
initial state, flip the binary switch connected to Reset to “0” (to reset) then back to “1” (to allow normal operation).
6) When you first start, or after removing/adding gates or switches, some probes may show a "Z" or "X" value. To fix
this, use the flip-flop reset option as described above.
7) If you use Reset, but still have X, Z, or C values, then somewhere you have a wiring problem:
a. "X" means that the value is unknown (usually because the value is the output of a gate, but some inputs to the gate
are not connected or are themselves unknown)
b. "Z" means that the signal is not connected to anything that is trying to force it to a zero or one (e.g. the wire is not
connected to anything meaningful)
c. "C" means "conflict" -- for instance, if you connect the outputs of two different gates together (which of course
you should not do), you get a conflict if the output of the first is zero and the output of the second is one.
8) If you are stuck with a X, Z, or C problem, how can you figure out where this is coming from? Well, these values
don't just appear out of nowhere -- if the value stored in your flip flop is X or Z, look at the D input going into it (do
this by adding another probe). Most likely it is also a X or Z. Keep adding probes to work backwards and figure out
which gate is first producing a X or Z value. You should eventually find a gate that has X or Z as output, but the
inputs have valid values (e.g. 0 or 1, which you can see with more probes). If you find this kind of gate, then you
know that you probably have a wiring problem with that gate (like one of the wires is not really connected, or one of
the inputs to the gate has nothing connected).
9) LogicWorks can be a little fussy about whether a connection is actually made. To see everything a wire is connected
to, use the arrow pointer and click on the wire, then look carefully at the endpoints to see if they all look the same – a
“T” at the end of the wire may indicate a bad connection. As another example, look at this screenshot:
In this circuit (from an actual problem I had), the clock signal going into the top flip-flop is not connected properly –
notice the “T”-like marking at the end (in some cases, this may only be visible once you click on the wire). If you can’t
see this in the printed version of this handout, look at the color version online.
Example Two-Bit State Machine:
This circuits counts from 0 (00) to 2 (10) to 1 (01) to 3 (11), then back to 0 and repeats.
Q1'
Q1
Q0
1
1
Q1
D Q
0
Q1'
CR
0
Q0'
Q0
Q0'
D Q
CR
CLOCK
1
0
1
0
RESET
Example Donut Bonus Machine:
(counts through the sequence: 1, 5, 11, 4, 3, 10, 12, 7, 8, 6, 9, 2, 1, ….)
5
CLOCK
1
0
Q3
Q2
Q1
Q0
0
1
0
1
Q3'
1
Q3
D Q
CR
Q2
Q2'
D Q
0
CR
Q1
D Q
C R
Q1'
Q0
1
D Q
CR
Q0'
1
1
0
RESET
Download