CSE460_LabAssignment2_Summer24
CSE460_LabAssignment2_Summer24
1. 1. A finite state machine that has to generate z = 1 when the previous four values of input
w were 1001 or 1111; otherwise, z = 0. Overlapping input patters are allowed. The
machine also has a negative reset. An example of the desired behavior is
2. You have to design a vending machine in Quartus for two products (n=2) each cost 15 Tk.
User’s money, returned money by the machine, and product bought condition are
represented as cash_in (2-bit input), return (output), and buy (1-bit output), respectively.
The vending machine can only accept three inputs: Tk 0 (cash_in = 00), Tk 20 (cash_in =
01), and Tk 50 (cash_in = 10). Once an acceptable input is more than or equal to 2*15 Tk,
the machine generates an output (buy=1), returns to the initial state, and returns the change
(if required).
a) Draw the state diagram, assigned table, and state-assigned table 3
c) Run the simulation, and verify your answer with the proper timing diagram. 4
3. Design a finite state machine that detects whether the input binary string is alternating
(i.e., 010101... or 101010...). The machine should output 1 if the input bits alternate, and
0 otherwise. The machine also has a positive Asynchronous Reset.
Example:
(a) Design the state diagram. Mark your reset states and transitions clearly. Is this 3
machine Mealy type or Moore type?
(b) Derive the assigned table and write the Verilog code to implement the 4
following FSM.
(c) Validate your answer with the appropriate input and output waveforms on a 3
timing diagram. Include all possible combinations of the input (w).
4. Design a Mealy machine that simulates detecting fraudulent transactions in a stream of credit
card transactions based on input categories:
• A: Low-value transaction.
• B: Medium-value transaction.
• C: High-value transaction.
The machine outputs 1 (fraud detected) if two consecutive high-value transactions (C) are
followed by a low-value transaction (A). Otherwise, it outputs 0.
Example:
• Input: B C C A B
• Output: 00010
(b) Derive the assigned table and write the Verilog code to implement the following 4
FSM.
(c) Validate your answer with the appropriate input and output waveforms on a 3
timing diagram. Include all possible combinations of the input (w).