aboutsummaryrefslogtreecommitdiff
path: root/sem6/dig/m2/ex6.vhdl
blob: e920c9884af06c417bedd08689d6f347428be50e (plain)
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
-- TEST_START{"inputs": ["cin", "a,3,0", "b,3,0"], "outputs": ["carry", "output,3,0"], "testin": [["0", "0001", "0001"], ["0", "0101", "1010"], ["0", "1111", "1111"], ["1", "0000", "0000"]]}TEST_STOP
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;

ENTITY ex6 IS
    PORT(
        a : IN STD_LOGIC_VECTOR(3 downto 0);
        b : IN STD_LOGIC_VECTOR(3 downto 0);
        cin: IN STD_LOGIC;
        output: OUT STD_LOGIC_VECTOR(3 downto 0);
        carry : OUT STD_LOGIC
    );
END ex6;

ARCHITECTURE impl OF ex6 IS
    SIGNAL c1 : STD_LOGIC;
    SIGNAL c2 : STD_LOGIC;
    SIGNAL c3 : STD_LOGIC;
    SIGNAL c4 : STD_LOGIC;

BEGIN

    add1 : ENTITY work.ex5
    PORT MAP (
                 a => a(0),
                 b => b(0),
                 cin => cin,
                 o => output(0),
                 cout => c1
             );

    add2 : ENTITY work.ex5
    PORT MAP (
                 a => a(1),
                 b => b(1),
                 cin => c1,
                 o => output(1),
                 cout => c2
             );

    add3 : ENTITY work.ex5
    PORT MAP (
                 a => a(2),
                 b => b(2),
                 cin => c2,
                 o => output(2),
                 cout => c3
             );

    add4 : ENTITY work.ex5
    PORT MAP (
                 a => a(3),
                 b => b(3),
                 cin => c3,
                 o => output(3),
                 cout => carry
             );
END impl;