Skip to main content

verilog code for ripple carry adder

Author : Kishore Papisetty

verilog code for the ripple carry adder i structural format

module ripple(
    output [3:0] s,
    output cout,
input [3:0] a,
    input [3:0] b,
    input cin
   
    );
wire c1,c2,c3;
fulladder F1(s[0],c1,a[0],b[0],cin);
fulladder F2(s[1],c2,a[1],b[1],c1);
fulladder F3(s[2],c3,a[2],b[2],c2);
fulladder F4(s[3],cout,a[3],b[3],c3);

endmodule


verilog code for the full adder

module fulladder(
output sum,
    output carry,
    input a,
    input b,
    input c
   
    );

assign sum = a^b^c;
assign carry = (a&b)|(b&c)|(c&a);
endmodule


Comments

Popular posts from this blog

Gray code counter in VHDL

Author : Kishore Papisetty code : VHDL Gray code is the code with only bit transition between adjacent words. The direct description of Gray counter is based on the equation extraction from the truth table. Such solution of n bit counter demands 2^(n-2). product terms. Implementation may be difficult for greater width of counter. The alternative is using of auxiliary bit. The design was based on the Auxiliary bit generation. vhdl code for the gray counter library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity gray_counter is     Port ( clk : in  STD_LOGIC;            rst : in  STD_LOGIC;            gray_code : out  STD_LOGIC_VECTOR (3 DOWNTO 0)); end gray_counter; architecture Behavioral of gray_counter is signal count:STD_LOGIC_VECTOR(3 DOWNTO 0):="0000"; begin process(clk) begin if(rst='1') then count <= "0000"...

VHDL code for a 3-bit binary to thermometer converter

Author : Kishore Papisetty Platform : Xilinx code : VHDL //bit binary to thermometer converter// library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.numeric_std.all; entity bin2therm2bit is                 port (                                 binary_input : in std_logic_vector (1 downto 0);                                 therm_output : out std_logic_vector (6 downto 0)                 ); end bin2therm6bit; architecture Behavioral of bin2therm6bit is begin                 process (binary_input)                 begin                                 label1 : case binary_inpu...