ArticleDirectory
- Experiment 2 Configuration
Disclaimer: This article is an original work and copyright belongs to akuei2 and heijin power Community All together, if you need to reprint, please indicate the source http://www.cnblogs.com/kingst/ 2.2 tends to parallel operation
After understanding the differences between "sequential operations" and "parallel operations" in Chapter 2.1, we will discuss this chapter and get used to the thinking of "parallel operations.
Is a combination module, which contains two functional modules. One is the function module for controlling the shining lamp, and the other is the function module for controlling the flow lamp. Assume that I want to use the functional modules implemented by "sequential operations. What is the actual effect?
We use the "C Language" as the representative of "sequential operations" to analyze the process ..
While (1) // Large Loop
{
Flash_funct (); // shining function module
Run_funct (); // flow lamp function module
}
If you followCode,ProgramIn the beginning, the shining function module (flash_funct () will be executed first, and then the running light function module (run_funct () will be executed ()). However, in reality, because of the fast scanning speed of the Controller, the human eye can see the illusion that "two modules are executed in parallel ". In fact, no matter how fast the Controller scans, there will be a "previous delay ".
That is to say, before run_funct () is executed, you must wait for flash_funct () to be executed, flash_funct () to be executed repeatedly, and run_funct () to be executed. In addition, in terms of "Understanding", human thinking is also very concise in order to understand the above Code.
1. Execute flash_funct ();
2. Run run_funct ();
3. Repeat Step 1.
As a result, we understand that "sequential operations" cannot meet the functional requirements of the combination module.
Module top_module (......);
Flash_module U1 // instantiate function module 1
(
......
);
Run_module U2 // function module 2 instantiation
(
......
);
Endmodule
The above content is the instantiation process of the OpenGL language. When creating instances U1 and U2, we only need to ensure that the connection is correct. As mentioned earlier, all functional modules of "parallel operations" are executed independently. In "design", the work of editing flash_module and run_module is "separated", while in "Understanding", both instances are "executed independently ".
In other words, the combination module is very suitable for modeling with "parallel operations. Different from "sequential operations", a combination of modules to be implemented, unless it relies on "High-Frequency Scanning" or "task scheduling program", but no matter how "depends, they are not really "parallel operations ".
Experiment 2: shining lights and flow lights
Function module |
Execution frequency |
Resource usage |
Flashlight function module Flash_module.v |
10Hz (100 ms) |
One led |
Flow lamp function module Run_module.v |
3.3Hz (300 ms) |
Three LEDs |
In experiment 2, we mainly set up functional modules. Take the opportunity of this experiment to explain a long-standing misunderstanding.
Scan Frequency? How often?
The shining frequency refers to the cycle time of an LED on and off. The output of flash_module in Experiment 2 is as follows.
Scan Frequency refers to the time period during which a flow lamp is completed. The scan output specified by run_module in Experiment 2 is as follows.
Recall that when I was getting started with single-chip microcomputer, I realized a flat lamp experiment. Maybe it was about getting started? I care too much about what I see with the naked eye, and forget these important information. Probably many people, right? However, after the experiment creation in Chapter 2.1 and Chapter 2.2, I need to understand the principle of "small experiment, great truth. In the past, the experiment was not only a classic but also contains a lot of knowledge. Sometimes people are too concerned about the outside world, and accidentally forget the world in their hearts.
Source code of Experiment 2:
Example 2:
Tutorial 2:
Note: For details, see the original project under "./experiment02. For the modeling process, see the modeling video "video_exp02 ". For the configuration process, see "Experiment 2 configuration"
Flash_module.v is a 10Hz, 50% duty cycle output function module. To put it simply, the timer switch...
The code is relatively simple.
Run_module.v is a flow lamp with a scanning frequency of 3.3hz. It is written in the form of a "control module. 16 ~ The 24 rows are 1 ms counters. 28 ~ The 36 rows are counter of Ms Based on count1. 40 ~ Row 52 is a 3bit shift operation, and row 45 indicates that a shift operation is performed at an interval of 100. 48 rows to determine the end of the shift. The 51 lines are shift code.
Mix_module.v is a combination module, and the code is easy to understand. Let's see it.
Experiment 2 conclusion:
Whether it is the result of experiment 2, Understanding thinking, or design direction. "Parallel operations" fully meet the requirements of Experiment 2. Therefore:
Thinking tends to be "parallel operations". It is very important to understand or design VerilogHDL + FPGA.
Experiment 2 Configuration
Black gold FPGA model: Cyclone II ep2c8q208c8
Include. V files.
The hierarchy generated after the compilation is successful.
Pin configuration (same as tutorial 1)