Question
Please save this file as vending.sv https://www.edaplayground.com/x/2at_ `default_nettype none module tb_vend; wire dispense; wire [2:0] change; reg quarter, loonie, toonie, clk; VendingMachineController dut(quarter, loonie, toonie,
Please save this file as vending.sv https://www.edaplayground.com/x/2at_
`default_nettype none
module tb_vend; wire dispense; wire [2:0] change; reg quarter, loonie, toonie, clk; VendingMachineController dut(quarter, loonie, toonie, clk, dispense, change); initial begin $dumpfile("dump.vcd"); $dumpvars(0, dut);
$display(" -- Testing only quarters -- "); quarter
$display(" -- Testing only Loonies -- "); loonie
$display(" -- Testing only Toonies -- "); toonie
$display(" -- Testing Loonies + Quarters -- "); quarter
$display(" -- Testing Toonies + Quarters -- "); quarter
task pulseClock; begin #1 clk
task assertEquals; input val; input eq; begin if ( val == eq ) $display("[TEST][PASSED] Dispensed: %b", val); else $display("[TEST][FAILED] Dispensed: %b, expected %b", val, eq); end endtask
task assertEquals3Bit; input [2:0] val; input [2:0] eq; begin if ( val == eq ) $display("[TEST][PASSED] Change: %d", val); else $display("[TEST][FAILED] Change: %d, expected %d", val, eq); end endtask endmodule
// Code your design here
`default_nettype none
module VendingMachineController(
input quarter, input loonie, input toonie, input clk, output dispense, output [2:0] change );
endmodule
Part 2: The vending machine controller. Using previous knowledge of sequential circuits, you will now construct a vending machine controller according to the following specification. The circuit has four inputs: clk, quarter, loonie, and toonie. The controller also has two outputs: change and dispense. Change is a 3-bit bus which outputs a binary number indicating the number of quarters to dispense. Dispense is a single on/off wire. clk dispense quarter change Vending machine loonie Controller toonie Every time a coin is inserted, there is a clock pulse to go along with it. Every time the coin is inserted, the controller must decide how much (if any) change to dispense, and whether or not to dispense the item. You must implement the controller based on the following properties: 1. 2. 3. The item (and change, if any) is dispensed when $1 is inserted into the machine. The change output outputs a binary number indicating the number of quarters to dispense. The dispense and change signals are set to 1 on the same clock tick that the amount is met. In the lecture, you designed sequential circuits using 6 steps from specification to minimizing the circuit. In Verilog however, you need to mainly focus on the specification and the state transition diagram. The rest of the circuit design is done with high-level Verilog statements. The skeleton code for the vending machine is provided here: Please save this file as vending.sv https://www.edaplayground.com//2at Part 2: The vending machine controller. Using previous knowledge of sequential circuits, you will now construct a vending machine controller according to the following specification. The circuit has four inputs: clk, quarter, loonie, and toonie. The controller also has two outputs: change and dispense. Change is a 3-bit bus which outputs a binary number indicating the number of quarters to dispense. Dispense is a single on/off wire. clk dispense quarter change Vending machine loonie Controller toonie Every time a coin is inserted, there is a clock pulse to go along with it. Every time the coin is inserted, the controller must decide how much (if any) change to dispense, and whether or not to dispense the item. You must implement the controller based on the following properties: 1. 2. 3. The item (and change, if any) is dispensed when $1 is inserted into the machine. The change output outputs a binary number indicating the number of quarters to dispense. The dispense and change signals are set to 1 on the same clock tick that the amount is met. In the lecture, you designed sequential circuits using 6 steps from specification to minimizing the circuit. In Verilog however, you need to mainly focus on the specification and the state transition diagram. The rest of the circuit design is done with high-level Verilog statements. The skeleton code for the vending machine is provided here: Please save this file as vending.sv https://www.edaplayground.com//2atStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started