Question
Vending Machine Using previous knowledge of sequential circuits, you will now construct a vending machine controller according to the following specifications. The circuit has four
Vending Machine
Using previous knowledge of sequential circuits, you will now construct a vending machine controller according to the following specifications. 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. You must implement the controller based on the following properties. The skeleton code is available here at https://www.edaplayground.com/x/2at. Name your file as task2.sv
1. The item (and change, if any) is dispensed when $1 is inserted into the machine.
2. Change outputs a binary number indicating the number of quarters to dispense.
3. The dispense and change signals are set to 1 on the same clock tick that the amount is met.
Note: 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.
// Code your testbench here module rand_test;
interface port_if(input clk); logic sop, eop; logic [31:0] data; logic rstN; clocking mon_cb @(posedge clk); input sop, eop, data; endclocking clocking drv_cb @(posedge clk); output sop, eop, data; endclocking modport MON (clocking mon_cb, input rstN); modport DRV (clocking drv_cb, output rstN); endinterface typedef byte[3:0] flit_t; typedef enum {MIN,SMALL,MED,LARGE,MAX} p_sz_t; class Packet; rand flit_t DA; rand flit_t SA; rand p_sz_t size; rand int length; rand byte DATA[length]; flit_t CRC; constraint length_c { size dist { MIN :/ 1, SMALL :/ 5, MED :/ 8, LARGE :/ 5, MAX :/ 1 }; length >= 52 && length (length == 52); (size == MAX) -> (length == 1056); (size == SMALL) -> (length >= 52 && length (length >= 116 && length (length >= 928 && length
initial begin : test_body Packet packet = new(); int count = 0; repeat(20) begin : rand_gen if(packet.randomize() == 0) begin $display("Failed to randomize packet! Count %0d",count); $finish; end $display("Count: %0d, Packet %s", count++, packet.toString()); end : rand_gen end : test_body
endmodule
// Code your design here
clk dispense quarter Vending Machine Controller loonie 3-wire bus toonie change Figure 1: Vending Machine clk dispense quarter Vending Machine Controller loonie 3-wire bus toonie change Figure 1: Vending MachineStep 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