Files
IPA/rtl/data_cache/rst_sync.v
Core_kingdom 79dee10db1 cache module
2025-08-26 16:53:22 +08:00

27 lines
599 B
Verilog
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module rst_sync #(
parameter SYNC_STAGE = 2 // 同步级数推荐2级
) (
input wire clk,
input wire rst_n_in,
output reg rst_n_out
);
reg [SYNC_STAGE-1:0] rst_sync_reg;
always @(posedge clk or negedge rst_n_in) begin
if (!rst_n_in) begin
rst_sync_reg <= {SYNC_STAGE{1'b0}};
end else begin
rst_sync_reg <= {rst_sync_reg[SYNC_STAGE-2:0], 1'b1};
end
end
always @(posedge clk or negedge rst_n_in) begin
if (!rst_n_in) begin
rst_n_out <= 1'b0;
end else begin
rst_n_out <= rst_sync_reg[SYNC_STAGE-1];
end
end
endmodule