2016-04-11 11:59:18 -04:00
|
|
|
//#############################################################################
|
|
|
|
//# Function: Reset synchronizer (async assert, sync deassert) #
|
|
|
|
//#############################################################################
|
|
|
|
//# Author: Andreas Olofsson #
|
|
|
|
//# License: MIT (see LICENSE file in OH! repository) #
|
|
|
|
//#############################################################################
|
2015-11-06 16:51:35 -05:00
|
|
|
|
2016-06-19 17:08:46 -04:00
|
|
|
module oh_rsync #(parameter PS = 2, // number of sync stages
|
|
|
|
parameter ASIC = `CFG_ASIC // use asic library
|
|
|
|
)
|
2016-04-11 11:59:18 -04:00
|
|
|
(
|
|
|
|
input clk,
|
|
|
|
input nrst_in,
|
|
|
|
output nrst_out
|
|
|
|
);
|
2016-06-19 17:08:46 -04:00
|
|
|
generate
|
|
|
|
if(ASIC)
|
|
|
|
begin : g0
|
|
|
|
asic_rsync asic_rsync (.clk(clk),
|
|
|
|
.nrst_in(nrst_in),
|
|
|
|
.nrst_out(nrst_out));
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin :g0
|
|
|
|
reg [PS-1:0] sync_pipe;
|
|
|
|
always @ (posedge clk or negedge nrst_in)
|
|
|
|
if(!nrst_in)
|
|
|
|
sync_pipe[PS-1:0] <= 1'b0;
|
|
|
|
else
|
|
|
|
sync_pipe[PS-1:0] <= {sync_pipe[PS-2:0],1'b1};
|
|
|
|
assign nrst_out = sync_pipe[PS-1];
|
|
|
|
end
|
|
|
|
endgenerate
|
|
|
|
|
2015-11-30 13:45:49 -05:00
|
|
|
endmodule // oh_rsync
|
|
|
|
|