aboutsummaryrefslogtreecommitdiff
path: root/rtl/src/reset_synchronizer.v
blob: dc035793a7e26d4ac64e450d2d65dee7f770862e (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