Verilog is a Hardware Description Language (HDL) used to describe and program digital logic circuits. It allows hardware designers to model systems at various levels of abstraction, enabling system simulation and synthesis.

There are two general styles of describing hardware in Verilog:

Structural Modeling

A structural model defines hardware as an interconnection of various modules and primitives.

For example:

and my_and (
  .out(z),
  .a(x),
  .b(y)
);

Here we instantiate an AND gate primitive and connect the ports.

In this style the focus is on the actual digital logic components and connectivity rather than just the behavior.

Most designs employ a mix of behavioral and structural modeling to take advantage of these complementary styles. Verilog gives the designer flexibility to use the right style at each level of abstraction.

Behavioral Modeling

A behavioral model focuses on the functionality and operation of a circuit rather than its actual implementation.

For example, we can describe a simple AND gate behaviorally using an always block:

always @(*) begin
  z = x & y; 
end

This models the logic function without specifying gates or components.

Modeling Constructs

Verilog provides two key modeling constructs that enable both behavioral and structural design:

Continuous Assignments

A continuous assignment drives a net or variable using a combinational expression:

assign out = a & b;

This models combinational logic that updates out continuously based on the current value of a and b.

Always Blocks

An always block describes sequential or registered logic:

always @(posedge clk) begin
  q <= d;
end

This models a flip-flop that samples d on the positive clock edge to update output q.

By combining continuous assignments and always blocks, we can model complex digital hardware spanning combinational logic, sequential elements, and clocked state machines.

These core modeling capabilities enable Verilog to describe hardware at multiple levels, ranging from basic gates to complete systems.


References