Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Industrial programming >> Verilog

Verilog Essentials: A Concise Overview

All behavioral code is written inside module and endmodule. So, whatever digital design that you intend to create, it'll go inside a module block. It may or may not have ports defined - allow signals to enter the block as input or escape the block as output.

Module

The empty module in the example below is called testbench. You can name it whatever you like, except that it should be alphanumeric, and can contain '_'.

  
  
module testbench;

endmodule

  

Let's look at another module. It has a few signals (d, clk, rstb) declared as inputs and q declared as an output.

  
  
module dff (input d,
                  clk,
                  rstb,
            output q);
endmodule

  

Data Types

Now that we have seen how a module looks like, let's see what can be put inside a module, by looking at the testbench module once again. There are primarily two types of datatypes in verilog :

A reg datatype is used to hold onto values like a variable, while a wire is just analogous to an electrical wire, that has to be driven continuously. So typically wire is used to connect between multiple modules, and other signals.

  
  
module testbench;
	
	reg d;
	reg rst_b;
	reg clk;
	
	wire q;
endmodule

  

Assignments

Verilog has three basic blocks :

always @ (condition) always executed when the condition is satisfied
initial will be executed only once, when the simulation begins
assign [LHS] = [RHS] Value of LHS will be updated whenever RHS changes

There are a few rules to keep in mind when writing Verilog:

  
  
module testbench;
	
	reg d;
	reg rst_b;
	reg clk;
	
	wire q;
	
	initial begin
		d = 0;
		rst_b = 0;
		clk = 0;
		
		#100 $finish;
	end
	
	always begin
		#10 clk = ~clk;
	end
endmodule

  

Note the following from the example shown above:


Verilog

  1. Verilog Basics: Designing Your First AND Gate
  2. Verilog Module Basics: Structure & Syntax
  3. Mastering Verilog Module Instantiation: Best Practices for Hierarchical Design
  4. Mastering Verilog Concatenation: A Practical Guide
  5. Understanding Verilog Always Blocks: Syntax & Sensitivity Lists
  6. Verilog Initial Blocks: Purpose, Syntax, and Non‑Synthesizable Use
  7. Mastering Verilog Generate Blocks: Dynamic Module Instantiation & Conditional Design
  8. Mastering Verilog Block Statements: Sequential & Parallel Execution
  9. Mastering Verilog Parameters: Build Reusable, Scalable Modules
  10. Mastering Verilog's Hierarchical Reference Scope: Avoid Name Collisions in Modules and Blocks