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

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
    • Low-Power RTL Hub
    • DFT and Scan Hub
    • Physical Awareness Hub
    • Waveform Debug Hub
    • STA and ECO Hub
    • RTL-to-Implementation Closure
    • DFT-Ready RTL
    • Capstone: Resilient Streaming Peripheral
    • Principal Design Review
    • Senior RTL Interview Questions & Model Answers
      • Interview: Combinational and Arithmetic
        • The latch inference trap
        • Signed arithmetic and width truncation
        • Parameterized RTL and carry-chain guards
        • Glitches on enables and combinational hazards
      • Interview: Sequential and Pipelines
      • Interview: FSM and Control
      • Interview: Timing and STA
      • Interview: CDC and Reset
      • Interview: Memories and Buses
      • Interview: Low-Power Design
      • Interview: Debug and ECO
      • Interview: Coding and Whiteboard
  • Glossary and Notation
Loading lesson

‹Interview: Combinational and Arithmetic
  1. Topics
  2. RTL Design
  3. Senior & Interview
  4. Senior RTL Interview Questions & Model Answers
  5. Interview: Combinational and Arithmetic
  6. Signed arithmetic and width truncation

Part 9 · Senior · Senior

Signed arithmetic and width truncation

Signed operands, full-width results, and a flag that catches silent truncation in arithmetic.

On this page

    Why this matters

    An 8-bit sum of 96 and 96 wraps to -64 with no warning, and small test values never hit it. The interviewer wants to hear how wide the result is and how the design detects overflow.

    After this lesson you can: size a signed sum to full precision, give the truncation flag condition, and explain why mixing signed and unsigned operands goes wrong.

    The question

    The interviewer asks for an 8-bit signed adder: how wide is the result, and how does the design know when the true sum no longer fits.

    The question tests signedness and width discipline. Silent truncation is a silicon bug that small test values never expose.

    Model answer

    Declare signed on the operand signals, not only on literals. Size the sum to the full precision, 9 bits for 8-bit operands, and carry a flag when the truncated result differs.

    Truncation to 8 bits preserves the value exactly when the two top sum bits agree. When they disagree, the low byte has wrapped.

    Coding

    Outcome

    Both operands signed, 9-bit sum

    Correct full-precision result

    Mixed signed and unsigned operands

    Expression is unsigned: sign lost

    8-bit result, small test values

    Wraps silently on large magnitudes

    8-bit result plus overflow flag

    Defined behaviour on every input

    Interview

    “Signed on the signals, full width on the result, and a flag that fires exactly on overflow.”

    Follow-ups

    • Why does mixing signed and unsigned bite? When any operand is unsigned, the whole expression is unsigned. A signed operand is then treated as a large positive value.

    • How wide is an 8 by 8 multiply? 16 bits. A multiply needs the sum of the operand widths, while an addition of two W-bit numbers needs W plus one.

    • When is truncation acceptable? When the design proves the upper bits redundant, for example a range check upstream. The proof belongs in the testbench, not in optimism.

    Common wrong answers

    “Cast the result with $signed” is too late. The expression width and signedness are fixed before the cast applies.

    “The testbench passed with typical values” proves nothing about extremes. Exhaustive small widths, or directed extremes plus random, are the standard.

    trunc_quiet.sv
    1
    2
    3
    4
    5
    6
    7
    // bad-example
    module trunc_quiet (
      input  logic signed [7:0] a, b,
      output logic signed [7:0] sum
    );
      assign sum = a + b;
    endmodule
    96 + 96 bit by bit: the true sum 192 needs 9 bits. Its top two bits disagree, so the low 8 bits read as -64.

    Read the columns from bit 8 down to bit 0. Bit 8 of each operand is its sign extension.

    • Bits 5 to 7: bit 5 is 1 + 1 = 0 carry 1; bit 6 is 1 + 1 + 1 = 1 carry 1; so bit 7 becomes 1.

    • Bit 8: both operands are positive, so the 9-bit sum keeps a 0 sign bit: +192.

    • The 8-bit result keeps only bit 7 as its sign, which is 1, so the same bits read as -64.

    Common pitfall

    An 8-bit sum of 96 and 96 wraps to -64 with no warning. The testbench below flags every such pair instead of hoping none occurs.

    Check yourself Operands are signed [7:0] and the sum is signed [8:0]. For which sums does the 8-bit wrap differ from the true value?

    Exactly when the top two sum bits disagree. That condition is the truncation flag in the solution below.

    Solution and testbench

    The full-precision adder with a truncation flag, checked against an integer reference over all 65536 operand pairs.

    signed_add.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    module signed_add #(parameter int W = 8) (
      input  logic signed [W-1:0] a, b,
      output logic signed [W:0]   sum,
      output logic signed [W-1:0] wrapped,
      output logic                dropped
    );
      assign sum = a + b;
      assign wrapped = sum[W-1:0];
      assign dropped = (sum[W] != sum[W-1]);
    endmodule
    

    Remember

    • Declare signed on the signals; the width and signedness of an expression are fixed before a cast.

    • An addition needs W plus one bits and a multiply needs the sum of the operand widths.

    • Truncation is exact only when the top two sum bits agree.

    Rule of thumb: signed on the signals, full width on the result, and a flag that fires exactly on overflow.

    Keep going

    • Interview: run a mock interview on this topic

    Related topics

    • Adder building blocks

    Previous

    314 / 350

    Next: Parameterized RTL and carry-chain guards

    Up next

    Up nextParameterized RTL and carry-chain guards

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Glitches on enables and combinational hazards