VLSI Design Portfolio · Step 1 of 8 Verilog HDL implementation of all fundamental logic gates from scratch — with individual testbenches, GTKWave simulation waveforms, and truth table verification for every gate.
- Overview
- Repository Structure
- Gates Implemented
- Block Diagram
- Truth Tables
- Simulation Instructions
- Waveforms
- Concepts Covered
- Tools Used
- What's Next
This is the first repository in my journey of building a 16-bit pipelined RISC processor from scratch using Verilog HDL.
Every component of a digital system — from a simple adder to a full processor — reduces to basic logic gates at the transistor level. This repository implements all 7 fundamental gates individually, each with its own dedicated Verilog module, testbench, and verified simulation waveform.
Each gate is implemented using continuous assignment (assign) — the standard approach for combinational logic in RTL design — and verified against its complete truth table.
01-basic-logic-gates/
│
├── src/ # Verilog HDL source files
│ ├── and_gate.v # 2-input AND gate
│ ├── or_gate.v # 2-input OR gate
│ ├── not_gate.v # Single-input NOT gate (inverter)
│ ├── nand_gate.v # 2-input NAND gate
│ ├── nor_gate.v # 2-input NOR gate
│ ├── xor_gate.v # 2-input XOR gate
│ └── xnor_gate.v # 2-input XNOR gate
│
├── tb/ # Testbench files
│ ├── and_gate_tb.v
│ ├── or_gate_tb.v
│ ├── not_gate_tb.v
│ ├── nand_gate_tb.v
│ ├── nor_gate_tb.v
│ ├── xor_gate_tb.v
│ └── xnor_gate_tb.v
│
├── sim/ # Simulation waveforms and outputs
│ ├── and_gate_waveform.png
│ ├── and_gate_terminal.png
│ ├── or_gate_waveform.png
│ ├── or_gate_terminal.png
│ ├── not_gate_waveform.png
│ ├── not_gate_terminal.png
│ ├── nand_gate_waveform.png
│ ├── nand_gate_terminal.png
│ ├── nor_gate_waveform.png
│ ├── nor_gate_terminal.png
│ ├── xor_gate_waveform.png
│ ├── xor_gate_terminal.png
│ ├── xnor_gate_waveform.png
│ └── xnor_gate_terminal.png
│
├── docs/ # Documentation and diagrams
│ └── gate_symbols.png # Circuit symbols and truth table reference
│
└── README.md
| # | Gate | Symbol | Boolean Expression | Gate Type |
|---|---|---|---|---|
| 1 | AND | & |
Y = A · B | Basic |
| 2 | OR | ` | ` | Y = A + B |
| 3 | NOT | ~ |
Y = Ā | Basic |
| 4 | NAND | ~& |
Y = ̄(A · B) | Universal |
| 5 | NOR | `~ | ` | Y = ̄(A + B) |
| 6 | XOR | ^ |
Y = A ⊕ B | Arithmetic |
| 7 | XNOR | ~^ |
Y = ̄(A ⊕ B) | Arithmetic |
Note: NAND and NOR are called Universal Gates because any Boolean function can be implemented using only NAND gates or only NOR gates. XOR is the foundation of binary addition — it directly computes the sum bit in a half adder.
The diagram below shows all 7 gate circuit symbols with their Boolean expressions, Verilog assign statements, and a combined truth table summary.
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
| A | Y |
|---|---|
| 0 | 1 |
| 1 | 0 |
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
- Icarus Verilog — open-source Verilog simulator
- GTKWave — waveform viewer
Step 1 — Compile
iverilog -o and_gate_sim and_gate.v and_gate_tb.vStep 2 — Run simulation
vvp and_gate_simStep 3 — View waveform
gtkwave and_gate.vcd# AND
iverilog -o and_gate_sim and_gate.v and_gate_tb.v
vvp and_gate_sim
# OR
iverilog -o or_gate_sim or_gate.v or_gate_tb.v
vvp or_gate_sim
# NOT
iverilog -o not_gate_sim not_gate.v not_gate_tb.v
vvp not_gate_sim
# NAND
iverilog -o nand_gate_sim nand_gate.v nand_gate_tb.v
vvp nand_gate_sim
# NOR
iverilog -o nor_gate_sim nor_gate.v nor_gate_tb.v
vvp nor_gate_sim
# XOR
iverilog -o xor_gate_sim xor_gate.v xor_gate_tb.v
vvp xor_gate_sim
# XNOR
iverilog -o xnor_gate_sim xnor_gate.v xnor_gate_tb.v
vvp xnor_gate_sim
# View waveform
gtkwave gate_name.vcdEach testbench applies all input combinations and displays the input and output values on the terminal. A .vcd waveform file is also generated which can be opened in GTKWave.
Example output for AND gate:
Time=0 a=0 b=0 y=0
Time=10000 a=0 b=1 y=0
Time=20000 a=1 b=0 y=0
Time=30000 a=1 b=1 y=1
moduleandendmodule— defining a hardware blockinput wireandoutput wire— port declarationsassignstatement — continuous assignment for combinational logic- Bitwise operators —
&,|,~,^,~&,~|,~^ - Testbench structure —
timescale,reg,initialblock,$display,$dumpfile,$dumpvars,$finish - Module instantiation — named port connection syntax
.port(signal)
- Behaviour of all 7 fundamental gates
- NAND and NOR as universal gates — any circuit can be built from only these
- XOR as the sum generator in binary addition — foundation of the ALU (coming in Repo 5)
- Difference between combinational logic (no memory) and sequential logic (covered in Repo 3)
- Continuous assignment — models real wires that are always active
| Tool | Purpose |
|---|---|
| Icarus Verilog | Compilation and simulation |
| GTKWave | Waveform viewing and verification |
| VS Code | Code editor |
| Git | Version control |
This repository is Step 1 in an 8-step roadmap building up to a complete 16-bit pipelined RISC processor.
| Step | Repository | Status |
|---|---|---|
| 1 | 01-basic-logic-gates | ✅ Complete |
| 2 | 02-combinational-circuits | ✅ Complete |
| 3 | 03-sequential-circuits | ✅ Complete |
| 4 | 04-finite-state-machines | 🔨 In Progress |
| 5 | 05-alu-16bit | ⏳ Upcoming |
| 6 | 06-processor-components | ⏳ Upcoming |
| 7 | 07-risc16-pipelined-processor | ⏳ Upcoming |
| 8 | 08-protocols-and-interfaces | ⏳ Upcoming |
The XOR gate built here directly becomes the sum bit generator inside the full adder, which becomes part of the 16-bit ALU, which becomes the Execute (EX) stage of the pipelined RISC processor.
Abhi Chandra B — B.Tech ECE, 3rd Year Building a complete VLSI design portfolio from logic gates to a pipelined processor.
Part of an 8-repository VLSI learning roadmap — from AND gate to 16-bit pipelined RISC processor.