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

R&D Intern (Electronics Engineering) at Greaves Electric Mobility

Hello Dear Readers, Currently, at Greaves Electric Mobility vacancy for an R&D Intern (Electronics Engineering) role. At Greaves Electric Mobility, we build products and solutions that are designed to democratize smart and sustainable mobility and do our bit to heal the Planet. Backed by the 164 year engineering legacy of Greaves, our portfolio of electric two and three wheelers are made in India at manufacturing sites across Tamil Nadu, Telangana and Uttar Pradesh. Key Responsibilities: Collaborate with experienced engineers in the research and development of electric mobility technologies. Participate in the design, prototyping, and testing of electronic and electrical systems for electric vehicles. Contribute to the analysis and improvement of automotive electrical systems, ensuring compliance with industry standards. Assist in troubleshooting and problem-solving activities related to electric vehicle components. Stay updated on the latest advancements in the electric mobility s