Verilog Introduction: Modules, Nets and Modelling Styles

Verilog is a hardware description language (HDL). Unlike a software language, where statements run one after another on a CPU, Verilog describes hardware that exists all at once — gates, flip-flops and wires that are physically present and operate in parallel. Learning Verilog is mostly learning to think in terms of concurrent hardware rather than sequential instructions.

This series is the free reference companion to the instructor-led VLSI programs at ChipXpert. Every code example on every page is compiled and simulated with the open-source Icarus Verilog toolchain before it is published, so what you read is what actually runs.

The building block: a module

Every Verilog design is a hierarchy of modules. A module has a name, a list of ports (its connections to the outside world), and a body that describes its behaviour or structure. Here is a complete, self-contained example — a 2-input AND gate and a tiny testbench that drives it:

module and_gate (input a, input b, output y);
  assign y = a & b;   // continuous assignment: y always tracks a & b
endmodule

module tb;
  reg a, b;
  wire y;
  and_gate dut (.a(a), .b(b), .y(y));   // instantiate, connect by name
  initial begin
    a = 0; b = 0; #1 $display("a=%b b=%b -> y=%b", a, b, y);
    a = 1; b = 0; #1 $display("a=%b b=%b -> y=%b", a, b, y);
    a = 1; b = 1; #1 $display("a=%b b=%b -> y=%b", a, b, y);
    $finish;
  end
endmodule
a=0 b=0 -> y=0
a=1 b=0 -> y=0
a=1 b=1 -> y=1

Two ways to describe hardware

Verilog gives you three modelling styles, and real designs mix them:

  • Dataflow — assign statements that describe combinational logic as expressions (the AND gate above).
  • Behavioural — always and initial blocks that describe what happens, leaving the synthesiser to build the gates.
  • Structural — instantiating and wiring sub-modules, the way the testbench instantiates and_gate.

Wires vs registers

Two net types trip up every beginner. A wire is driven continuously by something else (an assign or a module output). A reg holds its value until a procedural block changes it. A reg is not necessarily a hardware register — it is simply a variable that can be assigned inside always/initial. Use wire for the output of assign, and reg for anything you assign procedurally.

UseNet type
Left side of assignwire
Left side inside always/initialreg
Module output driven by assignwire (default)

▶ Try it in the ChipXpert Lab

Paste the example above, click Simulate, and watch the waveform & console output — no install, runs in your browser on open-source Icarus Verilog.

Open the Simulator →

What to read next

Continue with Verilog data types to learn the full set of nets and variables, then operators and the procedural blocks that bring a design to life.

Check yourself

Is a Verilog <code>reg</code> always a hardware flip-flop?

No. reg just means a variable you assign inside a procedural block. It becomes a flip-flop only when you assign it on a clock edge; assigned in a combinational always @(*) it is just wire-like logic.

Why must the testbench signal <code>y</code> be a <code>wire</code>?

Because y is driven by the and_gate instance (an external driver). Signals driven by another module or an assign are nets, so they must be wire. The inputs a and b are driven procedurally in the initial block, so they are reg.

Have questions about this topic?
Share your question in comments or talk to our mentor team for batch guidance.

Learn Verilog with mentors, labs and placement support

This free series is maintained by the ChipXpert training team in Hyderabad & Bengaluru. Go deeper with instructor-led courses on real EDA tools.

Explore VLSI Courses
Next batch starts 18th November 2026
Start your VLSI career with ChipXpert

Live online and classroom batches in Hyderabad & Bengaluru. Fill in your details and a counsellor will call you back.

  • Real EDA tools in your browser: industry-standard EDAReal EDA tools in your browser
  • Recorded sessions on the elearn portalRecorded sessions
  • Placement assistance: resume, mock interviewsPlacement assistance
  • Merit scholarship up to 60% · EMI optionsScholarship up to 60%
Hi! Ask me about courses, fees, batches or discounts. ×
BENGALURU
HYDERABAD