FixitFast
Junior Member level 2
- Joined
- Feb 6, 2013
- Messages
- 20
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,462
Helloo every one
I need to ask about the following code if it works fine in the practical two cross clock domain systems.
in simulation it works but I have reservations since this method looks fine for 1-bit signals, but for a data bus I am not sure hence want to ask
Thank you
I need to ask about the following code if it works fine in the practical two cross clock domain systems.
in simulation it works but I have reservations since this method looks fine for 1-bit signals, but for a data bus I am not sure hence want to ask
Code:
module clk_2_cross ( clock1, clock2, rst_n, data_in, data_out);
input clock1;
input clock2;
input rst_n;
output [7:0] data_out;
input [7:0] data_in;
reg [7:0] data_out_meta;
reg [7:0] data_out_reg;
reg [7:0] data_out_reg_r;
wire[7:0] data_out;
// Assign statements
assign data_out = data_out_reg_r;
// Always block to declare synchronous logic from source clock domain
always @ (posedge clock1)
begin
data_out_meta <= data_in;
end
// Always block to declare synchronous logic in destination clock domain
always @ (posedge clock2 or negedge rst_n)
begin
if (! rst_n)
begin
data_out_reg <= 'b0;
data_out_reg_r <= 'b0;
end
else
begin
data_out_reg <= data_out_meta;
data_out_reg_r <= data_out_reg;
end
end
endmodule
Thank you