How can we describe the vending machine FSM in this lecture will guide you through the implementation
of the vending machine, FSM explained in the previous lecture.
So our goal is implementing this.
Let's create a new White House project with the name of vending underscore machine dashboard to choose
a top function name and select the basis tree as a target FPGA board.
Creative design header file with the name of vending underscore machine that age and the design source
file with the name of vending underscore machine that CPB make sure that the creative files are located
inside the project folder.
Accordingly, create the test, potentiator and Sourcefire.
Open the design header file and include the AP underscore into that, why not open the design source
file, then include the design header file and define the enumeration data type to define the states.
Let's define the top function with seven arguments for inputs and outputs.
It is better to add port interfaces right now, then define a static variable as a design the state.
And find the corresponding temporarily valuable.
It is a good practice to define temporary variables for the outdoor arguments.
Now we should define the state machine using a switch case statement.
Then we should update the state register and out.
Initially, the circuit is in the city zero state ready for accepting a purchase.
Based on the input, the state machine goes to five star 10, oreste 25.
Similar behavior happens in Stiffy five to 10 to 15 and 20 states.
In the 25 states, the circuit doesn't need any inputs, it gives you a candy and those to the sweet
state.
Similar things happen in states estie 30, AC 35 to 40 and 44.
And that's why it stayed the vending machine is waiting for you to pick up your candy and change, then
it goes to zero, ready for the next request.
This code implements the whole state machine, except the system requires transition as a system.
Reset is added to the design by the tool automatically.
We should guide the tool to set up the research signal properly.
For this purpose.
Right, click on the solution one folder and select the solution settings option, then expand the config
archil, go to the reset section and select the all option under the reset feature.
This applies the reset to all registers in the design, including the state register.
Therefore, resetting the system.
Reset the state machine.
Now, we should try to test bench codes.
Open the test bench, identify and include the design header file and define the design top function
prototype, open the test by Sourcefire, defined the main function and the status variable.
Let's define a couple of variables corresponding to the top function arguments.
It is a good idea to define a function that describes putting a coin in the machine.
This function receives three arguments corresponding to the three coin types.
Note that only one of these arguments can be one at a time.
As we can only insert one coin at a time into the windish first, the function calls are designed to
function with the arguments in which one of them has the value of one.
Then it prints the variables on the screen for an inspection, it then calls the design function assigning
zero to all arguments just to add some delay between to coin insert operations.
Now, let's call this a function for inserting two dimes and the quarter into the winnings.
Now we are ready for performing the simulation.
As can be seen in the test bench output, after accepting the cones, the machine gives you a candy
and two dime coins.
Let's start from the high level synthesis analysis perspective confirms the article, Single Cycle Design
Implementation.
After performing the article Psycho Simulation, we can inspect the waveforms to understand the circuit
behavior and perform cycle accurate debugging.
Finally, we should export Aadil IP ready for integration in every other project.
Now that we have the Arthel IP for the vending machine, we should instantiate that in every Ghandour
project and generate that FPGA bitstream.
The next lecture will cope with this task.
This is our takeaway message in the solution setting window, it can determine the design registers
that should receive the system.
Now, the police question, right, a test meant to insert three nickels and one called.