Skip to main content

Half Adder And Full Adder in All Level Of Abstraction Verilog Code

Hello Dear Reader,


Fig.1



Here given Fig.1 is one bit half adder in the lowest level of the abstration diagram is there as similarly we know their are two ways to designed one bit full adder either using two half adder and one or gate or designed using their separate boolean expression As shown in below Fig.2 and Fig.3.

Fig.2

   
Fig.3

Here in below section i have provided verilog code at all the levels of the digital system design such as Behavioural Level, Data or RTL Level, Structural Level.

Half-Adder:

1) Behavioural Level Verilog Code:

module half_adder(a,b,c,s
    );// behavioural model
input a,b;
output reg c,s;
always@(a,b)
begin
if((a&&~b)||(~a&&b))
s=1;
else
s=0;
if(a&&b)
c=1;
else
c=0;
end
endmodule

2) RTL or Data Flow Level Verilog Code:

module half_adder(a,b,c,s
    );// Dataflow level model
input a,b;
output c,s;
assign s=((a&&~b)||(~a&&b));
assign c=(a&&b);
endmodule

3) Structural Level Verilog Code: 

module half_adder(a,b,c,s
    );// Structural level model
input a,b;
output c,s;
wire w1,w2;
and g1(w1,~a,b);
and g2(w2,a,~b);
or g3(s,w1,w2);
and g4(c,a,b);
endmodule

RTL Viewer:

Fig.4

Simulational Result:


Full-Adder:

1) Behavioural Level Verilog Code:

module full_adder(a,b,cin,s,c
    );//behavioural level model
input a,b,cin;
output reg s,c;
always@(a,b,cin)
begin
s=a^b^cin;
c= (a&&b )||((a^b)&&cin);
end
endmodule

2) RTL or Data Flow Level Verilog Code:

module full_adder(a,b,cin,s,c
    );//Dataflow level model
input a,b,cin;
output s,c;
assign s=(a^b^cin);
assign c=((a&&b )||((a^b)&&cin));
endmodule

3) Structural Level Verilog Code: 

module full_adder(a,b,cin,s,c
    );//structural level model
input a,b,cin;
output s,c;
wire w1,w2,w3;
xor g1(w1,a,b);
and g2(w2,a,b);
and g3(w3,cin,w1);
xor g4(s,w1,cin);
or g5(c,w2,w3);
endmodule

4) Full Adder using Half Adder As Instance Model: 

module full_adder(a,b,cin,sum,carry);//structural level model
               input a,b,cin;
               output sum,carry;
               half_adder p1(a,b,c1,s);
               half_adder p2(s,cin,c2,sum);
               or g1(carry,c1,c2);
               endmodule

RTL Viewer:


Simulational Result:


Now Thank the reader for this post and I hope it might be helpful and give your suggestions in the comment box I will try to improve my side.



Comments

  1. I like this sir but please upload some more code by example. I personally like your articles.

    ReplyDelete
  2. Sure I Will do In short time around December end.

    ReplyDelete
  3. Yes Sir I am from Punjab I like your content and most waiting for Verilog more example code.

    ReplyDelete
  4. Good article for all level of code thanks sir🙌🙌🙌🙌

    ReplyDelete
  5. Good write some more complex problems code so it is better.

    ReplyDelete
  6. Good starting brother keep it up 👍👍👍👌👌👌

    ReplyDelete
  7. Are you writing Specifically VLSI Field related then share site. I like your technical articles

    ReplyDelete
  8. I am doing M. Tech In VLSI and yes I have my own site specifically for VLSI field checkout this link https://geniusvlsi.blogspot.com/

    ReplyDelete

Post a Comment

Popular posts from this blog

Design Engineer at Infineon Bangalore

  Hello Dear Readers, Currently at Infineon Bangalore vacancy for the Design Engineer role. Design analog and mixed-signal modules in CMOS and Smart PowerTechnologies, with a particular focus on achieving high-efficiency power conversion for applications using GaN devices; In your new role you will: Design analog and mixed-signal modules  in CMOS and Smart PowerTechnologies, with a particular focus on achieving high-efficiency power conversion for applications using GaN devices; Design and verify pre-silicon analog/mixed-signal integrated circuit blocks, including incorporating features for testing and quality assurance, and providing support for top-level integration; Assist in defining the requirements  for analog and mixed-signal blocks,aligning them with IP Module architecture, and ensuring compliance with requirements through documentation; Estimate effort and planning design work packages to meet project milestones; Provide essential support to physical design ...

WXtoIMG 2018 Pro Upgrade Keys & Software Download

hello, friends good news for all the NOAA hobbies to upgrade your software with full functionality with keys, I have given below that keys try to use it and enjoy the upgrade version of the WxToImg software. Below are the upgrade keys for the 2018 edition of the WxToimg that is used to decode the polar orbiting NOAA weather satellite images by individuals at home. Unfortunately, the original site mentioned on the Main WXtoImg Post is no longer available but an archive copy of the WXtoIMG software for windows can be downloaded from Web.Archive.org (Version 2.10.11) and activated with the professional keys below. Professional Edition Upgrade Key Full Name: Kevin Schuchmann Email Address: your email address Upgrade Key: CGHZ-PP9G-EAJZ-AWKK-NDNX  

Tutorial on EasyEDA desktop software for PCB and schematic design

In this article, I am going to write a tutorial on how to use EasyEDA desktop application for creating a schematic and for PCB design. One of best advantage of this software is that you can create design offline and can automatically synchronize your design with your online EasyEDA account.  It can be used for circuits simulation, PCB deign and electronics circuits design. You can download EasyEDA desktop application by clicking on following link and it will work on windows 7 or its greater version. They are also releasing soon offline application OSX and Linux users. So keep visiting their website for more information.                                                    https://easyeda.com/page/download So let’s start and see how to design a schematic and PCB using EasyEDA offline desktop application. So first of all lets see how to create a schema...