5.5.27 · D3Embedded Systems & Real-Time Software

Worked examples — SpaceWire — high-speed serial link standard for spacecraft

2,389 words11 min readBack to topic

This page is a drill floor. The parent note built the machinery; here we run it through every kind of input it can meet — the boring middle, the weird edges, and the exam traps.

Before a single formula, one promise: we will only use symbols you already own from the parent note. If we need something new, we build it in plain words first.


The scenario matrix

Every problem SpaceWire throws at you falls into one of these case classes. Each column is a lever that can be pushed to an extreme, and each extreme breaks a naive formula in its own way.

Case class The lever being pushed Example that covers it
DS encoding — normal run mixed bits, both lines toggle Example 1
DS encoding — degenerate a run of identical bits (Data flat) Example 2
Parity — odd vs even count number of 1-bits is odd, then even Example 3
Parity — all-zero / all-one the two extreme bytes Example 4
Wormhole vs store-forward — long packet many cargo bytes Example 5
Wormhole — tiny packet limit cargo → 0 (header only) Example 6
Flow control — short cable RTT small, buffer easy Example 7
Flow control — long cable (real world) RTT large, credits scarce Example 8
Exam twist — mixed units / trap Mbps vs MB, ns vs μs Example 9

Read the table as: "what could go wrong?" A run of identical bits kills the Data line's timing. An all-zero byte makes parity feel trivial (it isn't). A zero-length packet makes the latency formula collapse to just the header. Each example below is tagged with its cell.


Warm-up: the two tools we reuse

Recall The two invariants (from the parent note)

Data-Strobe rule — exactly one of the two lines changes each bit period: where means XOR (1 if the two inputs differ, 0 if they match).

Latency of a wormhole route: = number of hops (switches), = per-switch delay, = time to stream the payload at line rate.

Keep these two in view. Half the examples are just these formulas pushed to an edge.


Example 1 — DS encoding, normal run

Forecast first: guess how many times Strobe toggles over these 5 bits. (Hint: it toggles only when Data does not.)

Steps.

  1. Data line = the bit value itself. So Data walks through (the leading 0 is our starting state, then the 5 bits). Why this step? The parent note's whole point: Data is not encoded, it is . The cleverness lives in Strobe.

  2. Strobe rule: Strobe changes exactly when Data did not change. Compare each bit to the one before:

    • (bit 1): Data changed → Strobe holds.
    • (bit 2): Data changed → Strobe holds.
    • (bit 3): Data same → Strobe toggles.
    • (bit 4): Data changed → Strobe holds.
    • (bit 5): Data same → Strobe toggles. Why this step? This guarantees "exactly one line moves per bit," which is the timing anchor.
  3. Tabulate (Data, Strobe) after each bit, starting from (0,0):

bit# Data Strobe who toggled
1 1 1 0 Data
2 0 0 0 Data
3 0 0 1 Strobe
4 1 1 1 Data
5 1 1 0 Strobe

Look at the figure: the top trace is Data, the middle is Strobe, and the bottom red trace is the recovered clock — one clean edge per bit.

Figure — SpaceWire — high-speed serial link standard for spacecraft

Verify: Strobe toggled exactly on bits 3 and 5 (the two "same as previous" cases) → 2 toggles, matching the forecast. In every column, exactly one of {Data, Strobe} changed. ✓


Example 2 — DS encoding, degenerate run of identical bits

Forecast: if we sent only the Data line, what would the receiver see across four identical 1s? (Answer: a flat line — no edges, no timing.)

Steps.

  1. Data line is flat. For starting from Data: it rises once () then stays at 1. After the first bit there are zero Data transitions. Why this step? This is exactly the disaster DS was invented to fix — a long run of identical bits erases timing on a single wire.

  2. Strobe carries all the timing now. Every bit here is "same as previous," so Strobe toggles on bits 2, 3, 4. Why this step? The invariant forces Strobe to move whenever Data can't, so no bit period is silent.

  3. Recovered clock still ticks once per bit, because in every period one line moved.

Look at the figure: Data (top) is flat while Strobe (middle) does the work; the recovered clock (red) still shows four edges.

Figure — SpaceWire — high-speed serial link standard for spacecraft

Verify: number of edges on the recovered clock over 4 bits = 4 (one per bit) despite Data being flat. Timing preserved. ✓


Example 3 — Parity, odd bit-count byte

Forecast: count the 1s by eye. Odd or even? That single fact decides both parity bits.

Steps.

  1. List all eight bits . Count the ones: . Why this step? The classic trap (flagged in the parent note) is counting only six bits. You must XOR all eight.

  2. XOR all eight — XOR-of-bits equals the parity of the count: ones is odd → XOR . Why this step? XOR is just "is the number of 1s odd?" packaged as one bit.

  3. Choose parity bits:

    • Even parity wants an even total → (making six ones).
    • Odd parity wants an odd total → (leaving five ones). Why this step? Parity picks the bit that forces the group into the target parity.

Verify: with , total ones (even ✓). With , total ones (odd ✓). ✓


Example 4 — Parity, the two extreme bytes

Forecast: all-zeros feels like "no information" — does parity even do anything? And eight ones — even or odd?

Steps.

  1. 0x00: zero ones → XOR . Even parity ; odd parity . Why this step? Even the all-zero byte gets protected — a flipped bit becomes a lone 1 and breaks the expected parity.

  2. 0xFF: eight ones, which is even → XOR . Even parity ; odd parity . Why this step? Eight is even, so 0xFF behaves like 0x00 for parity — a common exam surprise (people expect "all ones = odd").

Verify: XOR(0x00) and XOR(0xFF) . Both need odd-parity bit and even-parity bit . ✓


Example 5 — Wormhole vs store-and-forward, long packet

Forecast: guess the ratio. Long packet + many hops should hugely favour wormhole.

Steps.

  1. Body streaming time at line rate: . Why this step? Bits-per-byte is 8; dividing bits by bits-per-second gives seconds.

  2. Store-and-forward: each of the 4 switches must receive the whole packet before forwarding → . Why this step? No parallelism — each hop pays the full body time.

  3. Wormhole: the header carves the path in , then the body streams through the already-open pipe once: . Why this step? Body bytes are in the wire while the header is still advancing — the parallelism the parent note stressed.

Verify: ratio faster. Store-forward , wormhole . ✓


Example 6 — Wormhole limit: header-only packet

Forecast: as cargo , the latency formula should collapse to only the hop term.

Steps.

  1. Body time : with essentially no cargo, . Why this step? This is the degenerate limit — it isolates the per-hop cost.

  2. Latency . Why this step? Confirms the formula degrades gracefully; there's no hidden minimum-packet penalty in the wormhole model itself.

Verify: , dominated entirely by hop latency — exactly the limiting behaviour we predicted. ✓


Example 7 — Flow control, short cable

Forecast: short cable ⇒ credits return fast ⇒ tiny buffer. Guess whether one FCT (8 characters) is already enough.

Steps.

  1. One-way delay . Why this step? Distance ÷ speed = time; this is how long a bit takes to physically travel the cable.

  2. RTT (credit must come back). Why this step? Credit is only useful after it travels there and back.

  3. Bytes in flight bytes. Why this step? Bits-in-flight = rate × RTT; divide by 8 for bytes.

  4. Compare to one FCT (grants 8 characters). , so a single FCT keeps this link permanently full. Why this step? Answers the practical question: short cables never stall.

Verify: in-flight bytes, far below the 8-character credit of one FCT. No stall. ✓


Example 8 — Flow control, long cable (real world)

Forecast: longer cable ⇒ bigger RTT ⇒ more credit needed. Will one FCT still cut it?

Steps.

  1. One-way ; RTT . Why this step? Same physics as Example 7, scaled up 30×.

  2. Bytes in flight bytes. Why this step? Rate × RTT ÷ 8. This is the buffer you must have outstanding to avoid stalling.

  3. Credits needed: each FCT characters, so we need FCT... but at the boundary. Doubling the harness or the rate would tip us over 8 → 2 FCTs. Why this step? Shows why longer/faster links demand more outstanding credit — the RTT-bandwidth product is the design driver named in the parent note.

Verify: in-flight bytes; FCT (just barely). ✓


Example 9 — Exam twist: the unit trap

Forecast: the trap is b (bits) vs B (bytes) and M meaning . Guess the answer's order of magnitude.

Steps.

  1. Convert the image to bits. bytes bits. Why this step? Mbps counts bits per second; the payload is quoted in bytes. Mixing them is the classic exam kill.

  2. Divide by rate. . Why this step? Bits ÷ bits-per-second = seconds. Units cancel cleanly, which is your correctness signal.

  3. Sanity check the magnitude. 400 Mbps = 50 MB/s; . Same answer via bytes. Why this step? Two independent routes agreeing means no factor-of-8 slip.

Verify: s ms, and s. ✓


Recall check

Data flat on a run of identical bits — what saves the timing?
Strobe toggles every "same-as-previous" bit, so exactly one line moves each period.
XOR of all eight bits of 0xFF?
0 (eight ones is an even count).
Wormhole latency with zero cargo over hops?
— the body term vanishes.
Bytes in flight to keep a pipe full?
line rate × RTT ÷ 8.
1 MB over 400 Mbps?
20 ms (remember MB→bits ×8).

Related reading: Wormhole Routing vs Store-and-Forward, LVDS Signaling, RMAP Protocol, Real-Time Determinism, Cosmic Ray Effects on Electronics.