Logisim
• Use the version from the class Google Drive of Logisim Evolution. Other versions may not work correctly.
• Do not rename the files you receive. If you do so you will automatically fail the tester when you submit.
• Put your solution for each problem into implementation subcircuit
• Do not rename the implementation subcircuit anything else. If you do so you will automatically fail the tester when you submit.
• Do not change the appearance of the implementation subcircuit from what it is set as. Doing so will cause you to automatically fail the tester when you submit.
• That is this field right here
• Do not move the pins inside of the implementation subcircuit as that affects the appearance of the circuit on the outside as you saw in discussion. Doing so will cause you to automatically fail the tester when you submit.
• If you want to “move the pins” instead connect tunnels to the pins and move the tunnels around.
• Do not name any of the subcirucits in your solution main. Doing so will cause you to automatically fail the tester when you submit.
• You can create as many other subcircuits as you want in your solution. Just make sure your solution ends up in the implementation subcircuit
Restrictions
For all problems in this homework, you may only use
• All of the components under Wiring
• AND, OR, NOT, and XOR gates
• All of the components under Plexers
• All of the components under Arithmetic
• All of the components under Memory EXCEPT for Counter, RAM, ROM, and Random Generator
Unless a problem specifies otherwise.
Problem:
Implement a Mealy model circuit to control a coin-operated vending machine. This machine only accepts quarters, dimes, and nickels. Coins are inserted until a total of 30 cents or more is deposited. Only 1 coin is deposited at a time. Once a total of 30 or more cents has been deposited your circuit should set Give_Mechandise to 1 to dispense the product in the vending machine. You should also set the change outputs for the circuit to give back the appropriate amount of change. Assume that the machine can give one dime and/or nickel back. If the customer does something silly like entering a quarter followed by a quarter (total of 50 cents), correct change does not have to be provided (20 cents) but the maximum amount of change should be given (15 cents). Note that only 1 input can be high at a time.
Inputs
Pin
Size (in bits)
Explanation
EnableIn
1
Connect to the enable port of your registers/flip-flops. When 1 your circuit works normally. When 0 your circuit does nothing.
QuarterReceived
1
1 if the user entered a quarter into the machine and 0 otherwise
DimeReceived
1
1 if the user entered a dime into the machine and 0 otherwise
NickelReceived
1
1 if the user entered a nickel into the machine and 0 otherwise
ClkIn
1
Connect this to the clock ports of your registers/flip-flops. Do nothing else with this
Outputs
Pin
Size (in bits)
Explanation
Give_Merchandise_Out
1
1 if the user has entered 30 cents and 0 otherwise
Give_Dime_Out
1
1 if a dime should be given back as change and 0 otherwise
Give_Nickel_out
1
1 if a nickel should be given back as change and 0 otherwise
Credit
Credit for this problem goes to Sean Davis.
Testing
Testing for this problem is much different than for previous assignments because we are building sequential circuits. After you finish building your circuit and are ready to test it
• Open the associated grader circuit
• Scroll down on the left and side until you find your circuit. Right-click on it and select Reload Library
•
• Optionally turn StopOnMismatchIn on to have the testing stop on the first incorrect output
• If testing stops because of this you’ll need to reset the simulation after you make your fixes otherwise you’ll be stuck here forever.
• Start the simulation by going to Simulate and Ticks Enabled (ctrl + k)
• To increase the simulation speed go to Tick Frequency and select your desired frequency
• You can manually do one tick at a time by selecting Tick Half Cycle (ctrl + t). This is useful when you are debugging
• You can reset the simulation by selecting Reset Simulator (ctrl + r)
• The counter at the bottom will tell you how many you got right and listed next to it is the total number of points for the problem
Debugging
Here is my recommendation for how to debug
• Turn on StopOnMismatchIn
• Start the simulation
• Note down the test number that your circuit fails on
• Reset the simulation
• Start ticking until you get to the test number two or three before the one you failed
• Use the poke tool to go inside of your circuit
• Check if everything is as you expect it to be. Check absolutely everything including state, next state, and output.
• Tick to the next state.
• Repeat 7 and 8 until you find your error
• If go too far go back to step 4
Debugging sequential circuits is much harder than combinational circuits as the output depends on both the current inputs and the current state. This means that you may be failing test case X not because it is doing something wrong on that test case but because you transitioned to the wrong state N test cases ago. So if you are failing test case X you may need to check all of the test cases before X to validate you are switching to the correct state prior to test case X
Making Fixes to Your Solution
After you make changes to your solution you will need to reload your circuit in the grader circuit. If you don’t it won’t see the updates. To reload your circuit, select your circuit in the grader, right-click it and select Reload Library.