This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > FPGA Technology > FPGA > FPGA development and design experience summary - FPGA Technology

FPGA development and design experience summary

Date: May 18, 2021

Click Count: 1973

Contents

Before learning a technology we often start from its programming language, for example, when learning microcontroller, we often start from assembly or C language. So many developers who start to contact FPGA, often start from VHDL or Verilog to learn. But I personally think that if you can combine the "Digital Circuit Fundamentals" system to learn a variety of 74 series logic circuit, a deep understanding of the logic function, for learning HDL language is very beneficial, often with half the effort.

Of course, the learning of any programming language is not a one-time thing, the accumulation of experience and skills are done in the drop, FPGA design is no exception. The following FPGAkey will talk with you about the experience and skills of FPGA design.

FPGA.png

We first talk about the basic knowledge of FPGA.


1. Hardware design basic principles

FPGA (Field-Programmable Gate Array), that is, Field-Programmable Gate Array, which is the product of further development on the basis of PAL, GAL, CPLD and other programmable devices. It emerged as a semi-custom circuit in the field of special-purpose integrated circuits, which solves the shortcomings of custom circuits and overcomes the shortcomings of the limited number of gates of the original programmable devices.

Speed and area balance and interchangeability principles.

A design with a large timing margin that can run at a frequency much higher than the design requirements can reduce the chip area consumed by the entire design through module reuse, which is the speed advantage for area savings;

Conversely, if the timing requirements of a design are very high, the ordinary method can not reach the design frequency, then you can use the idea of "ping-pong operation" and "series-parallel conversion" to process the entire design by copying multiple operation modules in parallel through data stream series-parallel conversion. The data is then "parallel-serial converted" at the chip output module. Thus, the area is copied in exchange for the increase in speed.

Hardware principle: understand the essence of HDL.

System principle: grasp the whole.

Synchronous design principle: the basic principle of design timing stability.


2. Verilog as a HDL language, the way to model the behavior of the system is hierarchical

The more important levels are system level, algorithm level, register transfer level, logic level, gate level, and circuit switch level.


3. In practice, for loops are rarely used in RTL-level coding, except for describing simulation test stimuli with for loop statements

This is because the for loop will be expanded by the synthesizer into an execution statement for all variable cases, each variable independently occupies register resources, and cannot effectively reuse hardware logic resources, resulting in a huge waste. Generally, case statements are often used instead.


4. there is a big difference between if.else. and case in nested descriptions

If.else. has priority, generally speaking, the first if has the highest priority and the last else has the lowest priority. The case statement is a parallel statement, it has no priority, and it takes a lot of logic resources to build the priority structure, so don't use if.else. statements where you can use case.

Supplementary: 1. you can also use if.; if.; if.; to describe the "parallel" statements without priority.


5. FPGA general trigger resources are richer, while CPLD combinational logic resources are richer


6. Composition of FPGA and CPLD

FPGA basically has programmable I/O units, basic programmable logic units, embedded block RAM, rich wiring resources, underlying embedded functional units and embedded dedicated hard cores and other six components.

The structure of CPLD is relatively simple, mainly consisting of programmable I/O units, basic logic units, wiring pools and other auxiliary function modules.


7.Block RAM

  • 3 kinds of block RAM structure, M512 RAM (512bit), M4K RAM (4Kbit), M-RAM (64Kbit)

  • M512 RAM: suitable for some small Buffer, FIFO, DPRAM, SPRAM, ROM, etc.

  • M4K RAM: suitable for general needs

  • M-RAM: suitable for large data buffers

  • The LUT of Xlinx and LatTIce FPGAs can be flexibly configured into small RAM, ROM, FIFO and other storage structures, and this technology is called distributed RAM

  • Supplementary: However, in general design, it is not advocated to use the on-chip resources of FPGA/CPLD to configure into a large amount of memory, which is in the consideration of cost. So try to use external memory


8. Make good use of the chip's internal PLL or DLL resources to complete the clock dividing, frequency multiplication, shifting and other operations

Not only simplifies the design, and can effectively improve the accuracy of the system and work stability.


9. The difference between asynchronous and synchronous timing circuits

Asynchronous circuits.

The core logic of the circuit is implemented in a combinational circuit;

The biggest disadvantage of asynchronous timing circuits is that they are prone to burrs;

Not conducive to device migration;

Not conducive to static timing analysis (STA), verification of design timing performance.

Synchronous timing circuits.

  • The core logic of the circuit is implemented with various flip-flops;

  • The main signals, output signals, etc. are generated by driving the flip-flop at a certain clock edge;

  • Synchronous timing circuit can be very good to avoid burrs;

  • Good for device migration;

  • It is good for static timing analysis (STA) and verification of design timing performance.


10. In synchronous design, stable and reliable data sampling must comply with the following two basic principles.

(1) before the arrival of the valid clock edge, the data input has been stable for at least as long as the Setup time of the sampling register, this principle is referred to as meeting the Setup time principle;

(2) After the valid clock edge arrives, the data input will at least stabilize the Hold clock of the sample register for a long time, this principle is referred to as meeting the Hold time principle.


11. Synchronous timing design considerations

  • Asynchronous clock domain data conversion.

  • Design methods for combinational logic circuits.

  • Clock design of synchronous timing circuits.

  • Delay of synchronous timing circuits. The most common design method for the delay of synchronous timing circuits is to use a divided or multiplied clock or synchronous counter to complete the required delay, in contrast to the larger and special timing requirements of the delay, generally use a high-speed clock to generate a counter, according to the count to generate the delay; for smaller delays, you can use a D flip-flop to hit, so that not only can make the signal delayed by one clock cycle, but also to complete the signal and clock's initial synchronization. Used in input signal sampling and increasing the timing constraint margin.

In addition, there are behavioral-level methods to describe the delay, such as "#5 a"=4'0101;" this is commonly used in simulation test excitation, but will be ignored in the circuit synthesis, and does not play a delay role.

Verilog definition of reg type, not necessarily synthesized into registers. The two most commonly used data types in Verilog code are wire and reg type. In general, the data specified by wire type and the network wire are implemented through combinational logic, while the data specified by reg type is not necessarily implemented with registers.


12. Common design ideas and techniques

(1) Ping-pong operation;

(2) Serial to parallel conversion;

(3) pipelined operation;

(4) Asynchronous clock domain data synchronization. It is the problem of how to reliably exchange data between two data domains that are not synchronized by clocks. There are two main cases of data clock domain desynchronization.

  •  two domains with the same clock frequency, but the difference is not fixed, or the difference is fixed but not measurable, referred to as the same frequency heterodyne problem.

  •  two clock frequencies are fundamentally different, referred to as the heterodyne problem.

  • Two kinds of asynchronous clock domain operation method is not recommended: one is to adjust the sampling by increasing the Buffer or other gate delay; the other is to blindly use the clock positive and negative edges to adjust the data sampling.


13. The basic principles of module division

  • Use registers for the output of each sub-module of synchronous timing design (the principle of dividing synchronous timing modules by registers);

  • Divide the related logic and reusable logic in the same module (echo system principle);

  • Separate the logics with different optimization objectives;

  • grouping the logic that sends constraints into the same module;

  • Separate the storage logic into modules;

  • Suitable module size;

  • Top-level modules are preferably not designed for logic.


14. Considerations for combinatorial logic

(1) Avoid combinational logic feedback loops (prone to burrs, oscillations, timing violations, etc.).

Solution.

A. Keep in mind that any feedback loop must contain registers;

B. Check the WARNING information reported by synthesis and implementation, and modify accordingly after finding feedback loops (combinaTIonal loops).

(2) Replace the delay chain.

Solution: Finish with frequency doubling, frequency dividing or synchronous counter.

(3) Replace the asynchronous pulse generation unit (burr generator).

Solution: Design the pulse circuit with synchronous timing.

(4) Use latches carefully.

Solution

A. Use complete if.else statements.

B. Check if the design contains a combinational logic feedback loop.

C. For each input condition, design the output operation and set the default operation for the case statement. In particular, in the state machine design, it is better to have a default state transfer, and it is better to have a default operation for each state as well.

D. If you use case statements, especially in the design of the state machine, try to attach the synthesis constraint property, synthesize as a fully conditional case statement.

Tips: carefully check the synthesizer synthesis report, most of the synthesizer synthesizer will report "warning" for the synthesized latch, through the synthesis report can be more convenient to find the unintentionally generated latch.


15. Clock design considerations

The recommended clock design method for synchronous timing circuits: the clock is input via the global clock input pin, adjusted and calculated by the internal dedicated PLL or DLL of the FPGA for dividing/multiplying, shifting, etc., and then driven by the internal global clock wiring resources of the FPGA to reach the clock inputs of all registers and other modules in the chip.

FPGA designer's 5 basic skills: simulation, synthesis, timing analysis, debugging, verification.

For FPGA designers, practice these 5 basic skills, and use the corresponding EDA tools is the same process, the correspondence is as follows.

1. simulation: Modelsim, Quartus II (Simulator Tool)

2. synthesis: Quartus II (Compiler Tool, RTL Viewer, Technology Map Viewer, Chip Planner)

3. Timing: Quartus II (TImeQuest Timing Analyzer, Technology Map Viewer, Chip Planner)

4. debugging: Quartus II (SignalTap II Logic Analyzer, Virtual JTAG, Assignment Editor)

5. verification: Modelsim, Quartus II (Test Bench Template Writer)

Although mastering HDL language is not the whole of FPGA design, but the impact of HDL language on FPGA design throughout the entire FPGA design process, and the five basic skills of FPGA design are complementary.

For FPGA designers, a good use of the "synthesizable subset of the HDL language" can complete 50% of the work of FPGA design - design coding.

The three basic skills of simulation, synthesis, and timing analysis are helpful for learning the "synthesizable subset of HDL language" as follows.

Through simulation, you can observe the logic behavior of HDL language in FPGA.

Through synthesis, you can observe the physical implementation of the HDL language in FPGAs.

Timing analysis allows you to analyze the physical implementation of the HDL language in FPGAs.

For FPGA designers, using the "verification subset of HDL language" can complete the other 50% of FPGA design work - debug verification.

1. Build verification environment, through the means of simulation can verify the correctness of the FPGA design.

2. Comprehensive simulation verification can reduce the workload of FPGA hardware debugging.

3. Combine hardware debugging and simulation verification methods, use debugging to solve the problems not verified by simulation, use simulation to ensure that the problems that have been solved are not reproduced in debugging, you can establish a regression verification process, which helps to maintain the FPGA design project.

These five basic skills of FPGA designers are not isolated and must be used in combination to complete a complete FPGA design flow. Conversely, the 5 fundamentals can be most effectively practiced by completing a complete design flow. The five basic skills have a preliminary understanding, you can learn some in-depth one by one, and then the knowledge learned again for the complete design process. So repeatedly, you can gradually improve the design level. Using such a step-by-step, spiral approach, as long as the training into the door, you can learn and practice on their own, self-improvement.

In order to ensure the integrity of the structure of the books sold on the market about FPGA design, each aspect of FPGA design is introduced separately, each aspect is in-depth, but due to the lack of support from other related aspects, it is difficult for readers to put into practice, only through the complete book to gain an overall understanding of FPGA design. Such a book, as an engineering training guide does not work, can be used as a reference book for a certain aspect of advancement.

For new employees, they often have a preliminary understanding of the overall design process of FPGA, 5 basic skills of a few aspects may be very solid. However, the lack of ability in one or more aspects limits their ability to complete the entire design flow alone. The purpose of the induction training is to help them master the overall design process, develop the ability to acquire information by themselves, and form a virtuous cycle of self-promotion and self-development through the training of several design processes back and forth. In this process, as the breadth and depth of knowledge involved in the work is gradually clarified, the new employees' self-confidence will gradually increase and the direction of personal development will gradually become clear, so that they can actively participate in the engineering projects.

FPGA2.png

Finally summarize a few points.

1) Look at the code and build a model

Only when you build a logic model in your mind and understand the basis of FPGA internal logic structure implementation, you can understand why the overall idea of writing Verilog and writing C is different, and you can understand the differences in design methods of sequential execution language and parallel execution language. What kind of functional circuit should be thought of when seeing a simple program.

2) Use mathematical thinking to simplify the design logic

Learning FPGA not only logical thinking is important, good mathematical thinking can also make your design simple, so ah, those who see the high number of headaches need to pay attention to the class Oh. As a simple example, for example, there are two 32bit data X[31:0] and Y[31:0] multiplied together.

Of course, both Altera and Xilinx have ready-made multiplier IP cores to call, which is the easiest way, but two 32bit multipliers will consume a lot of resources. So is there a resource-saving and less complicated way to implement it? We can make a slight modification.

Split X[31:0] into two parts X1[15:0] and X2[15:0], so that X1[15:0]=X[31:16], X2[15:0]=X[15:0], then X1 left shift 16 bits and X2 can be added to get X; similarly, split Y[31:0] into two parts Y1[15:0] and Y2[15:0], so that Y1[15:0] = Y[31:16], Y2[15:0]=Y[15:0], then Y1 is shifted left by 16 bits and added with Y2 to get Y; then the multiplication of X and Y can be transformed into X1 and X2 multiplied with Y1 and Y2 respectively, so that a 32bit*32bit multiplication operation is converted into four 16bit*16bit multiplication operations and three 32bit addition operations. After the conversion of the occupied resources will be reduced a lot, interested children, may wish to take a comprehensive look to see how much difference between the two.

3) The relationship between the clock and the flip-flop

"The clock is the controller of the timing circuit" This sentence is too classic, can be said to be the holy words of the FPGA design. But the timing circuit is different, all its actions are in the clock a beat a beat rhythm shift trigger, it can be said that the clock is the controller of the entire circuit, control is not good, the circuit function will be chaotic.

To use an analogy, the clock is equivalent to the human heart, it is every beat is to trigger a CLK, the body's organs to supply blood, maintaining the normal operation of the body, each organism works properly without the composition of tissue cells, then the trigger can be compared to the basic unit tissue cells. Timing logic circuit clock is the control of timing logic circuit state transition "engine", without it the timing logic circuit can not work properly, because the timing logic circuit is mainly used to store the state of the circuit flip-flop, and the flip-flop state change requires the rising or falling edge of the clock! This shows the core role of the clock in the timing circuit!

Finally, a brief description of the experience, it boils down to more practice, more thinking, more questions. Practice makes perfect, see 100 times other people's programs than their own practice. The motivation to practice comes from interest on the one hand, and pressure on the other, and I personally think the latter is more important. Demand will easily form pressure, that is, it is best to exercise in the actual project development.


<< Previous: Master teaches you step by step how to play FPGA

<< Next: Introduction to Interrupts for Zynq-7000 Series

Need Help?

Support

If you have any questions about the product and related issues, Please contact us.