Digital Systems and Information: Arithmetic, Codes, and Abstractions

Conversions and Number Systems Recap

  • Decimal to Other Bases

    • Integer Part Conversion: To convert the integer portion of a decimal number to another base, divide the number by the target base repeatedly and record the remainders. The final converted number is found by reading the remainders in reverse order (from the last remainder generated to the first).
    • Fractional Part Conversion: To convert the fractional portion of a decimal number, multiply the fraction by the target base. Record the resulting integer part. Repeat the process with the remaining fraction until the fractional part equals 00. The final converted fraction is found by reading the recorded integers in chronological order (from first to last).
  • Conversion from Other Bases to Decimal

    • Apply the general positional notation formula: D=∑di×BiD = \textstyle\sum d_{i} \times B^i, where dd is the digit, BB is the base, and ii is the position relative to the radix point.
  • Binary to Octal Conversion

    • The binary number is partitioned into groups of three bits (33 bits) each, starting from the binary point and moving both left and right. Each group is then assigned its corresponding octal digit (00 through 77).
  • Binary to Hexadecimal Conversion

    • The binary number is partitioned into groups of four bits (44 bits) each, starting from the binary point. Each group is then assigned its corresponding hexadecimal digit (00 through 99 and AA through FF).

Binary Arithmetic Operations

  • Binary Addition of Two Bits

    • 0+0=00 + 0 = 0
    • 0+1=10 + 1 = 1
    • 1+0=11 + 0 = 1
    • 1+1=101 + 1 = 10: Result for the current bit is 00, with a carry of 11 to the next higher-order bit.
  • Binary Subtraction of Two Bits

    • 0−0=00 - 0 = 0
    • 1−0=11 - 0 = 1
    • 1−1=01 - 1 = 0
    • 0−1=110 - 1 = 11: In this case, the current step bit result is 11, and a borrow of 11 is taken from the next higher-order bit.

Hexadecimal Arithmetic Operations

  • Hexadecimal Addition (Example: AB+BCAB + BC)

    • Step 1 (Right Column): Sum the least significant digits.
      • B(11)+C(12)=23B(11) + C(12) = 23
      • Since 23>1623 > 16, perform division: 2316=1\frac{23}{16} = 1 with a remainder of 77.
      • Write down 77 and carry over 11.
    • Step 2 (Left Column): Sum the next digits and include the carry.
      • A(10)+B(11)=21A(10) + B(11) = 21
      • Include carry: 21+1=2221 + 1 = 22
      • Perform division: 2216=1\frac{22}{16} = 1 with a remainder of 66.
      • Write down 66 and carry over 11.
    • Final Result: 16716167_{16}
  • Hexadecimal Subtraction

    • When subtracting, if the top digit is smaller than the bottom digit, borrow 1616 from the next column.
    • Example logic provided: 26−11=1526 - 11 = 15, which corresponds to the hexadecimal digit FF.
  • Hexadecimal Multiplication (Example: AA16×B716AA_{16} \times B7_{16})

    • Process Part 1: AA×7AA \times 7
      • A(10)×7=70A(10) \times 7 = 70. 7016=4\frac{70}{16} = 4 remainder 66. Write 66, carry 44.
      • A(10)×7+4=74A(10) \times 7 + 4 = 74. 7416=4\frac{74}{16} = 4 remainder 10(A)10(A).
      • Partial Product 1: 4A6164A6_{16}.
    • Process Part 2: AA×BAA \times B
      • A(10)×B(11)=110A(10) \times B(11) = 110. 11016=6\frac{110}{16} = 6 remainder 14(E)14(E). Write EE, carry 66.
      • A(10)×B(11)+6=116A(10) \times B(11) + 6 = 116. 11616=7\frac{116}{16} = 7 remainder 44.
      • Partial Product 2: 74E1674E_{16}.
    • Final Summation:
      • Align the partial products (shifting the second product left by one position): 4A6+74E0=7986164A6 + 74E0 = 7986_{16}.
      • Text references additional values: 6E6E, 4646, and a resulting block of 51AE51AE.

Decimal Codes and Binary-Coded Decimal (BCD)

  • Definition and Concept

    • Computers store decimal numbers in specific formats to facilitate easy conversion to binary.
    • An nn-bit binary code consists of a group of nn bits that can assume up to 2n2^n distinct combinations of 11s and 00s.
    • Example: A 22-bit code identifies a set of 44 elements; a 44-bit code identifies a set of 1616 elements.
  • Binary-Coded Decimal (BCD)

    • Each decimal digit (0−90-9) is represented by its own 44-bit binary string.
    • Table 1-4: BCD Mapping
      • 0→00000 \rightarrow 0000
      • 1→00011 \rightarrow 0001
      • 2→00102 \rightarrow 0010
      • 3→00113 \rightarrow 0011
      • 4→01004 \rightarrow 0100
      • 5→01015 \rightarrow 0101
      • 6→01106 \rightarrow 0110
      • 7→01117 \rightarrow 0111
      • 8→10008 \rightarrow 1000
      • 9→10019 \rightarrow 1001
  • Practice Problem: Binary Number 010010000111010010000111

    • Conversion to Decimal: 210+27+22+21+20=1024+128+4+2+1=11592^{10} + 2^7 + 2^2 + 2^1 + 2^0 = 1024 + 128 + 4 + 2 + 1 = 1159.
    • Conversion to BCD: Partition into groups of 44 bits: 0100∣1000∣01110100 | 1000 | 0111. This translates to the digits 44, 88, and 77. Result: 487487.

Alphanumeric Codes

  • The Need for Alphanumeric Codes

    • Codes are required to store upper and lowercase letters, decimal digits (0−90-9), and various symbols (punctuation, mathematical operators) in binary form.
    • Requirement breakdown: 26×226 \times 2 (letters) + 1010 (digits) + additional symbols.
  • ASCII (American Standard Code for Information Interchange)

    • Uses 77 bits to encode 128128 characters.
    • The character set consists of 9494 printable characters and 3434 non-printable control characters.
    • Control Characters identified in Table 1-5:
      • NULL:Null\text{NULL}: \text{Null}
      • SOH:Start of heading\text{SOH}: \text{Start of heading}
      • STX:Start of text\text{STX}: \text{Start of text}
      • ETX:End of text\text{ETX}: \text{End of text}
      • EOT:End of transmission\text{EOT}: \text{End of transmission}
      • ENQ:Enquiry\text{ENQ}: \text{Enquiry}
      • ACK:Acknowledge\text{ACK}: \text{Acknowledge}
      • BEL:Bell\text{BEL}: \text{Bell}
      • BS:Backspace\text{BS}: \text{Backspace}
      • HT:Horizontal tab\text{HT}: \text{Horizontal tab}
      • LF:Line feed\text{LF}: \text{Line feed}
      • VT:Vertical tab\text{VT}: \text{Vertical tab}
      • FF:Form feed\text{FF}: \text{Form feed}
      • CR:Carriage return\text{CR}: \text{Carriage return}
      • SO:Shift out\text{SO}: \text{Shift out}
      • SI:Shift in\text{SI}: \text{Shift in}
      • DLE:Data link escape\text{DLE}: \text{Data link escape}
      • DC1-DC4:Device control 1-4\text{DC1-DC4}: \text{Device control 1-4}
      • NAK:Negative acknowledge\text{NAK}: \text{Negative acknowledge}
      • SYN:Synchronous idle\text{SYN}: \text{Synchronous idle}
      • ETB:End of transmission block\text{ETB}: \text{End of transmission block}
      • CAN:Cancel\text{CAN}: \text{Cancel}
      • EM:End of medium\text{EM}: \text{End of medium}
      • SUB:Substitute\text{SUB}: \text{Substitute}
      • ESC:Escape\text{ESC}: \text{Escape}
      • FS-US:Separators (File, Group, Record, Unit)\text{FS-US}: \text{Separators (File, Group, Record, Unit)}
      • SP:Space\text{SP}: \text{Space}
      • DEL:Delete\text{DEL}: \text{Delete}
  • Unicode Code

    • Provides a unique numeric value called a "code point" and a unique name for every character in world languages.
    • Format: U+U+ followed by four to six hexadecimal digits.
    • Example: U+0030U+0030 represents the "Digit Zero."
    • Supports Internationalization and Localization: The process of adapting computing systems for different world regions and languages.

Abstraction Layers in Computer Systems Design

Computer systems are designed in hierarchical layers of abstraction, moving from logical concepts to physical hardware:

  1. Algorithms
  2. Programming Languages
  3. Operating Systems
  4. Instruction Set Architecture (ISA)
  5. Microarchitecture
  6. Register Transfers
  7. Logic Gates
  8. Transistor Circuits

Practice Exercises

  • Decode the following ASCII sequences (mapped from binary):
    • 1000111→G1000111 \rightarrow G
    • 1101111→o1101111 \rightarrow o
    • 0100000→Space0100000 \rightarrow \text{Space}
    • 1000011→C1000011 \rightarrow C
    • 1100001→a1100001 \rightarrow a
    • 1110010→r1110010 \rightarrow r
    • 1100100→d1100100 \rightarrow d
    • 1101001→i1101001 \rightarrow i
    • 1101110→n1101110 \rightarrow n
    • 1100001→a1100001 \rightarrow a
    • 1101100→l1101100 \rightarrow l
    • 1110011→s1110011 \rightarrow s
    • 0100001→!0100001 \rightarrow !
    • Final Decoded Message: "Go Cardinals!"