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
  • Toggle search form

Module Instantiation in Verilog

Posted on February 25, 2016June 17, 2025 By vlsifacts No Comments on Module Instantiation in Verilog

A module provides a template from which you can create actual objects. When a module is invoked, Verilog creates a unique object from the template. Each object has its own name, variables, parameters, and I/O interface.

The process of creating objects from a module template is called instantiation, and the objects are called instances. Each instance is a complete, independent and concurrently active copy of a module. A module can be instantiated in another module thus creating hierarchy.

Syntax:

Module_name  Instance_name (Port_Association_List)

Module instantiation consists of module_name followed by instance_name and port_association_list. Need of instance_name is, we can have multiple instance of same module in the same program. Instance name should be unique for each instance of the same module. Port_association_list shows how ports are mapped.

Let us take an example of 4-bit adder for explaining module instantiation.

Module for 1-bit adder is fulladd as shown below.

module fulladd(s, c_out, ain, bin, c_in);
   output s, c_out;
   input ain, bin, c_in;
   assign s = (ain^bin)^c_in; // sum bit
   assign c_out = (ain & bin) | (bin & c_in) |(c_in & ain); //carry bit
endmodule

The above 1-bit adder is instantiated ‘4’ times to get functionality of 4-bit adder i.e. fulladder_4bit. Each instance of full adder has different instance name and port association list.

module fulladder_4bit(sum, cout, a, b, cin);
//input output port declarations
   output [3:0] sum;
   output cout;
   input [3:0] a, b;
   input cin;
   wire c1, c2, c3;
// Instantiate four 1-bit full adders
   fulladd f0 (sum[0], c1, a[0], b[0], cin);
   fulladd f1 (sum[1], c2, a[1], b[1], c1);
   fulladd f2 (sum[2], c3, a[2], b[2], c2);
   fulladd f3 (sum[3], cout, a[3], b[3], c3);
endmodule

In the above example, 4-bit adder module is the top level module thus creating an hierarchy.

While calling a module the width of each port must be the same, eg, a 4-bit register can not be matched to a 2-bit register. This is known as port matching. Port mapping can be done in two different ways i.e. “Port mapping by order” and “Port mapping by name“.

Reference: Verilog HDL, A guide to Digital Design and Synthesis; Samir Palnitkar

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. Port Mapping for Module Instantiation in Verilog
  2. Synopsys – Interview Questions – based on Synthesis and Simulation
  3. Synthesis in VLSI
  4. Difference between $display, $monitor, $write and $strobe in Verilog
Verilog Tags:Instance, Module Instantiation, port association list, port mapping, port mapping by name, port mapping by order, port matching

Post navigation

Previous Post: Ports in Verilog Module
Next Post: Port Mapping for Module Instantiation in Verilog

Leave a Reply Cancel reply

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

Top Posts & Pages

  • ASCII Code
  • Circuit Design of a 4-bit Binary Counter Using D Flip-flops
  • NAND and NOR gate using CMOS Technology
  • AND and OR gate using CMOS Technology
  • Introduction to Digital Computer


 

Copyright © 2025 VLSIFacts.

Powered by PressBook WordPress theme

%d