Home / Learn Verilog / Designing a Simple ALU

Designing a Simple ALU

Arithmetic and logic in one block.

In shortArithmetic and logic in one block.

What's actually going on

ALUABRESULTOPop
ALU

In plain terms

An ALU selects among operations with an opcode and produces a result plus flags.

Why we use it

The heart of every CPU.

Under the hood

Use a case on the opcode, compute flags separately.

Real-world use

  • Everyday RTL design
  • FPGA and ASIC projects
  • Testbenches and debugging

Try it

8-bit ALUVerilog: edit and run

a - b = 0 sets the zero flag.

Quick quiz

1. ALU opcode chooses...