Flip-flops are basic memory elements in sequential logic. They capture the input value only at specific clock edges, usually the rising edge. This means the output q updates only when the clock signal changes from low to high. Between these clock edges, the output remains stable, holding the stored value. This allows circuits to remember information over time, which is essential for building memory and state machines. The VHDL code uses a process sensitive to the clock signal, and inside it, the rising_edge function checks for the clock transition. When true, the input d is assigned to output q, storing the state. This step-by-step execution shows how q changes only at clock edges, not when input changes asynchronously.