Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Course
  • Reading Paths
  • Concept Map
  • How to Read the Diagrams
  • Part 0: What Is a Protocol?10
  • Part 1: Timing and Clocking11
  • Part 2: Encoding and Framing12
    • Line Codes
    • Framing Basics
    • Packet Anatomy
    • Bit Stuffing
    • DC Balance and Running Disparity
    • Block Codes
    • Scrambling
    • Alignment and Lock
    • Control Symbols and Ordered Sets
    • Flits, Phits and Packing
    • Protocols Compared: Encoding and Framing
    • Drills: Encoding and Framing
  • Part 3: Handshakes13
  • Part 4: Flow Control17
  • Part 5: Transactions19
  • Part 6: Concurrency and Performance17
  • Part 7: Ordering13
  • Part 8: Sharing and Arbitration12
  • Part 9: Deadlock and Liveness13
  • Part 10: Reliability and Recovery20
  • Part 11: Bring-Up and Link Management10
  • Part 12: Power8
  • Part 13: Shared State and Coherence9
  • Part 14: Security and Isolation7
  • Part 15: Specifying and Verifying11
  • Part 16: Protocols Dissected17
  • Part 17: Capstones5
  • Part 18: Interview Preparation6
Loading lesson

‹Part 2: Encoding and Framing
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 2: Encoding and Framing
  4. Drills: Encoding and Framing

Part 2 · Encoding and Framing · All levels

Drills: Encoding and Framing

Interview questions, a whiteboard exercise and a ten-question checkpoint for Part 2.

On this page

    Answer each question out loud before opening it. If you miss more than three in the checkpoint, revisit the lessons linked at the end.

    Interview questions

    Check yourself Why does PAM4 double the data rate but hurt noise margin?

    Four levels carry two bits per symbol, halving the symbol rate for a given bit rate, but the level spacing drops to a third of NRZ's (about 9.5 dB), so the same noise causes more errors; PAM4 links rely on FEC.

    Check yourself How does AXI-Stream mark a packet end, and why is that not enough on a cable?

    TLAST marks the last transfer. On chip nothing is lost; on a cable one corrupted marker merges or splits packets with no recovery, so serial links use resynchronising framing and CRCs.

    Check yourself What fields would you put in a read request header?

    Type, address, length, a tag to match the response, requester identity for routing, and attributes; plus a sequence number and CRC at the link layer, with reserved bits for growth.

    Check yourself Why does USB insert a zero after six ones?

    NRZI turns 0s into transitions, so the stuffed 0 guarantees a transition at least every seven bits for clock recovery, and keeps special patterns out of data. Worst-case overhead is about 17%.

    Check yourself What breaks if a link is not DC-balanced?

    On an AC-coupled link the received baseline drifts towards the data's recent average, pushing the threshold towards one level and raising errors even with good transitions.

    Check yourself Why did PCIe move from 8b/10b to 128b/130b?

    To drop from 20% to about 1.5% overhead: Gen3 nearly doubled payload per lane (4 to about 7.9 Gb/s) with only a 1.6x line rate. Run length and balance then come from scrambling plus an always-transitioning 2-bit header.

    Check yourself Does scrambling guarantee transitions?

    No, only statistically; data equal to the scrambling sequence becomes constant. Sync headers stay unscrambled to guarantee a transition per block.

    Check yourself How does a receiver find where a block starts?

    It hunts: slip one bit on each invalid header, require N valid headers in a row (false-lock chance about (½)ᴺ per wrong position), then tolerate a few bad headers per window while locked.

    Whiteboard exercise

    Task. Design the encoding and framing for a 4 Gb/s point-to-point serial link that is AC-coupled, carries variable-length packets of 8 to 256 bytes, and must recover quickly from bit errors. Justify each choice.

    Check yourself Open a model answer

    AC coupling and clock recovery need bounded runs and balance: at 4 Gb/s, 8b/10b's 20% overhead is acceptable and gives hard guarantees plus control symbols (a low-overhead header code with scrambling would also work, with statistical balance). Framing: start-of-packet and end-of-packet control symbols, so the receiver resynchronises at the next packet after an error, plus a length field in the header protected by a header CRC and a packet CRC trailer. Idle and alignment use control symbols (a comma for word alignment). If the link has two clock sources, add SKP-style filler for clock compensation.

    Checkpoint: ten questions

    Check yourself 1. In USB's NRZI, which value is a transition?

    A 0.

    Check yourself 2. Which framing method cannot resynchronise on its own after an error?

    A length field.

    Check yourself 3. Why does a CRC usually go at the end of a packet?

    It is computed over everything before it, so putting it last lets the sender stream the packet without buffering it.

    Check yourself 4. What is CAN's worst-case stuffing overhead, and why is it not 20%?

    25%: the stuffed bit can start a new run, so the worst data gets a stuff bit every four data bits.

    Check yourself 5. How does 8b/10b keep running disparity bounded?

    By choosing, for each byte, between two code groups of opposite imbalance, whichever moves the running disparity back towards zero.

    Check yourself 6. A x4 link at 5 GT/s uses 8b/10b. What is its raw payload bandwidth?

    4 × 5 × 0.8 = 16 Gb/s.

    Check yourself 7. Additive or self-synchronising: which one multiplies errors?

    Self-synchronising: each line error reappears once per tap.

    Check yourself 8. Why must a slip in a lock FSM take effect before the next word is judged?

    Otherwise the FSM judges a word still at the old offset, finds it bad, and slips again, overshooting the right offset.

    Check yourself 9. Why are training ordered sets repeated?

    So a receiver acts only on several identical copies, never on a single corrupted one.

    Check yourself 10. When do large flits beat small ones?

    When traffic is packed into shared flits; with one message per flit, the largest flits are the least efficient at every size in the lesson's table.

    Revisit

    • 2.1 Line Codes

    • 2.2 Framing Basics

    • 2.3 Packet Anatomy

    • 2.4 Bit Stuffing

    • 2.5 DC Balance and Running Disparity

    • 2.6 Block Codes

    • 2.7 Scrambling

    • 2.8 Alignment and Lock

    • 2.9 Control Symbols and Ordered Sets

    • 2.10 Flits, Phits and Packing

    Keep going

    Next: Part 3: Handshakes. Bits and boundaries are settled. Next: how two blocks agree, every cycle, whether a word moved.

    Previous

    37 / 234

    Next: Part 3: Handshakes

    Up next

    Up nextPart 3: Handshakes

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Line Codes
    • Framing Basics
    • Packet Anatomy