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

Subversion Repositories mips_fault_tolerant

[/] [mips_fault_tolerant/] [trunk/] [source/] [Mult.vhd] - Blame information for rev 74

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

Line No. Rev Author Line
1 35 jimi39
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    03:30:57 05/23/2012 
6
-- Design Name: 
7
-- Module Name:    Mult - 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_ARITH.ALL;
23
--use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
use IEEE.NUMERIC_STD.ALL;
25
-- Uncomment the following library declaration if using
26
-- arithmetic functions with Signed or Unsigned values
27
--use IEEE.NUMERIC_STD.ALL;
28
 
29
-- Uncomment the following library declaration if instantiating
30
-- any Xilinx primitives in this code.
31
--library UNISIM;
32
--use UNISIM.VComponents.all;
33
 
34
entity Mult is
35
    Port (
36
 
37
                A : in  STD_LOGIC_VECTOR (31 downto 0);
38
           B : in  STD_LOGIC_VECTOR (31 downto 0);
39
                          Hi_to_out : out STD_LOGIC_VECTOR (31 downto 0);
40
                          Lo_to_out : out STD_LOGIC_VECTOR (31 downto 0)
41
          );
42
end Mult;
43
 
44
architecture Behavioral of Mult is
45
begin
46
       process(A,B)
47
                 variable ov : std_logic := '0';
48
                 variable HiLo : signed(65 downto 0);
49
                 variable Hi,Lo :signed(31 downto 0);
50
                 variable A_in,B_in : signed(31 downto 0);
51
                 begin
52
                ---------------------------------
53
                -- A_in := signed((A(31)) & A);
54
                -- B_in := signed(B(31) & B);
55
                -- HiLo := A_in * B_in;
56
                -----------------------------------
57
                -- alternative method
58
                --HiLo :=  signed((A(31)) & A) * signed(B(31) & B);
59
                --ov := (not HiLo(63)) and  A_in(31) and B_in(31) or (HiLo(63)) and (not A_in(31)) and (not B_in(31));
60
                -----------------------------------
61
 
62
                 A_in := signed(A);
63
                 B_in := signed(B);
64
                 HiLo := (A_in(31) & A_in) * (B_in(31) & B_in);
65
                 ov := A_in(31) xor B_in(31) xor HiLo(63) xor HiLo(64) xor HiLo(65);
66
                 Hi :=   HiLo(63 downto 32);
67
                 Lo :=  HiLo(31 downto 0);
68
                 Lo_to_out <= std_logic_vector(Lo);
69
                 Hi_to_out <= std_logic_vector(Hi);
70
 
71
                 end process;
72
 
73
end Behavioral;
74
 

powered by: WebSVN 2.1.0

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