Voltecx is in beta. The macOS build comes first; Windows and Linux packages are still being tested.Beta. macOS comes first; Windows and Linux are still in testing. What's new
Documentation

D Flip-Flop (dff)

Copies its data input to the output on each rising clock edge.

dff

Component reference · 繁體中文

Group: Control · Kind: {"block":"dff","kind":"control"}

When to use it

Use it to sample a logic signal on a clock, divide a clock by two, or build a shift register. Use SR Latch for a latch that follows levels, and Counter to count edges.

Pins

Pin Domain Meaning
d signal Data input; true above 0.5
clk signal Clock input; rising edge crosses 0.5
s signal Optional asynchronous set; makes q 1 at once while above 0.5
r signal Optional asynchronous reset; makes q 0 at once while above 0.5 and wins over s
q signal Output, always 0 or 1
qn signal Opposite of q

Common parameters

  • q0: Output at the start (Default: 0)

Parameters

Key Unit Default Typical range Description
q0 — 0 Output at the start

Parameter descriptions are in English in both languages.

Model

An edge is a step at which clk is above 0.5 after being at or below 0.5 at the step before. At that step q takes the value d had at the previous step, that is the value just before the clock moved. This makes two flip-flops on one clock a proper shift register. The block has no direct feedthrough, so qn may feed d directly. A clk that is already high at t = 0 does not fire. While r is above 0.5, q is 0; otherwise, while s is above 0.5, q is 1; either one overrides the clock. An unwired s or r reads 0 and never forces q.

Common mistakes

  • A clock that changes between two solver steps is only seen at the next step, so drive it from a PWM Generator output or another source the solver lands on. Data that changes at the same moment as the clock is captured at its old value, like a hold time in hardware.
  • A reset held high keeps q at 0 through every clock edge, and reset wins when s and r are both high. For peak-current-mode control, tie d high, clock it from the oscillator and drive r from the current comparator. q0 sets the starting value; the default 0 suits most designs, and 1 is for an output that must start high.

Datasheet and sources

There is no datasheet. q0 is the power-up state of the register in your design. The clock frequency and phase come from the signal that drives clk, such as the PWM carrier or a timer output in your MCU setup.

Example

Open the example with the command file.openExample and the name demo:dff.


Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.