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

Subversion Repositories mipsr2000

[/] [mipsr2000/] [trunk/] [adder.vhd] - Blame information for rev 11

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

Line No. Rev Author Line
1 2 jimi39
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    01:51:49 04/11/2012 
6
-- Design Name: 
7
-- Module Name:    adder - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_UNSIGNED.ALL;
23
--use IEEE.STD_LOGIC_ARITH.ALL;
24
-- Uncomment the following library declaration if using
25
-- arithmetic functions with Signed or Unsigned values
26
use IEEE.NUMERIC_STD.ALL;
27
 
28
-- Uncomment the following library declaration if instantiating
29
-- any Xilinx primitives in this code.
30
--library UNISIM;
31
--use UNISIM.VComponents.all;
32
 
33
entity adder is
34
 
35
Port
36
(
37
           A : in  STD_LOGIC_VECTOR (31 downto 0);
38
           B : in  STD_LOGIC_VECTOR (31 downto 0);
39
           ALUop : in  STD_LOGIC_VECTOR (1 downto 0);
40
                          --ov : out std_logic;
41
                          S : out  STD_LOGIC_VECTOR (31 downto 0)
42
);
43
end adder;
44
 
45
architecture Behavioral of adder is
46
begin
47
adder:process(ALUop,A,B)
48
variable  add_sub : STD_LOGIC_VECTOR (32 downto 0);
49
variable  ov_temp : STD_LOGIC;
50
--variable  A_sn,B_sn,result :  signed(31 downto 0);
51
--variable  A_i,B_i :integer; 
52
         begin
53
 
54
         CASE ALUop IS
55
              When  "00"  =>
56
                                                add_sub := (A(31) & A) + (B(31) & B);
57
                                                                ov_temp := (A(31) and B(31) and (not add_sub(31))) or
58
                                                                ((not A(31)) and (not B(31)) and add_sub(31));
59
                                                                --ov <= ov_temp;
60
                        When  "01"  =>
61
                                                                add_sub := ('0' & A) + ('0' & B);
62
                                                                ov_temp := add_sub(32);
63
                        When  "10"  =>
64
                                       add_sub := (A(31) & A) - (B(31) & B);
65
                                                                ov_temp := ((not A(31)) and B(31) and add_sub(31)) or
66
                                                                (A(31) and (not B(31)) and (add_sub(31)));
67
                                                                --ov <= ov_temp;
68
                        When  "11"  =>
69
                                                                add_sub := ('0' & A) - ('0' & B);
70
                                                                ov_temp := add_sub(32);
71
         When others =>
72
                                        S <= (others =>'0');
73
         end Case;
74
             S <= add_sub(31 downto 0);
75
                       end process adder;
76
end Behavioral;
77
 

powered by: WebSVN 2.1.0

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