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

Different Coding Styles of Verilog Language

Posted on January 31, 2016June 16, 2025 By vlsifacts 4 Comments on Different Coding Styles of Verilog Language

Verilog language has the capability of designing a module in several coding styles. Depending on the needs of a design, internals of each module can be defined at four level of abstractions. Irrespective of the internal abstraction level, the module would behave exactly in the similar way to the external environment. Following are the four different levels of abstraction which can be described by four different coding styles of Verilog language:

  1. Behavioral or Algorithmic level
  2. Dataflow level
  3. Gate level or Structural level
  4. Switch level

The order of abstraction mentioned above are from highest to lowest level of abstraction. The top three would be explained using a 4:1 mux.

4to1 Mux

Behavioral or Algorithmic level

  • This is the highest level of abstraction provided by Verilog HDL.
  • A module can be implemented in terms of the desired design algorithm without concern for the hardware implementation details.
  • It specifies the circuit in terms of its expected behavior.
  • It is the closest to a natural language description of the circuit functionality, but also the most difficult to synthesize.
Mux behavioral
Mux 4:1 Behavioral Model
module Mux_4to1(
   input [3:0] i,
   input [1:0] s,
   output reg o
);

always @(s or i)
begin
   case (s)
      2'b00 : o = i[0];
      2'b01 : o = i[1];
      2'b10 : o = i[2];
      2'b11 : o = i[3];
      default : o = 1'bx;
   endcase
end
endmodule

The output port is declared as data type “reg”. Combination of “always” block and “case” procedural statement is used to implement the multiplexer. All inputs are added as part of the sensitivity list. Select signal “s” is used as condition here. Based on value of select signal “s”, any one of the input signal will be selected. Here we are implementing the functionality of multiplexer at higher-level of abstraction without looking into internal details of the design as in “Structural Modeling”

Simulation Result of 4:1 Mux Behavioral level model:

Mux_beh_result

Dataflow level

  • At this level, the module is designed by specifying the data flow.
  • Looking towards this design, one can realize how data flows between hardware registers and how the data is processed in the design.
  • This style is similar to logical equations. The specification is comprised of expressions made up of input signals and assigned to outputs.
  • In most cases, such an approach can be quite easily translated into a structure and then implemented.
Mux 4:1 Dataflow Model
Mux 4:1 Dataflow Model
module Mux_4to1_df(
input [3:0] i,
input [1:0] s,
output o
);

assign o = (~s[1] & ~s[0] & i[0]) | (~s[1] & s[0] & i[1]) | (s[1] & ~s[0] & i[2]) | (s[1] & s[0] & i[3]);
endmodule

In this approach “assign” statement is used. Assign statement is a continuous statement where in any changes in signals on right hand side will update the output signal. Any changes in the input signals will execute the assign statement and the updated value will be reflected on the output “o”. Changes in the inputs are continuously monitored.

Simulation Result of 4:1 Mux Dataflow level model:

Mux_df_result

Gate level or Structural level

  • The module is implemented in terms of logic gates and interconnections between these gates.
  • It resembles a schematic drawing with components connected with signals.
  • A change in the value of any input signal of a component activates the component. If two or more components are activated concurrently, they will perform their actions concurrently as well.
  • A structural system representation is closer to the physical implementation than behavioral one but it is more involved because of large number of details. Since logic gate is most popular component, Verilog has a predefined set of logic gates known as primitives. Any digital circuit can be built from these primitives.
Mux structural
Mux 4:1 Structural Model
module Mux_4to1_gate(
input [3:0] i,
input [1:0] s,
output o
);

wire NS0, NS1;
wire Y0, Y1, Y2, Y3;
not N1(NS0, s[0]);
not N2(NS1, s[1]);
and A1(Y0, i[0], NS1, NS0);
and A2(Y1, i[1], NS1, s[0]);
and A3(Y2, i[2], s[1], NS0);
and A4(Y3, i[3], s[1], s[0]);
or O1(o, Y0, Y1, Y2, Y3);
endmodule

In this approach, the multiplexer is represented in gate-level representation. It consists of ‘4’ AND gates, ‘2’ NOT gates and ‘1’ OR gate. Intermediate signals “NS1”, “NS0”, “Y3”, “Y2”, “Y1”, and “Y0” are declared as wires. In this AND, OR and NOT gates are basic Verilog inbuilt primitives. These primitives are instantiated and connected in such a way, to get the functionality of multiplexer. This type of modeling of multiplexer is known as “Structural Modeling”. In this internal details of the circuit are known to model it.

Simulation Result of 4:1 Mux Gate level model:

Mux_gate_level_result

Switch level

  • This is the lowest level of abstraction provided by Verilog.
  • A module can be implemented in terms of transistors, switches, storage nodes, and the interconnections between them.
  • In Verilog HDL transistors are known as Switches that can either conduct or open.
  • Design at this level requires knowledge of switch-level implementation details.

Verilog supports design that can be represented in different modeling levels. Describing the design at different levels is known as Mixed-level Modeling. Simulating the design consisting of different modeling levels is known as Mixed-level Simulation.

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. Synthesis and Functioning of Blocking and Non-Blocking Assignments.
  2. Power Analysis in XILINX Xpower Analyzer
  3. Synopsys – Interview Questions – based on Synthesis and Simulation
  4. Synthesis in VLSI
DHD, Verilog, Xilinx Tags:4:1 Mux, Behavioral level, Dataflow level, Gate level, Switch level, Verilog Coding Stules, Xilinx ISE

Post navigation

Previous Post: Aricent Technologies – Technical Interviews Question Bank – Part 7
Next Post: Mealy Vs. Moore Machine

Comments (4) on “Different Coding Styles of Verilog Language”

  1. shivkumar singh says:
    December 19, 2017 at 8:33 am

    This post is very informative which help in learning about Different Coding Styles of Verilog Language.
    Thanks for sharing

    Reply
  2. Pallvi says:
    December 22, 2017 at 9:44 am

    module instantiation is possible in behavioural modelling or not?

    Reply
    1. Sidhartha says:
      December 22, 2017 at 3:43 pm

      Module instantiation is not possible inside the behavioral block.

      Reply
  3. sharon maxwell says:
    April 5, 2018 at 9:15 am

    Nice Post !! Thanks for sharing !!

    Reply

Leave a Reply to sharon maxwell 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
  • Difference between $display, $monitor, $write and $strobe in Verilog


 

Copyright © 2025 VLSIFacts.

Powered by PressBook WordPress theme

%d