Synchronizer constructor

Synchronizer(
  1. Logic clk, {
  2. required Logic dataIn,
  3. Logic? reset,
  4. dynamic resetValue = 0,
  5. int stages = 2,
  6. String name = 'synchronizer',
})

Constructs a Synchronizer with the specified parameters.

  • clk: The destination clock domain.
  • dataIn: The signal to synchronize from the source clock domain.
  • reset: Optional reset signal for the destination domain.
  • resetValue: Value to initialize synchronizer stages on reset.
  • stages: Number of flip-flop stages (default: 2, minimum: 2).

Example:

final sync = Synchronizer(
  destClk,
  dataIn: sourceSignal,
  reset: destReset,
);

Implementation

Synchronizer(
  Logic clk, {
  required Logic dataIn,
  Logic? reset,
  dynamic resetValue = 0,
  int stages = 2,
  String name = 'synchronizer',
}) : super(
        dataIn,
        clk: clk,
        depth: stages,
        reset: reset,
        resetValue: resetValue,
        dataName: name,
        definitionName: 'Synchronizer_S${stages}_W${dataIn.width}',
      ) {
  if (stages < 2) {
    throw RohdHclException('Synchronizer must have at least 2 stages.');
  }
}