22. Level and pulse synchronizers
Build the logic of two classic clock-domain-crossing circuits. Here everything runs on one clock, clk, so the test can check the logic and the latency; in a real design the inputs would come from another clock domain.
Level synchronizer: async_in passes through two flip-flops in a row. sync_out is the second flip-flop, so it follows async_in two clock edges later.
Pulse synchronizer: pulse_in is a one-cycle pulse from the "source" side. A toggle flip-flop flips on every edge where pulse_in is 1. The toggle passes through a 2-flop synchronizer and one more flip-flop; pulse_out is the XOR of the last two of those three flip-flops. So each input pulse produces exactly one one-cycle output pulse, which appears two edges after the edge that saw pulse_in (it is high after the third edge counting that one, for one cycle).
rst (synchronous, active high) clears every flip-flop.
Ports
| Port | Dir | Bits | What it is |
|---|---|---|---|
clk | in | 1 | Clock. |
rst | in | 1 | Synchronous reset, active high. |
async_in | in | 1 | Level to synchronize. |
pulse_in | in | 1 | One-cycle pulse to carry across. |
sync_out | out | 1 | async_in after two flip-flops. |
pulse_out | out | 1 | One cycle per input pulse. |
Example
pulse_in is 1 at edge 1 only: the toggle flips at edge 1, the synchronizer flops copy it at edges 2 and 3, the last flop at edge 4, so pulse_out is 1 between edges 3 and 4.
Written hints
AI hint
Submissions
No submissions yet. Submit your answer and it shows here. Sign in to keep them.
Submit your answer to have it graded. The hidden test runs on the server; you see whether it passes and, if not, the first case it gets wrong.
Press Build to check your code with Yosys. Errors and warnings show here, and a clean build draws the logic diagram.
Build your design to drive it by hand and see its signals here.