feat: add rtl/heartbeat_sync.v

This commit is contained in:
2026-09-25 11:57:23 +08:00
parent 5f6a31d258
commit dc4f037849

11
rtl/heartbeat_sync.v Normal file
View File

@@ -0,0 +1,11 @@
module heartbeat_sync (
input wire clk, input wire rst_n, input wire heartbeat_async,
output wire heartbeat_rise
);
reg stage1, stage2, previous;
always @(posedge clk or negedge rst_n) begin
if (!rst_n) begin stage1 <= 0; stage2 <= 0; previous <= 0; end
else begin stage1 <= heartbeat_async; stage2 <= stage1; previous <= stage2; end
end
assign heartbeat_rise = stage2 && !previous;
endmodule