Milestone 1 — Computer Architecture
Design of a Vending Machine
Hai Cao
rev 1.0.0
Contents
1 Objectives 1
2 Coding Guidelines 1
3 Problem 2
Abstract
The first milestone in the course involves designing a vending machine using SystemVer-
ilog. Students are expected to adhere to specific coding guidelines and submit reports. If
you come across any errors or have suggestions for improving this document, please email
the TA: [email protected] with the subject “[CA203 FEEDBACK]”
1 Objectives
• Understand coding guidelines.
• Review basic logic design and FSM concepts.
• Design a Vending Machine using SystemVerilog
2 Coding Guidelines
When you’re coding, it’s important to remember that you’ll be revisiting your code multiple
times for various purposes like debugging and enhancement. Keeping your code clean will
save you a significant amount of time. On the other hand, a messy code file can be visually
overwhelming and mentally disruptive, leaving you wondering what you’ve done.
In this course, it’s highly recommended to adhere to the coding guidelines provided in this
link.
1
Milestone 1 — Computer Architecture
3 Problem
Vending Machine is a dispenser machine that receives coins or bills and dispenses soft drinks
or snacks. A simple vending machine controller is described in Figure 1.
i_nickle
i_dime o_soda
Vending
i_quarter
Machine o_change
i_clk
Figure 1: Vending machine’s ports
Design a vending machine that meets the following specifications:
1. The vending machine is capable of accepting coins: ¢5 (Nickel), ¢10 (Dime), ¢25 (Quarter).
However, it should only accept one coin at a time (per clock cycle).
2. When the deposited amount exceeds ¢20, it should dispense a soda and calculate the
correct change.
3. The change is represented as a 3-bit data:
000 ¢0
001 ¢5
010 ¢10
011 ¢15
100 ¢20
In this example, the system accepts a dime and then a quarter as input from the customer.
In the subsequent cycle, the system dispenses a soda and provides a change of ¢15.
i_clk
i_nickle
i_dime
i_quarter
o_soda
o_change 011 100
Figure 2: Waveform of an example vending machine