PART 01 : INTRODUCTION
Most computer code tells a computer what to do. Verilog is totally different.
It is a language used to build the physical computer itself.
Hardware vs. Software Code
When you write software in Python or Java, you are writing rules for a game. You run the game on an
existing board. When you write Verilog, you are designing the physical game board
itself. You are deciding where the wires go and how the tiny switches inside a microchip connect.
Software (Python, C++)
- Runs
step-by-step.
- Uses computer
memory.
- Easy to fix
after you send it out.
Hardware (Verilog)
- Everything
happens at the exact same time.
- Creates
physical logic gates and wires.
- Very hard to
fix once the chip is built.
PART 02 : TWO WAYS TO DESIGN
How Engineers Use Verilog
1. Structural Design
This is like playing with LEGO blocks. You tell Verilog exactly which pieces to use and how to
wire them together. You do not tell it what the final thing does, you just connect the parts.
// Example: Connecting two wires
and(output_wire, input_1, input_2);
2. Behavioral Design
This is the smarter way. You describe what you want to happen. You write simple
rules, and the software figures out how to build the LEGO blocks and wires for you.
// Example: Making a rule
if (button_pressed == 1)
turn_on_light = 1;
Verilog vs. VHDL
There are two major languages used to design chips. One is Verilog. The other is VHDL. Why is
Verilog so popular in modern chip companies? Because it is much simpler.
VERILOG
VHDL
Looks a lot like the "C" programming language. Easy to
read.
Looks like "Ada". Very long, strict, and heavy to read.
Lets you make mistakes quickly to test ideas fast.
Forces you to be perfect before it lets you test anything.
Winner in Silicon Valley and most modern
chip startups.
Often used in old military and
government projects.
PART 03 : WHAT IT LOOKS LIKE
Reading Verilog Code
Let us look at a real piece of Verilog. This code describes a simple "box". The box has two wires going
in, and one wire coming out. It combines the two inputs to make an output.
module simple_box (
input wire A, // Wire coming in from the left
input wire B, // Another wire coming in
output wire C // The wire going out the right
);
// The rule: C gets power ONLY if A and B both have power.
assign C = A & B;
endmodule
NOTE: The word assign tells the computer to
create a physical wire connection inside the chip.
The Tiny Blocks It Builds
When you write Verilog code, the computer software turns your words into tiny microscopic switches
called Logic Gates. These are the alphabet of computers.
AND
The AND Gate
Only turns ON if both switches plugged into it are ON. Like
requiring two keys to open a safe.
OR
The OR Gate
Turns ON if any switch plugged into it is ON. Like a doorbell:
front door OR back door works.
NOT
The NOT Gate
Does the exact opposite. If the switch is ON, it turns the power
OFF. If it is OFF, it turns it ON.
PART 04 : THE FACTORY
From Text to Physical Silicon
1
Write the Code
Engineers type Verilog code on normal computers to describe what the chip
should do.
2
Simulation (Testing)
They test the code in a fake, virtual environment. This is crucial because
fixing a physical chip costs millions of dollars.
3
Synthesis
A special software reads the Verilog and turns the words into a giant map of
real, tiny electrical wires and gates.
4
Fabrication
The map is sent to a massive, ultra-clean factory where machines print the
design onto a physical silicon chip.
Simulation: The Million Dollar Check
If a software app has a bug, a company sends an update over the internet. You cannot send a physical
update to a piece of metal. If a chip goes to the factory with a mistake, the company has to throw
away the chips and lose millions of dollars. This is why Verilog is used heavily to
simulate (fake) the chip to find every single mistake before it is ever built.
PART 05 : REAL WORLD
What Does Verilog Build?
Smartphones
Car Computers
Graphics Cards
Spacecraft
The Next Step: SystemVerilog
As chips became incredibly complicated (with billions of tiny switches inside), standard Verilog needed
an upgrade. Engineers created SystemVerilog. Think of SystemVerilog as the big brother
to Verilog. It adds new tools that make checking the code for errors much easier and faster for massive,
modern computer chips.
PART 06 : MEMORY & PIPES
Pipes vs. Buckets
In Verilog, there are two main ways to move electricity (data) around. You need to know the difference
between a wire and a reg (register).
The Wire (Pipe)
A wire is exactly what it sounds like. It is a physical piece of
metal connecting two points.
- - It cannot store information.
- - If the power at the start stops, the power at the end stops instantly.
- - Like a water pipe: water only comes out if water is actively being pushed in.
The Reg (Bucket)
A reg is a tiny piece of memory. It holds onto a value (ON or OFF)
until you tell it to change.
- - It stores information.
- - If you put a "1" in it, it stays a "1" forever until you change it to a "0".
- - Like a bucket: once you fill it with water, the water stays there.
The Chip's Heartbeat (Clocks)
Imagine an orchestra with millions of musicians. If they all play at whatever speed they want, it sounds
like terrible noise. They need a conductor. In a computer chip, the conductor is called the
Clock.
A clock is just a wire that constantly turns ON and OFF, perfectly evenly, millions of times a second.
Tick. Tock. Tick. Tock. Every time it ticks, the entire chip steps forward exactly one step together.
The Tiny Safe (Flip-Flops)
How does a computer actually remember something? It uses a tiny hardware device called a
Flip-Flop.
A Flip-Flop is like a safe with a door that only opens when the Clock ticks.
When the clock ticks, the Flip-Flop looks at the wire connected to its input, grabs that value
(ON or OFF), puts it inside the safe, and locks the door.
It will hold that value perfectly still until the very next clock tick.
Data In (D)
FLIP-FLOP
Data Out (Q)
PART 07 : BUILDING BIGGER
Boxes Inside Boxes (Modules)
Modern chips have billions of parts. You cannot write the code for every single piece one by one.
Verilog solves this by letting you create Modules.
A module is a custom box you build. For example, you can write Verilog code to build a "Calculator"
module. Once you build it, you can just drop 10 "Calculator" boxes into your main design without
ever rewriting the code. It is the ultimate copy-and-paste for hardware.
Main
Chip
Module: Math
Box
Module: Math
Box
Module:
Memory Box
The "Always" Rule
Because hardware runs continuously, we need a way to tell Verilog, "Keep watching this wire, and if it
changes, do something immediately." We do this using an always block.
// This reads: ALWAYS do the math below whenever A or B changes.
always @ (A or B) begin
Result = A + B;
end
PART 08 : PROVING IT WORKS
The Fake World (Testbenches)
You wrote the code for your chip. But how do you know it works before you spend money to build it? You
write a Testbench.
1. The Chip
This is the Verilog code you actually want to put on a physical piece of silicon.
2. The Testbench
This is fake Verilog code. It acts like a robot pressing buttons on your chip to
see if it breaks. This code never becomes real hardware.
FPGAs: The Rewritable Chip
Making a real silicon chip takes 3 months and millions of dollars. What if you just want to test your
Verilog on real hardware today? Engineers use an FPGA (Field Programmable Gate Array).
An FPGA is a blank, blank chip full of thousands of un-connected Logic Gates. When you plug it into your
computer, your Verilog code tells the FPGA to physically rewire its own internal connections. If you
make a mistake, you just press a button, and the FPGA completely rewires itself in seconds. It is a
reusable, magic piece of hardware.
PART 09 : HARDWARE QUIRKS
Parallel vs Step-by-Step
In software, line 1 happens, then line 2 happens. In hardware, everything happens at exactly the
same time. Verilog has two ways to assign values to handle this weird reality.
Blocking =
Acts like normal software. It finishes the first line before it moves to the
next. Used for simple math logic.
A = 1;
B = A; // B becomes 1
Non-Blocking <=
Acts like real hardware. Everything on the right side is read at the same
time, then pushed to the left side all at once.
A <= 1;
B <= A; // B gets the OLD value of A
Time Travel in Code
When you are writing a Testbench (the fake robot that tests your code), you need to simulate time
passing. You do this using the hashtag symbol #.
turn_on_power = 1;
#10; // Wait for 10 units of fake
time
turn_on_power = 0;
Warning: You cannot use # time delays in real chips. Metal does not know how to "wait". Time delays only
work in the fake simulation computer!
PART 10 : YOUR JOURNEY
Why learn Verilog now? Because we are running out of ways to make software faster.
For the last 30 years, companies just wrote better software. Today, artificial intelligence, electric
self-driving cars, and virtual reality headsets require math that is too heavy for standard computer
chips.
The only way to get faster is to build custom, physical chips designed specifically for AI and new
technology. Knowing how to write Verilog means you know how to build the physical brains of the
future.