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

Electronic Engineer at Thinture Technologies Pvt. Ltd

Hello Dear Readers, Currently, at Thinture Technologies Pvt. Ltd vacancy for Electronic Engineer role. Thinture Technologies Pvt. Ltd. is a vehicle control systems manufacturer, with a primary focus on road speed limitation and GPS-based tracking systems. All of our products are designed in-house from basic circuit designing to firmware, algorithm to PCB designing, online software platforms to mechanical assembly drawings, and standard operating procedures for aftermarket usage. Role Description: This is a full-time on-site role for an Electronic Engineer located in Bengaluru. The Electronic Engineer will be responsible for the day-to-day tasks associated with electronic engineering, including electronics, electrical engineering, circuit design, testing, and more. Qualifications: Strong electronic engineering skills Sound knowledge of circuit design and electrical engineering Experience with electronics testing and quality assurance Proficient in using software tools for schematic capt

Trainee Hardware Engineer at Confident Electronics Private Limited

Hello Dear Readers, Currently, at Confident Electronics Private Limited Bangalore vacancy for a Trainee Hardware Engineer role. About the job: We are looking for an enthusiastic, passionate, and motivated hardware engineer to join the team. As a Hardware Engineer, you will be responsible for designing and developing hardware components in close collaboration with our software engineers to make sure the final product operates seamlessly. Responsibilities: Designing and building hardware Recommending new hardware designs Performing tests of new hardware and software Troubleshooting and debugging performance issues Working with vendors and hardware suppliers to implement new designs Supporting the hardware engineering team Providing technical support for hardware issues Following industry-standard processes and procedures Collaborating with other engineers Handling the assigned clients Qualifications: Minimum BE/BTech in Electronics and Communication Engineering or related field. Familiar

Product Application Intern FY23 at Analog Devices

  Hello Dear Readers, Currently, at Analog Devices Bangalore vacancy for a Product Application Intern FY23 role. Analog Devices is a leading global high-performance analog technology company dedicated to solving the toughest engineering challenges. We enable our customers to interpret the world around us by intelligently bridging the physical and digital with unmatched technologies that sense, measure, power, connect and interpret. In this job you will work with a team developing sophisticated mixed-signal system-on-chip (SoC) integrated circuits for smart power systems as well as with people who develop standard power products with Buck, Boost, and Buck-boost topologies in high voltage domains. Roles and Responsibilities: Develop system level uses to showcase the product capabilities for technology adoption Develop PoC in close collaboration with automotive OEMs and field team Develop necessary software for system level EMI/EMC Build/modify the existing stacks/device drivers/applicati