回复 3# wangyu135792
不是这个意思,仍然需要通过B时钟域与A握手,生产一个握手脉冲,通过握手脉冲来实现对B时钟域的门控,写一段代码给你示意:
A时钟域对B的握手指示信号处理:
reg b_cap_a_ack_flag; // From B clk domain, indicating b clk domain has captured flag signals from A
reg b_cap_a_ack_flag_sync0;
reg b_cap_a_ack_flag_sync1;
reg b_cap_a_ack_flag_sync2;
reg event_a; // Event from A clk domain
reg a_to_b_flag; // handshake valid signal from A clk domain to B clk domain
always @(posedge clka or negedge rst_a_n) begin
if (rst_a_n == 1'b0) begin
b_cap_a_ack_flag_sync0 <= 1'b0;
b_cap_a_ack_flag_sync1 <= 1'b0;
b_cap_a_ack_flag_sync2 <= 1'b0;
end
else begin
b_cap_a_ack_flag_sync0 <= b_cap_a_ack_flag;
b_cap_a_ack_flag_sync1 <= b_cap_a_ack_flag_sync0 ;
b_cap_a_ack_flag_sync2 <= b_cap_a_ack_flag_sync1 ;
end
end
always @(posedge clka or negedge rst_a_n) begin
if (rst_a_n == 1'b0) begin
a_to_b_flag <= 1'b0;
end
else begin
if ((event_a == 1'b1) && (b_cap_a_ack_flag_sync2 == 1'b0) ) begin
else if (b_cap_a_ack_flag_sync2 == 1'b1) begin
end
end
always @(posedge clkb or negedge rst_b_n) begin
if (rst_b_n == 1'b0) begin
a_to_b_flag_sync0 <= 1'b0;
a_to_b_flag_sync1 <= 1'b0;
a_to_b_flag_sync 2 <= 1'b0;
end
else begin
a_to_b_flag_sync0 <= a_to_b_flag;
a_to_b_flag_sync1 <= a_to_b_flag_sync0 ;
a_to_b_flag_sync 2 <= a_to_b_flag_sync1 ;
end
end
always @(posedge clkb or negedge rst_b_n) begin
if (rst_b_n == 1'b0) begin
b_cap_a_ack_flag <= 1'b0;
end
else begin
if ((a_to_b_flag_sync2 == 1'b1) && (b_is_idle == 1'b1)) begin
b_cap_a_ack_flag <= 1'b1;
else if (a_to_b_flag_sync2 == 1'b0 ) begin
end
end
always @(posedge clkb or negedge rst_b_n) begin
if (rst_b_n == 1'b0) begin
clkb_gate_en <= 1'b0;
end
else begin
if ((a_to_b_flag_sync2 == 1'b1) && (b_cap_a_ack_flag == 1'b1)) begin
end
end
用clkb_gate_en 作B时钟域的ICG的使能即可
|