배울 내용

  • Perform arithmetic and logical operations on 8-bit operands.
  • Read 8-bit results in binary, decimal, and hex.
  • Generate and interpret status flags (Z, N, C, V).
  • Recognize the 8-bit ALU as the heart of classic 8-bit microprocessors.
  • Trace the operation-select code through to the output MUX.

작동 원리

An 8-bit ALU scales the 4-bit demo to byte-sized operands — taking two 8-bit inputs (range 0–255 unsigned, or −128 to 127 signed) and producing an 8-bit result plus status flags. This is the size of the ALU in classic 8-bit CPUs like the Intel 8080, MOS 6502, and Motorola 6800.

Operations typically supported: - Arithmetic: ADD, SUB, ADC (add with carry), SBC (subtract with borrow), INC, DEC. - Logical: AND, OR, XOR, NOT. - Shift / rotate: SHL, SHR, ROL, ROR (some ALUs include these; others have a separate shifter). - Compare: CMP (subtract A − B and update flags without storing the result).

The operation-select code (typically 4 bits for ~16 operations) drives an output MUX that picks among the functional units' results. Status flags (Z, N, C, V) are computed from the final result and side signals.

For 8-bit addition/subtraction, the carry chain has 8 stages — slow if pure ripple-carry. Real 8-bit CPUs used various optimizations: carry-lookahead in faster chips, simple ripple-carry in cheap chips. The trade-off is speed vs. transistor count.

The 8-bit ALU is a substantial educational milestone: it's the central computational engine of an 8-bit CPU. Once you've built one, the other CPU components (registers, control unit, memory interface) are conceptually simpler.

단계별로 시도해 보세요

위 임베드에서 입력을 설정한 후, 예상 결과를 읽고 직접 확인하세요.

  1. 1
    A = 00010101 B = 00001010 Op = ADD
    예상: Result = 00011111 (= 31)
    관찰 포인트: 21 + 10 = 31. Watch the result bits and verify no carry-out (sum fits in 8 bits).
  2. 2
    A = 11111111 B = 00000001 Op = ADD
    예상: Result = 00000000, C=1, Z=1
    관찰 포인트: 255 + 1 = 256, which wraps to 0 in 8 bits. Carry-out fires; zero flag fires; result rolls over.
  3. 3
    A = 11110000 B = 00001111 Op = AND
    예상: Result = 00000000, Z=1
    관찰 포인트: Bitwise AND — no overlapping 1 bits, so result is all zeros. Zero flag fires.
  4. 4
    A = 11001100 B = 00110011 Op = OR
    예상: Result = 11111111
    관찰 포인트: Bitwise OR — every bit is 1 in at least one input, so result is all 1s.
  5. 5
    A = 01010101 B = 01010101 Op = SUB
    예상: Result = 00000000, Z=1, C=1
    관찰 포인트: 85 − 85 = 0. Zero flag fires; carry-out indicates no borrow (the standard convention for two's-complement subtract).

사용된 구성 요소

실제 응용 사례

8-bit microcontrollers. PIC, AVR, 8051 — all have 8-bit ALUs at their core. Billions of these are deployed in embedded systems.

Classic gaming consoles. NES (6502), SNES (65C816), Master System (Z80) — all built around 8-bit ALUs.

Educational CPUs. Many university CPU-design courses build an 8-bit CPU around this kind of ALU as the first complete processor.

Embedded data processing. 8-bit ALUs handle byte-stream processing in protocols like USB low-speed, UART, and many sensor interfaces.

Bit-slice predecessors. Before commodity CPUs, designers built custom processors from 4-bit bit-slice ALUs (AMD 2901) chained for any width. The 8-bit ALU is two slices.

자주 묻는 질문

What's the difference between this and the 4-bit ALU?
Bit width. Same architecture, more bits per operand. The carry chain is twice as long, the zero-detect is wider, and the operation count typically grows (8-bit ALUs often add shift/rotate beyond the 4-bit minimum).
How fast is an 8-bit ALU?
In modern CMOS at 5 nm, well into the multi-GHz range — limited primarily by the carry chain through 8 full-adder stages. Classic 1980s 8-bit CPUs ran at 1–4 MHz, with the ALU completing in a single cycle.
Why doesn't the 8-bit ALU include 32-bit multiply?
Multiplication needs more transistors and longer paths than basic ALU ops. Many 8-bit micros omitted it (NES 6502 has no multiply); some included a small multiplier (8-bit by 8-bit → 16-bit result). Modern CPUs always have dedicated multipliers separate from the basic ALU.
What status flags does an 8-bit CPU typically have?
Zero (Z), Negative/Sign (N), Carry (C), Overflow (V). Some add Half-Carry (H) for BCD arithmetic, Parity (P) for serial-protocol checks. The 6502 has N, V, B, D, I, Z, C — 7 status bits in one register.
Could I build a 16-bit ALU from two 8-bit ALUs?
Yes — chain them with the lower ALU's carry-out as the upper ALU's carry-in. This is the bit-slice approach used historically before single-chip 16-bit CPUs were common. AMD's 2901 was a 4-bit slice that designers chained for 16 or 32 bits.

학습 계속하기