Skip to content

VLSIFacts

Let's Program the Transistors

  • Home
  • DHD
    • Digital Electronics
    • Fault Tolerant System Design
    • TLM
    • Verification
    • Verilog
    • VHDL
    • Xilinx
  • Embedded System
    • 8085 uP
    • 8086 uP
    • 8051 uC
  • VLSI Technology
    • Analog Electronics
    • Memory Devices
    • VLSI Circuits
  • Interview
    • Interview Experience
    • Training Experience
    • Question Bank
  • Notifications
  • QUIZ
  • Community
  • Job Board
  • Contact Us

Module Definition in Verilog

Posted on February 21, 2016June 17, 2025 By vlsifacts 2 Comments on Module Definition in Verilog

A “module” is the basic building block in Verilog. A module can be an element or a collection of lower-level design blocks. A module provides the necessary functionality to the higher-level block through its port interface (inputs and outputs), but hides the internal implementation. Module interface refers, how module communicates with external world. This communication is possible through different ports such as input, output and bi-directional (inout) ports.Design functionality is implemented inside module, after port declaration. The design functionality

In Verilog, a module is declared by the keyword module. A corresponding keyword endmodule must appear at the end of the module definition. Each module must have a module_name, which is the identifier for the module, and a port list, which describes the input and output terminals of the module. Design functionality is implemented inside module, after port declaration. The design functionality implementation part is represented as ā€œbodyā€ here.

Module Definition
Module definition: A module is enclosed between module and endmodule keywords. Also, the name of the module and a semicolon are mandatory. Module definitions can not be nested.
Interface: It consists of up to three optional elements: port list enclosed in brackets, port declarations for each port from the port list and parameter declarations. The interface must be declared before the module body.
Add-on: Any additional specifications can be inserted into the code using ‘include compiler directive with the file name enclosed in double quotes – one directive per file. The ‘include directive can be used anywhere in the code.
Module body: The five elements of the body specification can be used in any sequence with only one restriction – no item can be used before it is declared.
Module XYZ
module XYZ (en, data, all_zero, result, status); // XYZ is the module name 
   input en; // scalar input 
   input [3:0] data; // vector input 
   output all_zero; // scalar output 
   output [3:0] result; // vector output 
   inout [1:0] status; // bi-directional port 
endmodule
  • To make code easy to read, use self-explanatory port names.
  • For the purpose of conciseness, use short port names.
  • If port is vector, we can represent it in ‘2’ different ways. For output port “result” we can represent it as [3:0] or [0:3]

The module name

The module name, formally called an identifier should best describe what the system is doing. Each identifier in Verilog, including module names must follow these rules:

  • It can be composed of letters, digits, dollar sign ($), and underscore characters (_) only.
  • It must start with a letter or underscore.
  • No spaces are allowed inside an identifier.
  • Upper and lower case characters are distinguished (Verilog is case sensitive)
  • Reserved keywords cannot be used as identifiers.

Ex: Counter_4Bit, ALU, Receiver, UART_Transmit

Spread the Word

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to email a link to a friend (Opens in new window) Email
  • Click to print (Opens in new window) Print

Like this:

Like Loading...

Related posts:

  1. Ports in Verilog Module
  2. Verilog vs VHDL
  3. Case and Conditional Statements Synthesis CAUTION !!!
  4. Synopsys – Interview Questions – based on Synthesis and Simulation
Verilog Tags:Interface, Module, Port, Verilog

Post navigation

Previous Post: State Equivalence & Minimization Part – 2
Next Post: Ports in Verilog Module

Comments (2) on “Module Definition in Verilog”

  1. Muralikrishna says:
    February 22, 2019 at 6:36 pm

    Why we use module in verilog ? Why other ?

    Reply
    1. Sidhartha says:
      February 23, 2019 at 7:41 am

      Module creates the skeleton of a design. It assigns a name to your design and declares what will be the interfaces of the design.
      Interface decides how the design would be connected to the external world. That means what will be the inputs to the design and what will be the outputs.
      Add-ons are optional.
      Module body describes the design. That means it would explain how your design would function.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Top Posts & Pages

  • ASCII Code
  • Different Coding Styles of Verilog Language
  • Truth Tables, Characteristic Equations and Excitation Tables of Different Flipflops
  • Circuit Design of a 4-bit Binary Counter Using D Flip-flops
  • NAND and NOR gate using CMOS Technology

Copyright © 2025 VLSIFacts.

Powered by PressBook WordPress theme

Subscribe to Our Newsletter

%d