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.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 elujan
--
2
-- ALU del procesador MIPS Segmentado
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
library work;
27
use work.records_pkg.all;
28
use work.segm_mips_const_pkg.all;
29
 
30
entity ALU is
31
        generic (N: NATURAL);
32
        port(
33
                X       : in STD_LOGIC_VECTOR(N-1 downto 0);
34
                Y       : in STD_LOGIC_VECTOR(N-1 downto 0);
35
                ALU_IN  : in ALU_INPUT;
36
                R       : out STD_LOGIC_VECTOR(N-1 downto 0);
37
                FLAGS   : out ALU_FLAGS
38
        );
39
end;
40
 
41
architecture ALU_ARC of ALU is
42
 
43
-- Declaración de componentes
44
        component ALU_1BIT is
45
                port(
46
                        X       : in STD_LOGIC;
47
                        Y       : in STD_LOGIC;
48
                        LESS    : in STD_LOGIC;
49
                        BINVERT : in STD_LOGIC;
50
                        CIN     : in STD_LOGIC;
51
                        OP1     : in STD_LOGIC;
52
                        OP0     : in STD_LOGIC;
53
                        RES     : out STD_LOGIC;
54
                        COUT    : out STD_LOGIC;
55
                        SET     : out STD_LOGIC
56
                );
57
        end component ALU_1BIT;
58
 
59
-- Declaración de señales
60
 
61
        signal LESS_AUX : STD_LOGIC;
62
        signal COUT_AUX : STD_LOGIC_VECTOR(N-1 downto 0);
63
        signal R_AUX    : STD_LOGIC_VECTOR(N-1 downto 0);
64
 
65
begin
66
 
67
        BEGIN_ALU1B:
68
                ALU_1BIT port map (
69
                                X       => X(0),
70
                                Y       => Y(0),
71
                                LESS    => LESS_AUX,
72
                                BINVERT => ALU_IN.Op2,
73
                                CIN     => ALU_IN.Op2,
74
                                OP1     => ALU_IN.Op1,
75
                                OP0     => ALU_IN.Op0,
76
                                RES     => R_AUX(0),
77
                                COUT    => COUT_AUX(0)
78
                );
79
 
80
        GEN_ALU:
81
                for i in 1 to N-2 generate
82
                        NEXT_ALU1B:
83
                                ALU_1BIT port map (
84
                                        X       => X(i),
85
                                        Y       => Y(i),
86
                                        LESS    => '0',
87
                                        BINVERT => ALU_IN.Op2,
88
                                        CIN     => COUT_AUX(i-1),
89
                                        OP1     => ALU_IN.Op1,
90
                                        OP0     => ALU_IN.Op0,
91
                                        RES     => R_AUX(i),
92
                                        COUT    => COUT_AUX(i)
93
                                );
94
                end generate;
95
 
96
        LAST_ALU1B:
97
                ALU_1BIT port map (
98
                        X       => X(N-1),
99
                        Y       => Y(N-1),
100
                        LESS    => '0',
101
                        BINVERT => ALU_IN.Op2,
102
                        CIN     => COUT_AUX(N-2),
103
                        OP1     => ALU_IN.Op1,
104
                        OP0     => ALU_IN.Op0,
105
                        RES     => R_AUX(N-1),
106
                        COUT    => COUT_AUX(N-1),
107
                        SET     => LESS_AUX
108
                );
109
 
110
        FLAGS.Carry <= COUT_AUX(N-1);
111
        FLAGS.Overflow <= COUT_AUX(N-1) xor COUT_AUX(N-2) ;
112
        FLAGS.Negative <= '1' when R_AUX(N-1)='1' else '0';
113
        FLAGS.Zero <= '1' when R_AUX= ZERO32b else '0';
114
 
115
        ALU_RES:
116
                process(ALU_IN.Op3,R_AUX,Y)
117
                begin
118
                        if  ALU_IN.Op3='1' then
119
                                R <= Y( ((N/2)-1) downto 0) & ZERO16b;
120
                        else
121
                                R <= R_AUX;
122
                        end if;
123
                end process;
124
 
125
end ALU_ARC;

powered by: WebSVN 2.1.0

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