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

Port Mapping for Module Instantiation in Verilog

Posted on February 25, 2016May 18, 2025 By vlsifacts No Comments on Port Mapping for Module Instantiation in Verilog

Port mapping in module instantiation can be done in two different ways:

  • Port mapping by order
  • Port mapping by name

In this post, we would take one example to understand both types of port mapping in detail.

Synchro for Instantiation
Example for Module Port Mapping

The above Figure shows an example for module instantiation. Figure shows module “SYNCHRO” which consists of 2 ‘D’ flip-flops and are connected in serial fashion. Module “SYNCHRO” has 2 input ports “ASYNC” and “CLOCK” and 1 output port “SYNC”.

Verilog Programming for DFF instantiated in the SYNCHRO module:

module DFF (Q, D, CLK);
  input D, CLK;
  output reg Q;
  always @ (posedge CLK)
    Q <= D;
endmodule

MODULE PORT MAPPING BY ORDER

module SYNCHRO (ASYNC,SYNC,CLOCK);
  input ASYNC;
  input CLOCK;
  output SYNC;

  wire C1_ASYNC;

  DFF DFF1 (C1_ASYNC, ASYNC, CLOCK);
  DFF DFF2 (SYNC, C1_ASYNC, CLOCK);

  //Check what happens when you would replace the above two lines with the below two lines
  //DFF DFF1 (ASYNC, C1_ASYNC, CLOCK);
  //DFF DFF2 (SYNC, C1_ASYNC, CLOCK);

endmodule

Here first instance name of ‘D’ flip-flop is “DFF1” and second instance name is “DFF2”. In this module ports are connected by order. Order of ports in instantiation of DFF1 and DFF2 is same as order of ports in DFF. If the number of ports increased, then it is very difficult to do “module ports connection by order”.

MODULE PORT MAPPING BY NAME

Module SYNCHRO (ASYNC, SYNC, CLOCK);
  input ASYNC;
  input CLOCK;
  output SYNC;

  wire C1_ASYNC;

  DFF DFF1 (.D (ASYNC), .CLK (CLOCK), .Q (C1_ASYNC));
  DFF DFF2 (.D (C1_ASYNC), .Q (SYNC), .CLK (CLOCK)); 

endmodule

In this module, ports are connected by Name. Order of ports in instantiation of DFF1 and DFF2 is different from order of ports in DFF. In this ‘.’ is used to represent port name followed by associated port name in small brackets i.e. “()”. Advantage of using “port connection by name” is, it is easy to port map for large number of ports in a design.

Tip: Always connect ports by name to avoid any error.

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. Module Instantiation in Verilog
  2. Case and Conditional Statements Synthesis CAUTION !!!
  3. Module Definition in Verilog
  4. Delay in Assignment (#) in Verilog
Verilog Tags:Module Instantiation, port mapping, port mapping by name, port mapping by order

Post navigation

Previous Post: Module Instantiation in Verilog
Next Post: Why VLSI?

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
  • Port Mapping for Module Instantiation in Verilog


 

Copyright © 2025 VLSIFacts.

Powered by PressBook WordPress theme

%d