You are on page 1of 16

 Menu 

Carry Save Adder VHDL Code


May 31, 2016 by Admin

Contents [hide]

1 Carry Save Adder


2 Carry Save Adder Circuit 
3 Carry Save Adder VHDL Code
4 Testbench VHDL Code for Carry Save Adder
5 Output Waveform for Carry Save adder
6 Related

Carry Save Adder


Carry save adder used to perform 3 bit addition at once.
Here 3 bit input (A, B, C) is processed and converted to 2
bit output (S, C) at rst stage.  At rst stage result carry
is not propagated through  addition operation. In order to
generate carry, implemented ripple carry adder on stage 2
for carry propagation. Carry Save adder VHDL Code can
be constructed by port mapping full adder VHDL Code to
2 stage adder circuit.

Carry Save Adder Circuit 

Carry Save Adder VHDL Code


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity carry_save_adder is
Port ( A : in STD_LOGIC_VECTOR (3 downto 0);
B : in STD_LOGIC_VECTOR (3 downto 0);
C : in STD_LOGIC_VECTOR (3 downto 0);
S : OUT STD_LOGIC_VECTOR (4 downto 0);
Cout : OUT STD_LOGIC);
end carry_save_adder;

architecture Behavioral of carry_save_adder is

component full_adder_vhdl_code
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
Cin : in STD_LOGIC;
S : out STD_LOGIC;
Cout : out STD_LOGIC);
end component;

-- Intermediate signal
signal X,Y: STD_LOGIC_VECTOR(3 downto 0);
signal C1,C2,C3: STD_LOGIC;

begin
-- Carry save adder block
FA1: full_adder_vhdl_code PORT MAP(A(0),B(0),C(0),S(
FA2: full_adder_vhdl_code PORT MAP(A(1),B(1),C(1),Y(
FA3: full_adder_vhdl_code PORT MAP(A(2),B(2),C(2),Y(
FA4: full_adder_vhdl_code PORT MAP(A(3),B(3),C(3),Y(

-- Ripple carry adder block


FA5: full_adder_vhdl_code PORT MAP(X(0),Y(0),'0',S(1),
FA6: full_adder_vhdl_code PORT MAP(X(1),Y(1),C1,S(2)
FA7: full_adder_vhdl_code PORT MAP(X(2),Y(2),C2,S(3)
FA8: full_adder_vhdl_code PORT MAP(X(3),'0',C3,S(4),C

end Behavioral;

Testbench VHDL Code for Carry Save Adder

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

ENTITY Tb_carry_save IS
END Tb_carry_save;

ARCHITECTURE behavior OF Tb_carry_save IS

-- Component Declaration for the Unit Under Test (UUT)


COMPONENT carry_save_adder
PORT(
A : IN std_logic_vector(3 downto 0);
B : IN std_logic_vector(3 downto 0);
C : IN std_logic_vector(3 downto 0);
S : OUT std_logic_vector(4 downto 0);
Cout : OUT std_logic
);
END COMPONENT;

--Inputs
signal A : std_logic_vector(3 downto 0) := (others => '0'
signal B : std_logic_vector(3 downto 0) := (others => '0'
signal C : std_logic_vector(3 downto 0) := (others => '0'

--Outputs
signal S : std_logic_vector(4 downto 0);
signal Cout : std_logic;

BEGIN

-- Instantiate the Unit Under Test (UUT)


uut: carry_save_adder PORT MAP (
A => A,
B => B,
C => C,
S => S,
Cout => Cout
);

-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
A <= "1100";
B <= "1101";
C <= "1110";

wait for 100 ns;


A <= "1111";
B <= "1000";
C <= "1001";

wait for 100 ns;


A <= "1110";
B <= "0101";
C <= "0111";

wait;
end process;

END;
Output Waveform for Carry Save adder

Carry Save Adder performs Addition of 3 (A, B, C) 4-bit


values and output 5 bit Sum and Cout. Example result
(1100 + 1101 + 1110) = 100111 (MSB Bit ‘1’ Cout , Sum 5
bit ” 00111″).

 Download Post as PDF

Related

4 Bit Ripple Carry Carry Select Adder VHDL Code for Full
Adder VHDL Code VHDL Code Adder
May 29, 2016 June 2, 2016 April 7, 2014
In "VHDL" In "VHDL" In "VHDL"
 VHDL
 VHDL Code for Carry Save Adder
 Carry Look Ahead Adder VHDL Code
 Carry Select Adder VHDL Code
Leave a Reply

Enter your comment here...


INTRODUCING

EDGE Spartan6
FPGA
Development
Board
BUY NOW
Top Posts & Pages

VHDL Code for Flip op - D,JK,SR,T

VHDL 4 to 1 Mux (Multiplexer)

VHDL Code for Full Adder

BCD to 7 Segment Decoder VHDL Code

VHDL Code for 2 to 4 decoder

VHDL Code for 4-Bit Shift Register

VHDL code for 4-bit ALU

VHDL Code for 4 to 2 Encoder


VHDL code for 1 to 4 Demux

4 Bit Ripple Carry Adder VHDL Code

Recent Posts

Introducing EDGE Spartan 6 FPGA Development Board!


BCD to 7 Segment Decoder VHDL Code
Sequence Detector using Mealy and Moore State
Machine VHDL Codes
Carry Select Adder VHDL Code
Carry Save Adder VHDL Code
Carry Look Ahead Adder VHDL Code
4 Bit Ripple Carry Adder VHDL Code
VHDL Code for 4-bit Ring Counter and Johnson Counter
VHDL Code for 2 to 4 decoder
VHDL Code for 4 to 2 Encoder
About Us

We are the developers of high quality and low cost


FPGA development kits. Our aim is to provide the best
FPGA learning platform to the students, research
scholars and young engineers. We have created EDGE
Spartan6 FPGA development kit with awesome
features like  WiFi, Bluetooth, Stereo Jack, VGA, LCD, 7
Segment, ADC, DAC, Camera, TFT,and lot more.
Customer service is the experience we deliver to our
customer. It’s the promise we keep to the customer.

Like us on Facebook
  

Newsletter

Subscribe to our newsletter and receive the latest


offers, discounts and updates
Email Address

Subscribe

My Accounts

My account
Checkout
Cart
Shop
Terms of Service
Store A liates
A liate Login

© 2018 • All About FPGA

You might also like