DIRECT FORM I · 2 delaysDIRECT FORM II · 1 delay×2b₀z⁻¹x[n−1]yy[n]z⁻¹y[n−1]×1b₁×0.5a₁xx[n]×2b₀yy[n]z⁻¹w[n−1]×0.5a₁×1b₁111111
-101234500.51nx[n]INPUT x[n] = δ[n]-101234500.511.52ny[n]OUTPUT y[n]● form I○ form II
Coloured parts: what the current step is about; everything else rests in whiteBlocks: z⁻¹ delays (magenta), gains (violet), round adders (aqua), the input x and the outputs yPlots: the input δ[n] and the output y[n], one stem per samplePills riding the arrows are samples; their value changes as they pass a gainThe filter y[n] = 0.5·y[n−1] + 2·x[n] + x[n−1] drawn as direct form I (back, two delays) and direct form II (front, one shared delay), both stepped with the unit impulse: y = 2, 2, 1, 0.5, 0.25, 0.125. Sign conventions differ: Oppenheim & Schafer write the feedback as + a₁·y[n−1], SciPy as − a[1]·y[n−1]. The diagram is the same; only the number stored for a₁ flips sign.

Three building blocks

  1. A difference equation is a recipe: y[n] = 0.5·y[n−1] + 2·x[n] + x[n−1]. It only does three things: remember an old sample, multiply by a number, and add. A block diagram draws each one as a block.

Direct form I

Direct form II

The working

# step 1/11 · recipe

y[n] = 0.5·y[n−1] + 2·x[n] + x[n−1]

x[n]    the input list   (n = 0, 1, 2 ...)
y[n]    the output list
x[n−1]  the input one sample ago
y[n−1]  the output one sample ago

only three operations appear:
  delay     remember one old sample
  gain      multiply by a fixed number
  adder     add

each one gets a block; arrows carry samples

The coefficients b₀ = 2, b₁ = 1 and a₁ = 0.5 are chosen example values; the input is the unit impulse. Every token, face value and stem in the figure is computed by stepping the two structures in model.mjs. One sample (one clock tick) is split into beats so the eye can follow it: the products, the sum, then the delays storing. Real hardware does it all within one sample period.