Skip to main content

Gate-Level Modeling

>> Introduction
>> Gate Primitives
>> Delays
>> Examples


Introduction

In Verilog HDL a module can be defined using various levels of abstraction. There are four levels of abstraction in verilog. They are:
  • Behavioral or algorithmic level: This is the highest level of abstraction. A module can be implemented in terms of the design algorithm. The designer no need to have any knowledge of hardware implementation.
  • Data flow level: In this level the module is designed by specifying the data flow. Designer must how data flows between various registers of the design.
  • Gate level: The module is implemented in terms of logic gates and interconnections between these gates. Designer should know the gate-level diagram of the design.
  • Switch level: This is the lowest level of abstraction. The design is implemented using switches/transistors. Designer requires the knowledge of switch-level implementation details.
Gate-level modeling is virtually the lowest-level of abstraction, because the switch-level abstraction is rarely used. In general, gate-level modeling is used for implementing lowest level modules in a design like, full-adder, multiplexers, etc. Verilog HDL has gate primitives for all basic gates.

Gate Primitives

Gate primitives are predefined in Verilog, which are ready to use. They are instantiated like modules. There are two classes of gate primitives: Multiple input gate primitives and Single input gate primitives.
Multiple input gate primitives include and, nand, or, nor, xor, and xnor. These can have multiple inputs and a single output. They are instantiated as follows:

// Two input AND gate.
and and_1 (out, in0, in1);

// Three input NAND gate.
nand nand_1 (out, in0, in1, in2);

// Two input OR gate.
or or_1 (out, in0, in1);

// Four input NOR gate.
nor nor_1 (out, in0, in1, in2, in3);

// Five input XOR gate.
xor xor_1 (out, in0, in1, in2, in3, in4);

// Two input XNOR gate.
xnor and_1 (out, in0, in1);

Note that instance name is not mandatory for gate primitive instantiation. The truth tables of multiple input gate primitives are as follows:


Single input gate primitives include not, buf, notif1, bufif1, notif0, and bufif0. These have a single input and one or more outputs. Gate primitives notif1, bufif1, notif0, and bufif0 have a control signal. The gates propagate if only control signal is asserted, else the output will be high impedance state (z). They are instantiated as follows:

// Inverting gate.
not not_1 (out, in);

// Two output buffer gate.
buf buf_1 (out0, out1, in);

// Single output Inverting gate with active-high control signal.
notif1 notif1_1 (out, in, ctrl);

// Double output buffer gate with active-high control signal.
bufif1 bufif1_1 (out0, out1, in, ctrl);

// Single output Inverting gate with active-low control signal.
notif0 notif0_1 (out, in, ctrl);

// Single output buffer gate with active-low control signal.
bufif0 bufif1_0 (out, in, ctrl);

The truth tables are as follows:


Array of Instances:

wire [3:0] out, in0, in1;
and and_array[3:0] (out, in0, in1);

The above statement is equivalent to following bunch of statements:

and and_array0 (out[0], in0[0], in1[0]);
and and_array1 (out[1], in0[1], in1[1]);

and and_array2 (out[2], in0[2], in1[2]);
and and_array3 (out[3], in0[3], in1[3]);


>> Examples

Gate Delays:

In Verilog, a designer can specify the gate delays in a gate primitive instance. This helps the designer to get a real time behavior of the logic circuit.

Rise delay
: It is equal to the time taken by a gate output transition to 1, from another value 0, x, or z.

Fall delay
: It is equal to the time taken by a gate output transition to 0, from another value 1, x, or z.

Turn-off delay
: It is equal to the time taken by a gate output transition to high impedance state, from another value 1, x, or z.
  • If the gate output changes to x, the minimum of the three delays is considered.
  • If only one delay is specified, it is used for all delays.
  • If two values are specified, they are considered as rise, and fall delays.
  • If three values are specified, they are considered as rise, fall, and turn-off delays.
  • The default value of all delays is zero.
and #(5) and_1 (out, in0, in1);
// All delay values are 5 time units.

nand #(3,4,5) nand_1 (out, in0, in1);
// rise delay = 3, fall delay = 4, and turn-off delay = 5.

or #(3,4) or_1 (out, in0, in1);
// rise delay = 3, fall delay = 4, and turn-off delay = min(3,4) = 3.

There is another way of specifying delay times in verilog, Min:Typ:Max values for each delay. This helps designer to have a much better real time experience of design simulation, as in real time logic circuits the delays are not constant. The user can choose one of the delay values using +maxdelays, +typdelays, and +mindelays at run time. The typical value is the default value.

and #(4:5:6) and_1 (out, in0, in1);
// For all delay values: Min=4, Typ=5, Max=6.

nand #(3:4:5,4:5:6,5:6:7) nand_1 (out, in0, in1);
// rise delay: Min=3, Typ=4, Max=5, fall delay: Min=4, Typ=5, Max=6, turn-off delay: Min=5, Typ=6, Max=7.


In the above example, if the designer chooses typical values, then rise delay = 4, fall delay = 5, turn-off delay = 6.

Examples:

1. Gate level modeling of a 4x1 multiplexer.

The gate-level circuit diagram of 4x1 mux is shown below. It is used to write a module for 4x1 mux.


module 4x1_mux (out, in0, in1, in2, in3, s0, s1);

// port declarations
output out; // Output port.
input in0, in1, in2. in3; // Input ports.
input s0, s1; // Input ports: select lines.

// intermediate wires
wire inv0, inv1; // Inverter outputs.
wire a0, a1, a2, a3; // AND gates outputs.

// Inverters.
not not_0 (inv0, s0);
not not_1 (inv1, s1);

// 3-input AND gates.
and and_0 (a0, in0, inv0, inv1);
and and_1 (a1, in1, inv0, s1);
and and_2 (a2, in2, s0, inv1);
and and_3 (a3, in3, s0, s1);

// 4-input OR gate.
or or_0 (out, a0, a1, a2, a3);

endmodule

2. Implementation of a full adder using half adders.

Half adder:



module half_adder (sum, carry, in0, in1);

output sum, carry;
input in0, in1;

// 2-input XOR gate.
xor xor_1 (sum, in0, in1);

// 2-input AND gate.
and and_1 (carry, in0, in1);

endmodule

Full adder:


module full_adder (sum, c_out, ino, in1, c_in);

output sum, c_out;
input in0, in1, c_in;

wire s0, c0, c1;

// Half adder : port connecting by order.
half_adder ha_0 (s0, c0, in0, in1);

// Half adder : port connecting by name.
half_adder ha_1 (.sum(sum),
.in0(s0),
.in1(c_in),
.carry(c1));

// 2-input XOR gate, to get c_out.
xor xor_1 (c_out, c0, c1);

endmodule



<< Previous Home  Next >>   

 

Comments

Unknown said…
These are useful information about Gates.I really Greetings to you for share these info...
Top 10 Interior Designers in Chennai
Top Interior Design Companies in Chennai

Derrick Corea said…
Thank you very much for this blog provided was very helpful information and well appreciated.
electronics design services
Anonymous said…
You can also look into the Free Tutorials and Learn about the differences between ASIC & FPGA, usage of FPGA's for prototyping mobile SoC architecture, Moore's law and many important concepts in this latest video of the series - ASIC vs FPGA
https://www.youtube.com/channel/UCu19H6thv_ad_Sl2cG-t-jA
Rigid Box said…
Thanks for sharing this wonderful blog. Helpful article ! Kindly visit us @ Chocolate gift box
Aishwarya said…
This idea is mind blowing. I think everyone should know such information like you have described on this post. Thank you for sharing this explanation.Your final conclusion was good. We are sowing seeds and need to be patiently wait till it blossoms.
Property Management Software in india
Property Management Software in Chennai
Lead Management Software in India
Lead Management Software in Chennai
legal management software in india
legal management software in Chennai
Unknown said…

I enjoyed over read your blog post. Your blog have nice information, I got good ideas from this amazing blog. I am always searching like this type blog post. I hope I will see again.
Deer Hunting Tips Camping Trips Guide DEER HUNTING TIPS travel touring tips

Unknown said…

Thanks for sharing the information. It is very useful for my future. keep sharing
Still Hunting Method
Hunting psych tips Survival Tips Travel Touring Tips
Unknown said…

Very enjoyable to visit this blog and find something exciting and amazing.
travel trekking tips
see the link Tent Camping 101 Exploring Smithriver

jayapriya said…
Awesome..You have clearly explained …Its very useful for me to know about new things..Keep on blogging..

Tableau online training
gowsalya said…
It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command
msbi online training
rithiaanandh said…
A good blog always comes-up with new and exciting information and while reading I have felt that this blog really has all those quality that qualify a blog to be a one. I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts read this.
Sql server dba online training
jothikumar said…
Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
Devops training in chennai
jothikumar said…
Nice post. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated posts…
Selenium training in Chennai | Devops online training
pragyachitra said…
This is a terrific article, and that I would really like additional info if you have got any. I’m fascinated with this subject and your post has been one among the simplest I actually have read.
Docker online training
Docker certification training
Docker online course
Docker training course
saher said…
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
Pooja room interior desingers in chennai
Hotel Interior desingers in chennai
Hospital interior designers in chennai
afibiz said…
This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
Office interior designers in chennai
living room interior designers in chennai
False ceiling interiors designers in chennai


This post is really nice and informative. The explanation given is really comprehensive and informative. I want to share some information about the best oracle dba training and weblogic server tutorial training videos. Thank you .Hoping more articles from you.
afiaa said…
Awesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
interior designers in chennai
electronics said…
https://gatelevelmodeling.blogspot.com/2021/01/error-during-simulation-vwfwave-form.html
electronics said…
https://gatelevelmodeling.blogspot.com/2021/01/error-during-simulation-vwfwave-form.html
This comment has been removed by the author.
Anonymous said…
Microhard Infotech software stores, tracks, controls, and handles products in a logistics or warehouse facility. The fact that managing the supply chain effectively is difficult without automation has led rise to the rapid use of this software for daily operations.

The best-in-class inventory management software Dubai from Microhard Infotech provides the data you need to ship orders on budget and time and supports the customers’ business needs. But what is inventory management? And what can you expect from such software? Well, let’s find out.

Contact Microhard Infotech UAE:
Location: 303 Le Solarium, Dubai Silicon Oasis, Dubai, UAE
Tel: +971 4 320 8308
+971 55 954 1228
email: sales@microhard.ae
A Low Code Mobile App Development Platform acts as a game-changer for your company. Some Key features of FourNxt’s Low Code Mobile App Development Platform are given below:

Out-of-the-box functionality
Visual Modeling Tools
Reporting and monitoring
Scalability
Reusability
Drag-and-Drop Interfaces
Security
Cross-Platform Accessibility

This is how FourNxt meets critical enterprise app development and deployment requirements. Every segment of our work is crucial in graphic designing or implementation of different ideal features.

Contact FourNxt:

Email: info@fournxt.com
Phone Number: +971 50 8602393
+91 95674 11011

Twitter: https://twitter.com/fournxt
Facebook: https://www.facebook.com/FourNxtTech/
Linkedin: https://www.linkedin.com/company/fournxt/
What as up, I read your blogs like every week. Your writing style is awesome, keep up the good work!
OSB Training
<a href="https://viswaonlinetrainings.com/courses/application-packaging-training/>Application Packaging Training</a>

Popular posts from this blog

Digital Design Interview Questions - All in 1

1. How do you convert a XOR gate into a buffer and a inverter (Use only one XOR gate for each)? Answer 2. Implement an 2-input AND gate using a 2x1 mux. Answer 3. What is a multiplexer? Answer A multiplexer is a combinational circuit which selects one of many input signals and directs to the only output. 4. What is a ring counter? Answer A ring counter is a type of counter composed of a circular shift register. The output of the last shift register is fed to the input of the first register. For example, in a 4-register counter, with initial register values of 1100, the repeating pattern is: 1100, 0110, 0011, 1001, 1100, so on. 5. Compare and Contrast Synchronous and Asynchronous reset. Answer Synchronous reset logic will synthesize to smaller flip-flops, particularly if the reset is gated with the logic generating the d-input. But in such a case, the combinational logic gate count grows, so the overall gate count savings may not be that significant. The clock works as a filter for sma

XMR: Cross Module Reference

Cross Module Reference   Cross Module Reference abbreviated as XMR is a very useful concept in Verilog HDL (as well as system Verilog). However it seems to be less known among many users of Verilog. XMR is a mechanism built into Verilog to globally reference (i.e., across the modules) to any nets, tasks, functions etc. Using XMR, one can refer to any object of a module in any other module, irrespective of whether they are present below or above its hierarchy. Hence, a XMR can be a:   Downward reference OR Upward reference   Consider the following hierarchy:     Module A   Net x   Instance P of Module B     Net x   Instance M of Module D   Net x   Instance Q of Module C   Net x   Instance N of Module E    Net x   Instance R of Module B   Net x   Instance M of Module D   Net x     In test bench:   Instance top of Module A   In the above scenario, there is a

Synchronous Reset vs. Asynchronous Reset

Why Reset? A Reset is required to initialize a hardware design for system operation and to force an ASIC into a known state for simulation. A reset simply changes the state of the device/design/ASIC to a user/designer defined state. There are two types of reset, what are they? As you can guess them, they are Synchronous reset and Asynchronous reset. Synchronous Reset A synchronous reset signal will only affect or reset the state of the flip-flop on the active edge of the clock. The reset signal is applied as is any other input to the state machine. Advantages: The advantage to this type of topology is that the reset presented to all functional flip-flops is fully synchronous to the clock and will always meet the reset recovery time. Synchronous reset logic will synthesize to smaller flip-flops, particularly if the reset is gated with the logic generating the d-input. But in such a case, the combinational logic gate count grows, so the overall gate count savings may not be