aboutsummaryrefslogtreecommitdiff
path: root/rtl/src/reset_synchronizer.v
blob: 3d68bf7a7810c58582c63872a44e56e1fcaed8bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// reset synchronizer:
// Is used too ensure that the deassertion of the reset signal 
// is synchronized with the clock. If the reset signal is deasserted 
// asynchronously with respect to the clock, it can cause metastability issues.

module reset_synchronizer (
    input clk,
    input rstn_async,
    output rstn
);

reg [1:0] rstn_sync;

always @(posedge clk or negedge rstn_async) begin
  if (!rstn_async) rstn_sync <= 2'b00;
  else             rstn_sync <= {rstn_sync[0], 1'b1};
end

assign rstn = rstn_sync[1];

endmodule