Course Name: Digital System Design Course Number and Section: 14:332:437:xx Experiment: Colloquium No. 2 Adventure Game Lab Instructor: Swapnil Mhaske Date Performed: 9/30/2016 Date Submitted: 10/14/2016 Submitted by: Name: Nikhil Nelson ; RUID: 150006182 --------------------------------For Lab Instructor Use ONLY------------------------------GRADE: _________ COMMENTS: _______________________________________________ Electrical and Computer Engineering Department School of Engineering Rutgers University, Piscataway, NJ 08854 ECE Lab Report Structure 1. Purpose / Introduction / Overview – describe the problem and provide background information 2. Approach / Method – the approach took, how problems were solved 3. Results – present your data and analysis, experimental results, etc. 4. Conclusion / Summary – what was done and how it was done 2 LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 Purpose The goal of this lab was to implement an adventure game in the form of a sequential circuit. In order to do this, we had to create a finite state machine. The first step was to create a state transition table for the state machine. The current state represented the room that the player was in, along with inputs for a reset and directions that the player should move in. From the transition table, we were able to derive the combination logic for the next states as well as the logic functions for each of the outputs. Lastly, we built the schematic in Quartus and performed the simulations in Modelsim. LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 3 Approach My approach was to first create the state transition table and logic equations for the room finite state machine. After that, I dealt with the state transition table and logic equations for the sword state machine. I used a binary representation for the states, so the number of bits which equals the number of D flip-flops needed which is given by the ceiling of log2(number of states). 4 LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 State transition table for room FSM LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 5 D flip flop equations for room FSM 6 LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 Output Equations for room FSM LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 7 Sword FSM state transition table w/ state encoding 8 LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 Sword FSM D flip flop equation and Output Equation Through these logic functions, I was able to build the circuit in Quartus and do the simulations in ModelSim LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 9 Results 1) Please indicate how many hours you spent on this lab. This will not affect your grade, but will be helpful for calibrating the workload for next semester’s labs. Spent a total of five hours. Most of which was spent drawing the room schematic in quartus. 2) Completed state transition diagram for the “Room” FSM. 10 LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 3) a. Room binary encodings b. Sword binary encodings LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 11 4) a. Room Transition table b. Sword Transition Table 12 LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 5) a. Room FSM equations Flip Flop Equations LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 13 Output equations 14 LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 b. Sword FSM Equations LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 15 6) Room FSM schematic b. Sword Schematic 16 LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 7) Full Schematic 8) Waveforms a) Win LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 17 b) Death 18 LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 Conclusion In this lab, we learned how to implement finite state machines using sequential logic circuit components. More specifically, we learned how to implement them with D flip flops. Furthermore, we learned how to create state transition tables that involve several variables and how to derive the necessary logic functions from them. Implementing the room FSM was a very tedious process. The reason this was the case was because I used binary encoding as opposed to on-hot encoding. However, there are tradeoffs associated with each encoding scheme. If I use binary encoding, I use less bits, but more logic gates. On the other hand, if I use one-hot encoding the opposite happens; I have more bits but less logic gates. More concretely, one-hot encoding would require 7 D flip flops, while binary encoding would require 3 flip flops. It was a fairly tedious lab, but I gained a better understanding of state machine implementation through it. LAB REPORT FOR 14:332:437:03; DATE SUBMITTED: 10/14/16 19