Skip to main content
Engineering LibreTexts

5.1: The Sign Extend Unit

  • Page ID
    27266
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    The immediate values which can be part of an instruction are 8 bits, and can be used as an input to the ALU. However, the ALU accepts inputs which are 16 bits. Therefore, immediate values which are passed to the CPU must be expanded to fill 16 bits. The question is how to fill in the high 8 bits when expanding immediate values from 8 to 16 bits.

    Remember that all the immediate values passed to the CPU are integers; the top (left-most) bit of the value determines the sign. If the 2’s complement number is positive, leading 0s have no effect on the number. For example, 01012 = 0000 01012 = 510. In a negative 2’s complement number, leading 1s have no effect on the number. Thus 10112 = 1111 10112 = -510. Thus to extend an integer the left-most bit is extended into the new binary digits. This is what the sign extend unit is doing, extending the 7th bit to positions 8-15 to translate the 8-bit integer into a 16- bit integer.

    Figure 5-1: The sign extend unit

    Screen Shot 2020-07-03 at 12.19.22 PM.png


    This page titled 5.1: The Sign Extend Unit is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Charles W. Kann III via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?