-
Notifications
You must be signed in to change notification settings - Fork 0
/
nbit_incrementor.vhd.bak
66 lines (53 loc) · 1.84 KB
/
nbit_incrementor.vhd.bak
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
55
56
57
58
59
60
61
62
63
64
65
66
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 11:24:34 11/10/2016
-- Design Name:
-- Module Name: eightbit_comparator - 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;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity nbit_incrementor is
generic (n : positive := 4);
Port ( InA : in STD_LOGIC_VECTOR (n-1 downto 0);
C_in : in STD_LOGIC;
Sum : out STD_LOGIC_VECTOR (n-1 downto 0);
C_out : out STD_LOGIC);
end nbit_incrementor;
architecture Behavioral of nbit_incrementor is
--define I/O connetions of a full adder
component HalfAdder_VHDL
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
s : out STD_LOGIC;
Cout : out STD_LOGIC);
end component;
--define carry signal
signal sig_carry : STD_LOGIC_VECTOR (n-1 downto 0) := (others =>'0');
begin
--define connections of firt half adder in series
initFirstHalfAdd: HalfAdder_VHDL port map (InA(0), C_in, Sum(0), sig_carry(0));
genHlfAdds: for i in (n-1) downto 1 generate --define connection of the main body of hald adders with genneral connections
initStdHlfAdd: HalfAdder_VHDL port map(InA(i), sig_carry(i-1), sum(i), sig_carry(i));
end generate;
C_out <= sig_carry(n-1);--define output carry signal connection
end Behavioral;