cache module
This commit is contained in:
27
rtl/data_cache/rst_sync.v
Normal file
27
rtl/data_cache/rst_sync.v
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
Reference in New Issue
Block a user