Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

full adder code in vhdl programming

Status
Not open for further replies.

sumati

Newbie level 3
Newbie level 3
Joined
Sep 16, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,309
I want a full adder programming code in vhdl.How can I get software for vhdl programming.How can i get licence for it. Any HELP plz!!!
 

you could download xilinx webpack ( free license) , you will also found a lot of codes in the templates including adders.
 

You can download the Xilinx Webpack for free here: Xilinx: Downloads

A fulladder VHDL code looks like this:
-- This is just to make a reference to some common things needed.
LIBRARY IEEE;
use IEEE.STD_LOGIC_1164.ALL;

-- We declare the 1-bit adder with the inputs and outputs
-- shown inside the port().
-- This will add two bits together(x,y), with a carry in(cin) and
-- output the sum(sum) and a carry out(cout).
entity BIT_ADDER is
port( a, b, cin : in STD_LOGIC;
sum, cout : out STD_LOGIC );
end BIT_ADDER;

-- This describes the functionality of the 1-BIT adder.
architecture BHV of BIT_ADDER is
begin

-- Calculate the sum of the 1-BIT adder.
sum <= (not a and not b and cin) or
(not a and b and not cin) or
(a and not b and not cin) or
(a and b and cin);

-- Calculates the carry out of the 1-BIT adder.
cout <= (not a and b and cin) or
(a and not b and cin) or
(a and b and not cin) or
(a and b and cin);
end BHV;
 
  • Like
Reactions: sumati

    sumati

    Points: 2
    Helpful Answer Positive Rating
You can download the Xilinx Webpack for free here: Xilinx: Downloads

A fulladder VHDL code looks like this:

LIBRARY IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-----------------------------------------------------------------
entity fulladder is
port( a, b, cin : in STD_LOGIC;
sum, cout : out STD_LOGIC );
end fulladder;
-----------------------------------------------------------------
architecture Behavioral of fulladder is
signal s1,s2,s3: STD_ULOGIC;
constant gate_delay: Time :=100 ps;
begin
s1<=(a xor b) after gate_delay;
s2<=(cin and s1) after gate_delay;
s3<=(a and b) after gate_delay;
sum<=(s1 xor cin) after gate_delay;
cout<=(s2 or s3) after gate_delay;

end Behavioral;
 

LIBRARY IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-----------------------------------------------------------------
entity fulladder is
port( a, b, cin : in STD_LOGIC;
sum, cout : out STD_LOGIC );
end fulladder;
-----------------------------------------------------------------
architecture Behavioral of fulladder is
signal s1,s2,s3: STD_ULOGIC;
constant gate_delay: Time :=100 ps;
begin
s1<=(a xor b) after gate_delay;
s2<=(cin and s1) after gate_delay;
s3<=(a and b) after gate_delay;
sum<=(s1 xor cin) after gate_delay;
cout<=(s2 or s3) after gate_delay;

end Behavioral;
Wow, hold on! Why are you using all those "after" statements?
You can't use "after ...." in real VHDL development for implementation in your FPGA or CPLD. There is no "logic" to make an "after..." statement.
The after statements are used in your test bench for simulation your logic!

Also I am not sure if your code is alright. Instead I would recommend you to use this code:
Code:
library ieee;
use ieee.std_logic_1164.all;

entity fullAdder is
    Port(
        a    : in std_logic;
        b    : in std_logic;
        cin  : in std_logic;
        s    : out std_logic;
        cout : out std_logic);
end fullAdder;

architecture arch of fullAdder is
    signal aXorB : std_logic;
begin
    aXorB <= a xor b;
    s     <= aXorB xor cin;
    cout  <= (a and b) or (cin and aXorB);
end arch;

Borrowed from **broken link removed** which has a good explanation too.
 

Right... Did you compile your "code" for "real VHDL development" ? LOL
 

Right... Did you compile your "code" for "real VHDL development" ? LOL
No, I haven't tried synthesizing this one - though it should work as it makes the right logic for the full adder circuitry.
 

in arch... don't forget to declare that 's' and 'cout' of yours.
 

Wow, hold on! Why are you using all those "after" statements?
You can't use "after ...." in real VHDL development for implementation in your FPGA or CPLD. There is no "logic" to make an "after..." statement.
The after statements are used in your test bench for simulation your logic!

Also I am not sure if your code is alright. Instead I would recommend you to use this code:
Code:
library ieee;
use ieee.std_logic_1164.all;

entity fullAdder is
    Port(
        a    : in std_logic;
        b    : in std_logic;
        cin  : in std_logic;
        s    : out std_logic;
        cout : out std_logic);
end fullAdder;

architecture arch of fullAdder is
    signal aXorB : std_logic;
begin
    aXorB <= a xor b;
    s     <= aXorB xor cin;
    cout  <= (a and b) or (cin and aXorB);
end arch;

Borrowed from **broken link removed** which has a good explanation too.

Well, what Atemnik has given is a good simulation model of a full adder, but other than that it still looks good. I dont think both codes (the one from Mindthomas) will generate a different hardware when synthezised. however Mindthomas code looks clean :cool:
 

Well, what Atemnik has given is a good simulation model of a full adder, but other than that it still looks good. I dont think both codes (the one from Mindthomas) will generate a different hardware when synthezised. however Mindthomas code looks clean :cool:
Can you compile your code and post a screenshot? Thanks.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top