Here is the verilog equivalent, only that it goes through 2 synchronizers, and has independent asynchronous resets for each clock domain.
I can't remember where from the internet I pulled this from.
module Flag_CrossDomain(
clkA,
reset_n_A,
FlagIn_clkA,
clkB,
reset_n_B,
FlagOut_clkB);
// clkA domain signals
input clkA, FlagIn_clkA;
input reset_n_A;
// clkB domain signals
input clkB;
output FlagOut_clkB;
input reset_n_B;
reg FlagToggle_clkA;
reg SyncA_clkB;
// this changes level when a flag is seen
always @(posedge clkA or negedge reset_n_A) begin
if (~reset_n_A) begin
FlagToggle_clkA <= 1'b0;
end
else begin
if(FlagIn_clkA) FlagToggle_clkA <= ~FlagToggle_clkA;
end
end
// which can then be synched to clkB
always @(posedge clkB or negedge reset_n_B) begin
if (~reset_n_B) begin
SyncA_clkB <= 3'h0;
end
else begin
SyncA_clkB <= {SyncA_clkB, FlagToggle_clkA};
end
end
// and recreate the flag from the level change (Takes 3 clocks. Went through 2 intermediate flip flops for extra stability)
assign FlagOut_clkB = (SyncA_clkB ^ SyncA_clkB);
endmodule