Adder_Generic.vhd
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 08.10.2023 15:22:15
-- Design Name:
-- Module Name: Generic unsigned full Adder - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use ieee.std_logic_unsigned.all;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Adder_Generic is
generic( N : Integer := 256);
Port (
clk_in, reset : in std_logic;
a_in, b_in : in std_logic_vector(N-1 downto 0);
s_out : out std_logic_vector(N downto 0)
);
end Adder_Generic;
--
architecture Behavioral of Adder_Generic is
signal ain_add : signed(N downto 0);
signal bin_add : signed(N downto 0);
signal s_out_d : signed(N downto 0);
begin
s_out_d <= ain_add + bin_add;
process(clk_in, reset)
begin
if reset = '1' then
s_out <= (others => '0');
elsif rising_edge(clk_in) then
ain_add <= resize(signed(a_in),N+1);
bin_add <= resize(signed(b_in),N+1);
s_out <= std_logic_vector(s_out_d);
end if;
end process;
end Behavioral;