2016-04-11 11:59:18 -04:00
|
|
|
//#############################################################################
|
|
|
|
//# Function: Reset synchronizer (async assert, sync deassert) #
|
|
|
|
//#############################################################################
|
|
|
|
//# Author: Andreas Olofsson #
|
2021-07-25 14:46:55 -04:00
|
|
|
//# License: MIT (see LICENSE file in OH! repository) #
|
2016-04-11 11:59:18 -04:00
|
|
|
//#############################################################################
|
2015-11-06 16:51:35 -05:00
|
|
|
|
2021-07-25 14:46:55 -04:00
|
|
|
module oh_rsync
|
2021-07-26 22:34:03 -04:00
|
|
|
#(parameter SYNCPIPE = 2, // number of sync stages
|
2022-06-17 15:10:19 -04:00
|
|
|
parameter TARGET = "DEFAULT" // scell type/size
|
2021-07-25 14:46:55 -04:00
|
|
|
)
|
2016-04-11 11:59:18 -04:00
|
|
|
(
|
|
|
|
input clk,
|
|
|
|
input nrst_in,
|
|
|
|
output nrst_out
|
|
|
|
);
|
2016-08-17 15:06:01 +01:00
|
|
|
|
2021-07-25 14:46:55 -04:00
|
|
|
generate
|
2022-06-17 15:10:19 -04:00
|
|
|
if(TARGET == "DEFAULT")
|
2021-07-25 15:16:52 -04:00
|
|
|
begin
|
|
|
|
reg [SYNCPIPE-1:0] sync_pipe;
|
|
|
|
always @ (posedge clk or negedge nrst_in)
|
|
|
|
if(!nrst_in)
|
|
|
|
sync_pipe[SYNCPIPE-1:0] <= 'b0;
|
|
|
|
else
|
|
|
|
sync_pipe[SYNCPIPE-1:0] <= {sync_pipe[SYNCPIPE-2:0],1'b1};
|
|
|
|
assign nrst_out = sync_pipe[SYNCPIPE-1];
|
|
|
|
end
|
2021-07-25 14:46:55 -04:00
|
|
|
else
|
2021-07-25 15:16:52 -04:00
|
|
|
begin
|
2022-06-17 15:10:19 -04:00
|
|
|
asic_rsync #(.TARGET(TARGET),
|
2021-07-25 14:46:55 -04:00
|
|
|
.SYNCPIPE(SYNCPIPE))
|
|
|
|
asic_rsync (.clk(clk),
|
|
|
|
.nrst_in(nrst_in),
|
|
|
|
.nrst_out(nrst_out));
|
|
|
|
end
|
|
|
|
endgenerate
|
2015-11-30 13:45:49 -05:00
|
|
|
endmodule // oh_rsync
|