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 ...

Engineer II - Analog Design Engineering at Microchip

Hello Dear Readers,   Currently at Microchip  vacancy for Engineer II - Analog Design Engineering role. Job Description: The Mixed Signal Development Group is responsible for delivering analog, digital and mixed-signal IP to divisions within Microchip. We work with leading edge CMOS processes to produce analog integrated circuits for wireline applications. From 112Gb/s+ SERDES to high-speed FEC engines, we enable technology that allows Microchip’s products to interface to the outside world.  Job Descriptions: As a member of the Mixed-Signal Development Group, the candidate will be supervised by a team leader/manager, and be engaged in the design of SERDES/DSP blocks, and other high-speed Digital Signal Processing blocks. This will involve taking a design from initial concept to production form. Throughout you will be mentored and coached by experienced engineers and be exposed to Microchip's Best-In-Class engineering practices. Job Responsibilities: Ramping up o...

Analog Design Engineer II at onsemi

Hello Dear Readers,   Currently at onsemi  vacancy for  Analog Design  Engineer II role. JOB DESCRIPTION: An analog design engineer is expected to quickly take an analog design block through all phases of the development process, including design, simulation, and supervision of the layout/verification processes and evaluation/debug of silicon samples. A Senior Analog IC Design Engineer will be responsible for individual block designs using CMOS process. That person will work with the latest Cadence analogue design tools (Virtuoso Composer, Verilog) Spectre and appropriate PC-based tools (MATLAB). The nature of the circuits is Mixed Signal involving blocks such as switched capacitor amplifiers, data converters, charge pumps, references, voltage buffers, IO circuits and digital building blocks. QUALIFICATIONS: Analog engineer is expected to have PhD (no experience) or master’s degree in field of Electrical Engineering/VLSI/Electronics with 0-2 years of experience and w...