EDA programming classic numbers game across the river

Mondo Education Updated on 2024-02-01

First, the design task requirements

, basic requirements:

The classic game of a man crossing a river with a dog, a cat and a mouse is implemented with modules;

Game requirements: The canoe can only carry people and 1 animal at a time, and cats, dogs, cats and mice can not get along with each other, design a river crossing plan, and cross the river safely for three animals, then the game will end successfully.

Representation in an appropriate way by LEDs of various animals, rivers and canoes, as well as the movement of crossing rivers;

The number of river crossings experienced by completing the game is displayed on the digital tube;

Reset the reset button, when the game fails, the LED display or digital tube display E and other ways to indicate that the program is suspended at this time, press the reset key to start a new round of the game.;

2. Design scheme

态Design ideas:

In this course design, we use a finite state machine to implement this game. The hardware of this design mainly includes 5 buttons, 10 LED lights and 2 digital tubes; 5 buttons are used to represent the input and reset buttons, and 14 LEDs are used to display the status of both sides of the river, the status of crossing the river, and the situation of winning or losing. Two digital tubes are used to display the number of river crossings experienced.

The specific steps are as follows:

1.First of all, get the problem and start studying the possible states of the game, and draw a state transition diagram.

2.Based on the state transition diagram, write a program for debugging**.

3. Debugging** passed, and began to design the required modules, frequency division, debounce, base conversion and other modules.

4.After the module design is completed, connect the schematic.

5.Define the pins and eventually display the results on the chamber.

, system composition:

The cross-river game circuit is mainly composed of a state control module, a clock division module, a key debounce module, a counting module, and a decimal conversion module. This is shown in the figure below.

Edit. 2. Hardware circuit design

, button module

There are 5 buttons: a reset button and four buttons for crossing the state control, which can control the corresponding state transition by pressing the corresponding key.

, display module

It is equipped with 14 LED lights and 2 digital tubes. The LED light is divided into two parts, four in LED0-LED3 indicate the state on the other side of the river, LED6 indicates the game error, and LED7 indicates the game success; Four in LED8-LED11 indicate the state of the other side. LED12-LED15 indicates the state of movement. 2 digital tubes show the number of steps taken in the game.

3. Software design

The programmable logic device FPGA is programmed using Quartus II as a development tool, which is implemented by Verilog HDL statements at the bottom layer and schematic at the top level. The software design is composed of four parts: state control module, clock division module, key debounce module, decimal conversion module, because the input clock is 50MHz, the square wave of 50Hz is output by using the frequency division module, and the signal is provided to the control module, and the counting input of the output of the control module is given to the digital tube display decoding module, and the function of the key debounce module is to eliminate the key jitter and set up.

Edit.

Editorial material is borrowed from here

Related Pages