OpenCores
URL https://opencores.org/ocsvn/vhdl-pipeline-mips/vhdl-pipeline-mips/trunk

Subversion Repositories vhdl-pipeline-mips

[/] [vhdl-pipeline-mips/] [trunk/] [3_execution/] [alu_1bit.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 elujan
--
2
-- ALU de 1 Bit
3
--
4
-- Licencia: Copyright 2008 Emmanuel Luján
5
--
6
--      This program is free software; you can redistribute it and/or
7
--      modify it under the terms of the GNU General Public License as
8
--      published by the Free Software Foundation; either version 2 of
9
--      the License, or (at your option) any later version. This program
10
--      is distributed in the hope that it will be useful, but WITHOUT
11
--      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
--      or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
13
--      License for more details. You should have received a copy of the
14
--      GNU General Public License along with this program; if not, write
15
--      to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
16
--      Boston, MA 02110-1301 USA.
17
-- 
18
-- Autor:       Emmanuel Luján
19
-- Email:       info@emmanuellujan.com.ar
20
-- Versión:    1.0
21
--
22
 
23
library ieee;
24
use ieee.STD_LOGIC_1164.all;
25
 
26
entity ALU_1BIT is
27
        port(
28
                        X       : in STD_LOGIC;
29
                        Y       : in STD_LOGIC;
30
                        LESS    : in STD_LOGIC;
31
                        BINVERT : in STD_LOGIC;
32
                        CIN     : in STD_LOGIC;
33
                        OP1     : in STD_LOGIC;
34
                        OP0     : in STD_LOGIC;
35
                        RES     : out STD_LOGIC;
36
                        COUT    : out STD_LOGIC;
37
                        SET     : out STD_LOGIC
38
        );
39
end;
40
 
41
architecture ALU_1BIT_ARC of ALU_1BIT is
42
 
43
-- Declaración de componentes
44
        component FULL_ADDER is
45
                port(
46
                        X       : in    STD_LOGIC;
47
                        Y       : in    STD_LOGIC;
48
                        CIN     : in    STD_LOGIC;
49
                        COUT    : out   STD_LOGIC;
50
                        R       : out   STD_LOGIC
51
                );
52
        end component FULL_ADDER;
53
 
54
-- Declaración de señales
55
        signal NEW_Y            : STD_LOGIC;
56
        signal R0,R1,R2,R3      : STD_LOGIC;
57
        signal RES_AUX          : STD_LOGIC;
58
 
59
begin
60
 
61
        MUX_BINV:
62
                process(BINVERT,Y) is
63
                begin
64
                        if BINVERT='0' then
65
                                NEW_Y <= Y;
66
                        else
67
                                NEW_Y <= not Y;
68
                        end if;
69
                end process MUX_BINV;
70
 
71
        R0 <= X and NEW_Y;
72
        R1 <= X or NEW_Y;
73
 
74
        FULLADDER_ALU:
75
                FULL_ADDER port map(
76
                        X       => X,
77
                        Y       => NEW_Y,
78
                        CIN     => CIN,
79
                        COUT    => COUT,
80
                        R       => R2
81
                );
82
 
83
        R3 <= LESS;
84
 
85
        MUX_RES_ALU:
86
                process(OP1,OP0,R0,R1,R2,R3) is
87
                begin
88
                        if (OP1 = '0' and OP0 = '0') then
89
                                RES_AUX <= R0;
90
                        elsif (OP1 = '0' and OP0 = '1') then
91
                                RES_AUX <= R1;
92
                        elsif (OP1 = '1' and OP0 = '0') then
93
                                RES_AUX <= R2;
94
                        elsif (OP1 = '1' and OP0 = '1') then
95
                                RES_AUX <= R3;
96
                        end if;
97
                end process MUX_RES_ALU;
98
 
99
        RES <= RES_AUX;
100
        SET <= R2;
101
 
102
end ALU_1BIT_ARC;

powered by: WebSVN 2.1.0

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