[Xiaoyue Electronics] Anlu domestic FPGA development board system learning tutorial-LESSON4 digital tube static display

Explanation of digital tube static display routine

Insert image description here

To view the video tutorial accompanying this blog, click this link

Based on many years of work experience, the FPGA design process has been summarized in a total of the above 12 steps, some of which can be omitted depending on the difficulty of the project. For example, for very simple projects, we can omit the steps in the dotted box, but our introductory course, no matter how simple it is, will be explained according to these 12 steps.

1. Interpretation of requirements

1.1 Requirements

Let the first digital tube display 0, and modify the code to display any other number.

1.2 Knowledge background

The digital tube is an "8"-shaped device composed of multiple LED light-emitting diodes. According to different polarities, it is divided into common anode and common cathode. Our development board uses a common anode digital tube. The internal structure of the digital tube is as shown below:
Insert image description here
Insert image description here

As can be seen from the figure, the difference between common anode and common cathode. The common terminal of the common anode is connected to the positive terminal of the power supply, and the common terminal of the common cathode is connected to the ground. When choosing a common anode digital tube, we only need to set the corresponding abcdefgdq to a low level to light up the corresponding digital tube. On the contrary, the common cathode needs to connect abcdefgdq to the positive pole of the power supply to light up the corresponding digital tube. The schematic diagram of the digital tube is as follows:
Insert image description here

The development board we chose uses a common anode digital tube. If we want to display 2, then we should light up the
A, B, G, E, and D LEDs. If you want to display 5, you can analyze by yourself which segments should be lit, so that we can get the codes from 0 to 9 of the common yang digital tube. In order to save everyone's time, I have sorted out the codes corresponding to the common Yang digital tube, as shown below, which can be called directly. The coding of the common cathode digital tube only requires bitwise inversion.
The development board common yang digital tube segment selection coding table is as follows:
Insert image description here

1.3 Hardware design

Insert image description here
Insert image description here

The development board uses a PNP transistor. When a low level is input to the base of the transistor, the collector and emitter of the transistor are connected, and a voltage of 3.3V is applied to the bit selection pin of the digital tube. Then we need To light up the first digital tube, you need to input low level to SMG_W0, and assign values ​​to the segment selection of the digital tube according to the digital tube coding table. Now that the principle is mastered, we can start writing code

1.4 Interface description

Signal name direction FPGA pin number illustrate
SMG_W0 output E12 Bit selection control signal, low level can turn on the transistor to power the digital tube bit selection
SMG_W1 output B15 Bit selection control signal, low level can turn on the transistor to power the digital tube bit selection
SMG_W2 output E15 Bit selection control signal, low level can turn on the transistor to power the digital tube bit selection
SMG_W3 output H11 Bit selection control signal, low level can turn on the transistor to power the digital tube bit selection
SMG_W4 output K16 Bit selection control signal, low level can turn on the transistor to power the digital tube bit selection
SMG_W5 output K14 Bit selection control signal, low level can turn on the transistor to power the digital tube bit selection
SMG_A output F13 Digital tube segment selection control signal, low level lights up the segment
SMG_B output B16 Digital tube segment selection control signal, low level lights up the segment
SMG_C output J16 Digital tube segment selection control signal, low level lights up the segment
SMG_D output J13 Digital tube segment selection control signal, low level lights up the segment
SMG_E output G14 Digital tube segment selection control signal, low level lights up the segment
SMG_F output E13 Digital tube segment selection control signal, low level lights up the segment
SMG_G output G12 Digital tube segment selection control signal, low level lights up the segment
SMG_DP output J14 Digital tube segment selection control signal, low level lights up the segment

Summary: The bit selection is equal to: 6'h1f(6'b011111), the segment selection is equal to 8'h03, so that the first digital tube displays 0.

2. Draw theoretical waveform diagram

Insert image description here
Insert image description here

3. New TD project

In order to make the project look tidy and facilitate project transplantation. We create 4 new folders, namely Project, Source, Sim, and Doc.
Project — the project folder, which contains the TD project
Source — the source code folder, which contains the project source code (.v file or .vhd file)
Sim — the simulation folder, which contains the simulation-related files
Doc — stores relevant information , such as data manuals, requirements documents, etc.

4. Write code

///
//QQ:3181961725
//TEL/WX:13540738439
//作者:Mr Wang
//模块介绍:实现数码管的静态显示
///
module sta_smg_drv(
	output	[7:0]	smg_seg,
	output	[5:0]	smg_bit
	);
	assign	smg_seg=8'h03;
	assign	smg_bit=6'h1f;
endmodule

5. Write simulation test stimulus file

`timescale 1ns/1ns
module sta_smg_drv_tb;
	sta_smg_drv Usta_smg_drv(
	.smg_seg(),
	.smg_bit()
	);
endmodule

6.Modelsim simulation

There are generally two methods for Modelsim simulation:

  1. Graphical interface simulation means that all operations are completed on the Modelsim software interface. The advantage of this method is that it is easy to learn and suitable for simple projects. The disadvantage is that the operation steps are cumbersome.

  2. Batch simulation , this method requires writing corresponding script files before simulation. The advantage of this method is that the simulation can be completed with one click, saving time and effort. The disadvantage is that script files need to be written in the early stage. The first two lectures used graphical interface simulation; in order to be closer to engineering reality, starting from this lecture, we will use batch processing simulation. For specific operation steps, please refer to our video tutorial.
    The simulated waveform is shown below:
    Insert image description here

7. Compare waveforms

Compare the theoretical waveform diagram drawn in the second step with the waveform diagram simulated by Modelsim in the sixth step. The results are consistent, indicating that our logic design is correct. If the comparison results are found to be inconsistent, you need to find the reason for the inconsistency, and ultimately ensure that the comparison results are consistent. By comparison, the theoretical waveform is consistent with the simulated waveform, indicating that the function meets the design requirements.

8 Add .v file

Insert image description here

9 Bind the pins and save the constraint file (.adc)

Insert image description here
Insert image description here

10 Compile and synthesize the BIT file

Insert image description here

11. Download BIT file

Insert image description here
Insert image description here

After the download is successful, you can observe the experimental phenomena on the development board. If the experimental phenomena match the design requirements, it means that there is no problem with our design, and we can proceed to the next step of solidifying the configuration file.

12 solidification configuration file

FPGA has a characteristic that the configuration information will be lost after power failure, so we need to store the configuration information in the configuration chip (FLASH). After the development board is powered on, the FPGA will read the configuration information in the configuration chip, so the development The board can still work normally after powering off and on again.
Insert image description here

After the curing is successful, power off the development board and then power it on again. It can be observed that the development board can still perform the functions just now.

Guess you like

Origin blog.csdn.net/Moon_3181961725/article/details/126779672