AMBA APB · Module 5
Legal and Illegal Transitions
A rigorous, protocol-checker enumeration of every legal APB state transition and exactly what makes the rest illegal — skipping setup, lingering in setup, dropping PSEL mid-access — expressed as checkable SVA properties.
Module 2 drew the APB lifecycle as a state machine and showed you the legal path. This deep-drill chapter asks the harder question a protocol checker has to answer every single cycle: of all the transitions the bus could take, which are legal — and what, exactly, makes the rest illegal? The lifecycle has only five legal edges, and every other move is a violation for a precise, nameable reason. The single idea to carry: legality is not a vibe, it is an enumeration — a finite list of allowed transitions, each with an exact condition, so that anything outside the list is a checkable assertion failure. This chapter enumerates the legal set, then walks each illegal move and the contract it breaks.
1. What problem is being solved?
The problem is deciding, mechanically and without judgement, whether any observed APB transition is allowed — so that a manager's FSM, a subordinate's expectations, and a verification checker all agree on what "a valid bus move" is.
A lifecycle diagram tells you the happy path. It does not, by itself, tell you what to reject. A protocol checker cannot run on intuition; it needs the legal set written down exhaustively, because its job is to flag the complement — every move that is not in the set. APB makes this tractable because the FSM is tiny, so the legal set is short and closed:
IDLE → SETUP— a transfer is requested (reqhigh). The bus leaves idle and presents the access.SETUP → ACCESS— unconditional, on the next cycle.PENABLErises; this edge has no guard at all.ACCESS → ACCESS—PREADYis low. The subordinate is not ready, so the access is held (the wait-state self-loop).ACCESS → IDLE—PREADYis high and no further transfer is pending. The transfer completes and the bus idles.ACCESS → SETUP—PREADYis high and another transfer is pending. Completion flows straight into the next setup (back-to-back).
Those five are the whole legal set. The job of this chapter is to make that set exact, and then to show that every other transition — and there are exactly five interesting ones — breaks a specific, statable rule.
2. Why the previous model is not enough
Module 2 gave you the FSM and the legal path IDLE → SETUP → ACCESS → IDLE / next SETUP. That is the constructive view: how to drive a correct transfer. This chapter is the checking view: how to prove an arbitrary waveform is correct — which is a different and stricter discipline. Three things the path-drawing view leaves implicit, and all three are where checkers and bugs live:
- The legal set is closed, and the complement is the spec. Module 2 told you what the FSM does; a checker needs what it must never do. Listing five legal edges is only half the contract — the enforceable half is "and no others." A checker asserts the complement, so the complement must be enumerated as precisely as the legal set.
- Each illegal move maps to one broken guarantee. It is not enough to say "that transition is wrong."
IDLE → ACCESSis wrong because it removes the decode window;SETUP → SETUPis wrong because it violates the one-cycle rule andPENABLEmust rise; droppingPSELinACCESSis wrong because it deselects the subordinate before completion. The reason is what becomes the assertion. - Signal-level violations hide between state-level ones. Some illegalities are not edges at all but signal combinations within a state —
PENABLEhigh duringSETUPcollapses the two phases without ever "taking a bad edge." A purely state-transition view misses these; the checker mindset catches them because it asserts on signals, not just on state names.
So the model to add is the protocol-checker enumeration: the closed legal set, plus each illegal transition stated as a violated contract you can write as a property — the move from "I can draw a correct transfer" to "I can fail any incorrect one at the offending cycle."
3. Mental model
The model: the APB FSM is a guarded turnstile with exactly five doors, and a checker stands at every other point on the wall. A move is legal only if it passes through one of the five doors with the right ticket (its guard condition); a move that tries to go through the wall — any unlisted transition — trips the checker.
Think of an immigration hall. There is one legal sequence: queue (IDLE), present your documents at the desk (SETUP), pass through the gate when it clears (ACCESS → completion). You may be held at the gate while they verify (the wait-state self-loop) — that is allowed. What is not allowed is jumping the desk and going straight to the gate (IDLE → ACCESS, no document check), standing at the desk forever re-presenting documents (SETUP → SETUP), walking back out of the queue after your documents were taken (SETUP → IDLE), or having your visa revoked while you are mid-gate (PSEL dropped in ACCESS). Each forbidden act breaks a specific rule, and a guard is posted for each one.
Three refinements make the model precise:
- Guards, not just edges.
IDLE → SETUPneedsreq;ACCESS → IDLEandACCESS → SETUPboth needPREADYand differ only by whether a next transfer is pending;SETUP → ACCESShas no guard at all. The guard is half the legality — the same edge with the wrong guard is itself a violation. - The complement is enumerable. Because the FSM has three states and the legal set is five edges, the interesting illegal moves are a short, nameable list — not "everything else in the universe," but five specific temptations a real RTL bug actually takes.
- Some violations live inside a state.
PENABLEhigh inSETUP, orPSELlow inACCESS, are illegal signal conditions within a legal state, not bad edges. The checker asserts on the signals, so it catches the move the state diagram cannot draw.
4. Real SoC / hardware context
In silicon the legal set is enforced constructively by the manager FSM and checked by bound assertions. The bridge's sequencer simply has no code path that takes an illegal edge — the absence of a branch is the guarantee — and the verification environment binds properties that fire if the synthesized logic, or a buggy third-party manager, ever does.
The manager's next-state logic is the legal set, written as a case with no escape hatches:
// APB manager next-state: the legal set, encoded as the ONLY reachable edges.
// There is deliberately no IDLE->ACCESS, no SETUP->SETUP, no SETUP->IDLE path.
always_comb begin
next = state;
unique case (state)
IDLE: if (req) next = SETUP; // only legal exit from IDLE
SETUP: next = ACCESS; // unconditional — never repeats, never aborts
ACCESS: if (pready) next = req ? SETUP : IDLE; // complete; else stay (wait state)
endcase
endNotice what is not there: IDLE has no branch to ACCESS, SETUP has no self-branch and no branch back to IDLE. Those missing branches are exactly the illegal transitions — the FSM is correct because it cannot express them. A bug that adds one (or a glitch that corrupts state) is what the checker is for.
On the verification side, the legal set becomes a small bundle of properties bound to every APB interface. They encode the guards directly: a select implies the bus is in a transfer, setup lasts exactly one cycle, and PSEL cannot drop mid-access. This is the single most valuable structural check on an APB port, because an illegal transition otherwise manifests as a corrupted or lost access with no protocol error.
// SVA: three properties that encode APB transition legality on a bound interface.
// (1) No access without select — PENABLE high implies PSEL high (no IDLE->ACCESS,
// no PENABLE-high-in-SETUP collapse where PSEL is also low).
property p_no_enable_without_sel;
@(posedge pclk) disable iff (!presetn)
penable |-> psel;
endproperty
assert property (p_no_enable_without_sel);
// (2) SETUP lasts exactly one cycle — a setup cycle (PSEL high, PENABLE low)
// must be followed by access (PENABLE high). Catches SETUP->SETUP and SETUP->IDLE.
property p_setup_is_one_cycle;
@(posedge pclk) disable iff (!presetn)
(psel && !penable) |=> penable;
endproperty
assert property (p_setup_is_one_cycle);
// (3) PSEL cannot drop mid-access — while in ACCESS and not yet complete,
// PSEL must remain high next cycle. Catches dropping select before PREADY.
property p_psel_held_in_access;
@(posedge pclk) disable iff (!presetn)
(psel && penable && !pready) |=> psel;
endproperty
assert property (p_psel_held_in_access);Bind those three and any manager that skips setup, lingers in setup, abandons a started transfer, or deselects mid-access fails at the offending cycle, naming the rule — instead of you debugging a dropped register write three transactions later.
5. Engineering tradeoff table
Each legality rule trades expressive freedom for a checkable, unambiguous protocol. The closed legal set is a deliberate choice: a tiny set is easy to verify exhaustively.
| Legality rule | What it forbids | What it buys | Why it is correct for APB |
|---|---|---|---|
SETUP → ACCESS unconditional | A multi-cycle or skippable setup | A guaranteed one-cycle decode window | The subordinate always gets exactly one cycle to decode |
No IDLE → ACCESS | A one-cycle "fast" transfer | A single legal entry path to verify | PENABLE high with no setup has no decode window |
No SETUP → SETUP / SETUP → IDLE | Pausing or aborting in setup | A transfer that, once started, completes | A presented access must be honoured, not retracted |
PSEL held through ACCESS | Deselecting mid-transfer | A subordinate that owns completion timing | Dropping select aborts the access the subordinate is mid-serving |
PENABLE low in SETUP | Collapsing the two phases | A clean phase boundary at the PENABLE rise | One marker, PENABLE, cleanly separates the phases |
The throughline: APB keeps the legal set tiny and closed so the complement — the set of violations a checker must catch — is equally tiny and nameable. A protocol with a small legal set is one you can verify exhaustively, which is exactly what the control plane wants.
6. Common RTL / waveform mistakes
7. Interview framing
This is the senior-level APB question that separates "I can recite the FSM" from "I can verify it." Interviewers ask you to enumerate the legal transitions and to explain why a specific tempting shortcut — usually skipping setup or pausing in setup — is illegal. The weak answer lists states; the strong answer lists the closed set of edges with guards and then names the broken contract for each illegal move.
Say it in three moves: the legal set is exactly five edges — IDLE → SETUP on req, SETUP → ACCESS unconditionally (where PENABLE rises), the ACCESS → ACCESS wait-state self-loop while PREADY is low, and ACCESS → IDLE or ACCESS → SETUP on PREADY high depending on whether a next transfer is pending; the set is closed, so anything else is illegal; and each illegal move breaks a named guarantee — IDLE → ACCESS removes the decode window, SETUP → SETUP violates the one-cycle rule, SETUP → IDLE abandons a started transfer, dropping PSEL in ACCESS deselects before completion, and PENABLE high in SETUP collapses the phases. The depth signal that lands: volunteer that each of these is a one-line SVA property — penable |-> psel, (psel && !penable) |=> penable, (psel && penable && !pready) |=> psel — because an interviewer hears that and knows you have bound these checks, not just drawn the diagram.
8. Q&A
9. Practice
- Enumerate the legal set. From memory, write the five legal transitions with their exact guard conditions, and state which edge has no guard and why.
- Name the broken contract. For each of
IDLE → ACCESS,SETUP → SETUP,SETUP → IDLE, andPSELdropped inACCESS, state in one sentence the specific guarantee it violates. - Spot the signal-level violation. Given a waveform where
PENABLEis high during the cyclePSELfirst rises, state which rule is broken and why a state-only checker might miss it. - Write the assertions. From memory, write the three legality properties (
penable |-> psel,(psel && !penable) |=> penable,(psel && penable && !pready) |=> psel) and state which illegal transition each one catches. - Audit an FSM. Given a manager
casestatement with an addedIDLE: if (fast) next = ACCESS;branch, identify the illegal transition it introduces and which bound property would fire on it.
10. Key takeaways
- The APB legal set is exactly five edges:
IDLE → SETUP(onreq),SETUP → ACCESS(unconditional),ACCESS → ACCESS(PREADYlow),ACCESS → IDLEandACCESS → SETUP(PREADYhigh, by whether a next transfer is pending). - The set is closed. Anything outside the five is illegal by construction — the complement is the bug list, which is what a protocol checker asserts.
IDLE → ACCESSremoves the decode window, andSETUP → SETUP/SETUP → IDLEbreak the one-cycle rule. Setup is exactly one cycle becauseSETUP → ACCESSis unconditional andPENABLEmust rise.- Some violations live inside a state.
PSELdropped inACCESSdeselects before completion;PENABLEhigh inSETUPcollapses the phases. Assert on signals, not just state names. - Each illegal move maps to one SVA property —
penable |-> psel,(psel && !penable) |=> penable,(psel && penable && !pready) |=> psel— so legality is checkable at the offending cycle. - A correct manager FSM cannot express the illegal edges. The missing
casebranches are the guarantee; the bound assertions catch anything — a bug or a glitch — that produces one anyway.