[Xiaoyue Electronics] Anlu domestic FPGA development board system learning tutorial-LESSON1 lights up the LED light

Routine explanation of lighting LED lights

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

Insert image description here

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

Realize lighting up an LED light (D2).

1.2 Knowledge background

Introduction to LED lights
LED, also known as light-emitting diodes. The operating current of LED lights is very small (some can emit light with only a few tenths of a milliamp). They have good impact and seismic resistance, high reliability and long life. Due to these advantages, LED lights are widely used in instruments and meters as indicator lights, LCD screen backlights and many other fields. Light-emitting diodes of different materials can emit eight colors of light: red, orange, yellow, green, cyan, blue, purple and white. As shown below:

Insert image description here

Figure 2. Plug-in LED light
The long end of this diode is the anode, and the short end is the cathode. The development board is equipped with SMD LED lights. The actual product is shown in the picture below:

Insert image description here

Figure 3. SMD LED light
SMD LEDs generally have color markings on the front, and the marked end is the cathode. Light-emitting diodes have unidirectional conductivity like ordinary diodes. After adding the anode forward voltage to it, the diode can be made to emit light through a current of about 5mA. The greater the current passing through the diode, the stronger the light emitted. However, we generally limit the current to between 3~20mA, otherwise the diode will be burned out if the current is too large.

1.3 Hardware design

Insert image description here
Insert image description here

Figure 4. LED light schematic and PCB
The schematic diagram of the light-emitting diode is shown in the figure above. The anodes of the eight light-emitting diodes from LED1 to LED8 are connected to 3.3V, and the cathodes are connected to the corresponding pins of the FPGA. The resistor between the LED and ground in the schematic diagram acts as a current limiter. We can see from the schematic diagram that LED1 is connected to pin L12 of FPGA. We have marked the pin numbers on the PCB diagram or the actual object, so when binding the pins, you don’t need to look at the schematic diagram, just look at the silk screen on the board, as shown in the PCB diagram above. We only light one LED light (LED1), then we only need to care about the pin number (L12) of LED1. When pin L12 outputs a low level, current flows through the LED light, driving the LED light to emit light. If L12 outputs a high level, no current flows through the LED light, and the LED does not emit light.

1.4 Interface description

Signal name direction FPGA pin number illustrate
LED0 output L12 Connected to LED light, low level LED light turns on

Summary: Through the above explanation, the requirement can be interpreted as that as long as the L12 pin of the FPGA is set to low level, the LED light D2 can be lit.

2. Draw theoretical waveform diagram

Insert image description here

Figure 5. Logic block diagram

Insert image description here

Figure 6 Theoretical waveform

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:13540738439
//作者:Mr Wang
//模块介绍:点亮LED灯
///
module led_on(
   output led 
   );
   assign	led=1'b0;
endmodule

5. Write simulation test stimulus file

`timescale 1ns/1ps
module led_on_tb;
   wire led;
   //例化被仿真模块
   led_on Uled_on(
   .led	(led)
   );
endmodule

Insert image description here

Figure 7. Simulation logic block diagram

6.Modelsim simulation

This routine is very simple and uses only one statement, so no simulation verification is required. But in order to demonstrate a complete development process to everyone, we also created a new simulation project for this experiment, starting from the simplest code to teach you how to write simulation stimulus files and how to use Modelsim software for simulation. Add the source code written in the third step and the simulation test stimulus file written in the fourth step to the Modelsim simulation project to simulate and observe the waveform.
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. In order to quickly apply what everyone has learned to engineering practice, only the first experiment and the second experiment were simulated using a graphical interface, and all subsequent experiments were simulated using batch processing.

    Graphical interface simulation steps:
    1. Create a new project, file–>new–>Project
    Insert image description here

    2. Fill in the project name and specify the simulation project storage path
    Insert image description here

3. Add files, source files and simulation stimulus files
4. Compile
5. Start simulation
Insert image description here
Insert image description here

6. Add observation signal
Insert image description here
7. Interrupt simulation
Insert image description here

8. Enter the run command, run + simulation time
Insert image description here

At this point, we can observe the level status of the simulated signal in the waveform window.
When we change the source code, we need to start from step 4 again.
The simulated waveform is shown in the figure 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.

Experimental phenomena

The LED light connected to FPGA pin L12 is lit, meeting the design requirements, and the design is completed!
Insert image description here

Guess you like

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