Git Product home page Git Product logo

de_subtractor's Introduction

Ex. No. 4

Date: 28.4.23

Implementation of half subtractor and full subtractor circuit using Verilog HDL

Aim :

To design and implement half subtractor and full subtractor circuit and verify its truth table.

Components Required:

  1. Laptop with Quartus software and modelsim software.

Theory:

Subtractor circuits take two binary numbers as input and subtract one binary number input from the other binary number input. Similar to adders, it gives out two outputs, difference and borrow (carry-in the case of Adder). There are two types of subtractors.

  1. Half Subtractor
  2. Full Subtractor

1. Half Subtractor

The half-subtractor is a combinational circuit which is used to perform subtraction of two bits. It has two inputs, X (minuend) and Y (subtrahend) and two outputs D (difference) and B (borrow). To perform x - y, we have to check the relative magnitudes of x and y. If x ;;, y, we have three possibilities: 0 - 0 = 0, 1 - 0 = 1, and 1 - I = 0. The result is called the difference bit. If x < y, we have 0 - I, and it is necessary to borrow a 1 from the next higher stage. The I borrowed from the next higher stage adds 2 to the minuend bit, just as in the decimal system a borrow adds 10 to a minuend digit. With the minuend equal to 2, the difference becomes 2 - I = 1. The half-subtractor needs two outputs. One output generates the difference and will be designated by the symbol D. The second output, designated B for borrow, generates the binary signal that informs the next stage that a I has been borrowed.

Truth table

image

Sum = X’Y+XY’ = X image Y
Carry=X’Y

Logic Diagram

image

2. Full Subtractor

A full subtractor is a combinational circuit that performs subtraction involving three bits, namely minuend, subtrahend, and borrow-in . It accepts three inputs: minuend, subtrahend and a borrow bit and it produces two outputs: difference and borrow.

Truth table

.image

image

Logic Diagram

image

Procedure:

  1. Type the program in Quartus software.
  2. Compile and run the program.
  3. Generate the RTL schematic and save the logic diagram.
  4. Create nodes for inputs and outputs to generate the timing diagram.
  5. For different input combinations, generate the timing diagram.

Program:

1.Half Subtractor

 module exp4a(a,b,diff,borrow);
 input a,b;
 output diff,borrow;
 wire adash;
 xor(diff,a,b);
 not(adash,a);
 and(borrow,adash,b);
 endmodule

2.Full Subtractor

 module exp4b(a,b,c,diff,borrow);
 input a,b,c;
 output diff,borrow;
 wire adash,x,p,q,r;
 xor(x,b,c);
 xor(diff,a,x);
 not(adash,a);
 and(p,adash,c);
 and(q,b,c);
 and(r,adash,b);
 or(borrow,p,q,r);
 endmodule

RTL Schematic:

1.Half Subtractor

241495345-884983d1-5f92-401c-8b6e-45e51af35b04

2.Full Subtractor

241495890-4f7721b8-1fc5-4e29-897c-ae669d7ed08a

Timing Diagram:

1.Half Subtractor Screenshot 2023-06-05 220023

2.Full Subtractor Screenshot 2023-06-05 220116

Result:

Thus the half subtractor and full subtractor circuits are designed and the truth tables are verified using Verilog HDL.

de_subtractor's People

Contributors

rvinifa avatar janarthanan2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.