2012年12月17日 星期一

同步與非同步Reset


同步與非同步Reset






























源自於https://geekwentfreak-raviteja.rhcloud.com/2010/10/designing-asynchronous-and-synchronous-reset-in-verilog/

designing asynchronous and synchronous reset in verilog


Asynchronous reset doesn’t require the clock edge to reset the flip-flop whereas synchronous reset does. Let us design these in verilog and see how synthesis tools implements them.
Asynchronous Reset
dff_async_reset.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module dff_async_reset(
clk,
reset,
data,
Q
);
//input
input clk, reset, data;
//output
output reg Q;
always @(posedge clk, posedge reset) begin
  if(reset) begin
     Q <= 0;
  end
  else begin
    Q <= data;
  end
end
endmodule
FPGA provides asynchronous reset and set options for every register(D flip-flop). Hence, asynchronous resets are implemented by synthesis tools using this reset pin.
Synchronous Reset
dff_sync_reset.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module dff_sync_reset(
clk,
reset,
data,
Q
);
//input
input clk, reset, data;
//output
output reg Q;
//synchronous
always @(posedge clk) begin
  if(reset) begin
    Q <= 0;
  end
  else begin
    Q <= data;
  end
end
endmodule
For synchronous reset, synthesis tool models the reset as another input, selecting either data signal or zero using a mux based on the reset signal.
Which to use
Though synchronous reset results in extra combination logic, it is more efficient because asynchronous reset suffers from metastable state. Metastability in asynchronous reset occurs when reset is de-asserted very close to clock edge and hence violates reset recovery time.






沒有留言:

張貼留言

ESP32 微控制器 採集的環境數據,經由 MQTT 協定 轉換並寫入工業標準的 Modbus 暫存器 中

  一個典型的 IoT(物聯網)與工業自動化系統整合(SCADA/機台連線) 的架構圖。它透過 Node-RED 作為核心資料網關,將前端 ESP32 微控制器 採集的環境數據,經由 MQTT 協定 轉換並寫入工業標準的 Modbus 暫存器 中。 1. 各模組功能拆解...