OpenCores
URL https://opencores.org/ocsvn/ecpu_alu/ecpu_alu/trunk

Subversion Repositories ecpu_alu

[/] [ecpu_alu/] [trunk/] [alu/] [rtl/] [vhdl/] [alu_adder.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 leonous
--------------------------------------------------------------------------------
2
--------------------------------------------------------------------------------
3
-- Module   - Introduction to VLSI Design
4
-- Lecturer - Dr V. M. Dwyer
5
-- Course   - MEng Electronic and Electrical Engineering
6
-- Year     - Part D
7
-- Student  - Sahrfili Leonous Matturi A028459 [elslm]
8
--------------------------------------------------------------------------------
9
--------------------------------------------------------------------------------
10
-- Final coursework 2004
11
-- 
12
-- Details:     Design and Layout of an ALU
13
--------------------------------------------------------------------------------
14
--------------------------------------------------------------------------------
15
 
16
--      Description     :       ALU datapath
17
--  Entity                      :       alu_datapath
18
--      Architecture    :       structural
19
--  Created on          :       07/03/2004
20
 
21
library ieee;
22
 
23
use ieee.std_logic_1164.all;
24
use     ieee.std_logic_unsigned.all;
25
 
26
entity alu_adder is
27
        generic (
28
                        adder_width     : integer := 8
29
                        );
30
        port    (
31
                        x                       : in    std_logic_vector(adder_width - 1 downto 0)       ;
32
                        y                       : in    std_logic_vector(adder_width - 1 downto 0)       ;
33
                        carry_in        : in    std_logic                                                                       ;
34
                        ORsel           : in    std_logic                                                                       ;
35
                        XORsel          : in    std_logic                                                                       ;
36
                        carry_out       : out   std_logic_vector(adder_width     downto 0)       ;
37
                        xor_result      : out   std_logic_vector(adder_width - 1 downto 0)       ;
38
                        or_result       : out   std_logic_vector(adder_width - 1 downto 0)       ;
39
                        and_result      : out   std_logic_vector(adder_width - 1 downto 0)       ;
40
                        z                       : out   std_logic_vector(adder_width - 1 downto 0)
41
                        );
42
end alu_adder;
43
 
44
 
45
architecture structural of alu_adder is
46
signal  c               : std_logic_vector(adder_width downto 0);
47
signal  XxorY,
48
                XandY,
49
                XorY    : std_logic_vector(adder_width - 1 downto 0);
50
 
51
begin
52
 
53
        ----------------------------------------------------
54
    -- adder
55
    ----------------------------------------------------
56
    xor_result  <= XxorY;
57
    or_result   <= XorY ;
58
    and_result  <= XandY;
59
 
60
        XxorY   <=      x xor y;
61
        XandY   <=      x and y;
62
        XorY    <=      x or  y;
63
 
64
    carry_out   <= c;
65
 
66
    adder       :       process (x, y, c, XxorY, XandY, XorY)
67
                        begin
68
                            c(0) <= carry_in;
69
                            for i in z'range loop
70
                                z(i)    <=  XxorY(i) xor (c(i) and XORsel);
71
                                c(i+1)  <=  XandY(i) or
72
                                           ((c(i) or ORsel) and XorY(i));
73
                                        end loop;
74
                        end process adder;
75
 
76
end structural;
77
 
78
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.