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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [gaisler/] [arith/] [arith.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2003, Gaisler Research
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18
-----------------------------------------------------------------------------
19
-- Package:     arith
20
-- File:        arith.vhd
21
-- Author:      Jiri Gaisler, Gaisler Research
22
-- Description: Declaration of mul/div components
23
------------------------------------------------------------------------------
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
use ieee.numeric_std.all;
28
 
29
package arith is
30
 
31
type div32_in_type is record
32
  y                : std_logic_vector(32 downto 0); -- Y (MSB divident)
33
  op1              : std_logic_vector(32 downto 0); -- operand 1 (LSB divident)
34
  op2              : std_logic_vector(32 downto 0); -- operand 2 (divisor)
35
  flush            : std_logic;
36
  signed           : std_logic;
37
  start            : std_logic;
38
end record;
39
 
40
type div32_out_type is record
41
  ready           : std_logic;
42
  nready          : std_logic;
43
  icc             : std_logic_vector(3 downto 0); -- ICC
44
  result          : std_logic_vector(31 downto 0); -- div result
45
end record;
46
 
47
type mul32_in_type is record
48
  op1              : std_logic_vector(32 downto 0); -- operand 1
49
  op2              : std_logic_vector(32 downto 0); -- operand 2
50
  flush            : std_logic;
51
  signed           : std_logic;
52
  start            : std_logic;
53
  mac              : std_logic;
54
  acc              : std_logic_vector(39 downto 0);
55
  --y                : std_logic_vector(7 downto 0); -- Y (MSB MAC register)
56
  --asr18           : std_logic_vector(31 downto 0); -- LSB MAC register
57
end record;
58
 
59
type mul32_out_type is record
60
  ready           : std_logic;
61
  nready          : std_logic;
62
  icc             : std_logic_vector(3 downto 0); -- ICC
63
  result          : std_logic_vector(63 downto 0); -- mul result
64
end record;
65
 
66
component div32
67
port (
68
    rst     : in  std_ulogic;
69
    clk     : in  std_ulogic;
70
    holdn   : in  std_ulogic;
71
    divi    : in  div32_in_type;
72
    divo    : out div32_out_type
73
);
74
end component;
75
 
76
component mul32
77
generic (
78
    infer   : integer := 1;
79
    multype : integer := 0;
80
    pipe    : integer := 0;
81
    mac     : integer := 0
82
);
83
port (
84
    rst     : in  std_ulogic;
85
    clk     : in  std_ulogic;
86
    holdn   : in  std_ulogic;
87
    muli    : in  mul32_in_type;
88
    mulo    : out mul32_out_type
89
);
90
end component;
91
 
92
function smult ( a, b  : in  std_logic_vector) return std_logic_vector;
93
 
94
end;
95
 
96
package body arith is
97
 
98
function smult ( a, b  : in  std_logic_vector) return std_logic_vector is
99
  variable sa : signed (a'length-1 downto 0);
100
  variable sb : signed (b'length-1 downto 0);
101
  variable sc : signed ((a'length + b'length) -1 downto 0);
102
  variable res : std_logic_vector ((a'length + b'length) -1 downto 0);
103
begin
104
 
105
  sa := signed(a); sb := signed(b);
106
-- pragma translate_off
107
  if is_x(a) or is_x(b) then
108
    sc := (others => 'X');
109
  else
110
-- pragma translate_on
111
    sc := sa * sb;
112
-- pragma translate_off
113
  end if;
114
-- pragma translate_on
115
  res := std_logic_vector(sc);
116
  return(res);
117
end;
118
 
119
end;

powered by: WebSVN 2.1.0

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