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

Subversion Repositories opencpu32

[/] [opencpu32/] [trunk/] [hdl/] [opencpu32/] [Alu.vhd] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 leonardoar
--! @file
2
--! @brief Arithmetic logic unit http://en.wikipedia.org/wiki/Arithmetic_logic_unit
3
 
4 8 leonardoar
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
5 5 leonardoar
library IEEE;
6 8 leonardoar
use ieee.std_logic_1164.all;
7
use ieee.std_logic_unsigned.all;
8
use ieee.std_logic_arith.all;
9 5 leonardoar
 
10
--! Use CPU Definitions package
11 8 leonardoar
use work.pkgOpenCPU32.all;
12 5 leonardoar
 
13
--! ALU is a digital circuit that performs arithmetic and logical operations.
14
 
15
--! ALU is a digital circuit that performs arithmetic and logical operations. It's the fundamental part of the CPU
16
entity Alu is
17 8 leonardoar
    generic (n : integer := nBits - 1);
18
         Port ( A : in  STD_LOGIC_VECTOR (n downto 0);           --! Alu Operand 1
19
           B : in  STD_LOGIC_VECTOR (n downto 0);                --! Alu Operand 2
20
           S : out  STD_LOGIC_VECTOR (n downto 0);               --! Alu Output
21
           sel : in  aluOps);                                                                   --! Select operation
22 5 leonardoar
end Alu;
23
 
24
--! @brief Architure definition of the ALU
25
--! @details More details about this mux element.
26
architecture Behavioral of Alu is
27
 
28
begin
29 8 leonardoar
        --! Behavior description of combinational circuit (Can not infer any FF(Flip flop))
30
        process (A,B,sel) is
31
        begin
32
                case sel is
33
                        when alu_sum =>
34
                                S <= A + B;
35
 
36
                        when alu_sub =>
37
                                S <= A - B;
38
 
39
                        when alu_inc =>
40
                                S <= A - B;
41
 
42
                        when alu_dec =>
43
                                S <= A - B;
44
 
45
                        when alu_and =>
46
                                S <= A and B;
47
 
48
                        when alu_or =>
49
                                S <= A or B;
50
 
51
                        when alu_xor =>
52
                                S <= A xor B;
53
 
54
                        when others =>
55
                                S <= (others => 'Z');
56
                end case;
57
        end process;
58 5 leonardoar
 
59
end Behavioral;
60
 

powered by: WebSVN 2.1.0

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