Complete the code to declare a flip-flop that captures data on the rising edge of clk.
always @(posedge [1]) begin
q <= d;
endThe flip-flop captures data on the rising edge of the clock signal clk.
Complete the code to instantiate a two-stage synchronizer for crossing from clk_a to clk_b domain.
reg sync_[1]_1, sync_[1]_2; always @(posedge clk_b) begin sync_[1]_1 <= signal_a; sync_[1]_2 <= sync_[1]_1; end
The synchronizer uses two flip-flops named with the signal name, here sig, to reduce metastability.
Fix the error in the code to safely transfer a pulse from clk_a to clk_b domain using a handshake.
reg pulse_a, pulse_b; always @(posedge clk_a) begin if (reset) pulse_a <= 0; else pulse_a <= [1]; end
To generate a pulse, assign 1'b1 to pulse_a when needed, not the other signals.
Fill both blanks to complete a Gray code counter for safe multi-bit clock domain crossing.
always @(posedge [1]) begin if (reset) gray_count <= 0; else gray_count <= gray_count [2] 1; end
The Gray code counter increments by XORing the current count with 1 on the clock clk.
Fill all three blanks to implement a handshake signal crossing from clk_a to clk_b domain.
reg [1]_a, [1]_b; always @(posedge clk_a) begin [1]_a <= request; end always @(posedge clk_b) begin [2] <= [1]_a; ack <= [2]; end
The handshake uses req_a in clk_a domain, synchronized as req_sync in clk_b domain, and acknowledgment ack_sync.
