Basic knowledge of digital electronics and Verilog: synchronization and asynchronous, synchronous reset and asynchronous reset

Synchronous and asynchronous are two different processing methods. The main difference between them lies in whether you need to wait for the result. Synchronization means that during the execution of a task, you must wait for the completion of the previous task before continuing to execute the next task; asynchronous means that during the execution of a task, you do not need to wait for the completion of the previous task and can execute multiple tasks at the same time. The advantages and disadvantages of synchronization and asynchronousness depend on the specific application scenario. Generally speaking, synchronization is easier to understand and implement, but less efficient; asynchronous is more difficult to understand and implement, but has higher efficiency.

For example, suppose you want to make a dish and you need to chop the vegetables first and then stir-fry them. If you use the synchronous method, then you must finish cutting all the vegetables before starting to stir-fry; if you use the asynchronous method, then you can chop the vegetables and stir-fry at the same time, or let others help you cut the vegetables, and you are only responsible for cooking. . Obviously, in this example, the asynchronous approach is more efficient because it can use idle time and resources to process multiple tasks in parallel.

Synchronous reset and asynchronous reset are two different reset methods. Their difference mainly lies in whether the reset signal is synchronized with the clock signal. The reset signal is a signal used to clear or initialize registers or other components in the circuit, and the clock signal is a signal used to control data transmission and updates in the circuit. Synchronous reset and asynchronous reset each have their own advantages and disadvantages, and the appropriate reset scheme should be selected based on specific design requirements and scenarios.

Synchronous reset means that the reset signal can only take effect on the valid edge of the clock signal (usually the rising edge), which means that the circuit will be reset only when the clock signal arrives. The advantage of synchronous reset is that it can filter out burrs or interference on the reset signal and improve the reliability of the circuit; the disadvantage is that it will increase the combinational logic on the data path, affecting timing and area, and it is necessary to ensure that the duration of the reset signal is long enough, otherwise This may cause some circuits to not be reset correctly.

Asynchronous reset means that the reset signal does not need to wait for the clock signal. As long as a reset signal with a valid width appears, the circuit will be reset immediately. The advantage of asynchronous reset is that it can achieve fast and flexible reset, improving the performance and portability of the circuit; the disadvantage is that the quality of the reset signal is very high. If glitches or interference occur, it may cause false reset or metastable state, and requires Adding an extra port to each register increases area and power consumption.

For example, assume there is a four-bit counter circuit that has a clock input port clk, a data input port d, a data output port q, an enable input port en and a reset input port rst_n. If synchronous reset is used, it can be described with the following Verilog code:

module counter(input logic clk, input logic [3:0] d, input logic en, input logic rst_n, output logic [3:0] q);
  always_ff @(posedge clk) begin
    if (rst_n == 0) q <= 4'b0; // 同步清零
    else if (en == 1) q <= q + d; // 计数使能
    else q <= q; // 保持状态
  end
endmodule

If asynchronous reset is used, it can be described with the following Verilog code:

module counter(input logic clk, input logic [3:0] d, input logic en, input logic rst_n, output logic [3:0] q);
  always_ff @(posedge clk or negedge rst_n) begin
    if (rst_n == 0) q <= 4'b0; // 异步清零
    else if (en == 1) q <= q + d; // 计数使能
    else q <= q; // 保持状态
  end
endmodule

Guess you like

Origin blog.csdn.net/qq_52505851/article/details/132063808