Project

General

Profile

Download (4.41 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
-- Copyright (C) 1996 Morgan Kaufmann Publishers, Inc
3

    
4
-- This file is part of VESTs (Vhdl tESTs).
5

    
6
-- VESTs is free software; you can redistribute it and/or modify it
7
-- under the terms of the GNU General Public License as published by the
8
-- Free Software Foundation; either version 2 of the License, or (at
9
-- your option) any later version. 
10

    
11
-- VESTs is distributed in the hope that it will be useful, but WITHOUT
12
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
-- for more details. 
15

    
16
-- You should have received a copy of the GNU General Public License
17
-- along with VESTs; if not, write to the Free Software Foundation,
18
-- Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
19

    
20
-- ---------------------------------------------------------------------
21
--
22
-- $Id: bv_arithmetic.vhd,v 1.2 2001-10-25 01:24:24 paw Exp $
23
-- $Revision: 1.2 $
24
--
25
-- ---------------------------------------------------------------------
26

    
27
--------------------------------------------------------------------------
28
--
29
--  Bit-vector arithmetic package interface.
30
--  
31
--  Does arithmetic and logical operations on bit vectors, treating them
32
--  as either unsigned or signed (two's complement) integers.  Leftmost bit
33
--  is most-significant or sign bit, rightmost bit is least-significant
34
--  bit.  Dyadic operations need the two arguments to be of the same
35
--  length; however, their index ranges and directions may differ.  Results
36
--  must be of the same length as the operands.
37
--  
38
--------------------------------------------------------------------------
39

    
40
package bv_arithmetic is
41

    
42
  function bv_to_natural ( bv : in bit_vector ) return natural;
43

    
44
  function natural_to_bv ( nat : in natural;
45
      	      	      	   length : in natural ) return bit_vector;
46

    
47
  function bv_to_integer ( bv : in bit_vector ) return integer;
48

    
49
  function integer_to_bv ( int : in integer;
50
      	      	      	   length : in natural ) return bit_vector;
51

    
52
  procedure bv_add ( bv1, bv2 : in bit_vector;
53
      	       	     bv_result : out bit_vector;
54
		     overflow : out boolean );
55

    
56
  function "+" ( bv1, bv2 : in bit_vector ) return bit_vector;
57

    
58
  procedure bv_sub ( bv1, bv2 : in bit_vector;
59
      	       	     bv_result : out bit_vector;
60
		     overflow : out boolean );
61

    
62
  function "-" ( bv1, bv2 : in bit_vector ) return bit_vector;
63

    
64
  procedure bv_addu ( bv1, bv2 : in bit_vector;
65
      	       	      bv_result : out bit_vector;
66
		      overflow : out boolean );
67

    
68
  function bv_addu ( bv1, bv2 : in bit_vector ) return bit_vector;
69

    
70
  procedure bv_subu ( bv1, bv2 : in bit_vector;
71
      	       	      bv_result : out bit_vector;
72
		      overflow : out boolean );
73

    
74
  function bv_subu ( bv1, bv2 : in bit_vector ) return bit_vector;
75

    
76
  procedure bv_neg ( bv : in bit_vector;
77
                     bv_result : out bit_vector;
78
                     overflow : out boolean );
79

    
80
  function "-" ( bv : in bit_vector ) return bit_vector;
81

    
82
  procedure bv_mult ( bv1, bv2 : in bit_vector;
83
      	       	      bv_result : out bit_vector;
84
		      overflow : out boolean );
85

    
86
  function "*" ( bv1, bv2 : in bit_vector ) return bit_vector;
87

    
88
  procedure bv_multu ( bv1, bv2 : in bit_vector;
89
      	       	       bv_result : out bit_vector;
90
		       overflow : out boolean );
91

    
92
  function bv_multu ( bv1, bv2 : in bit_vector ) return bit_vector;
93

    
94
  procedure bv_div ( bv1, bv2 : in bit_vector;
95
      	       	     bv_result : out bit_vector;
96
		     div_by_zero : out boolean;
97
                     overflow : out boolean );
98

    
99
  function "/" ( bv1, bv2 : in bit_vector ) return bit_vector;
100

    
101
  procedure bv_divu ( bv1, bv2 : in bit_vector;
102
      	       	      bv_quotient : out bit_vector;
103
		      bv_remainder : out bit_vector;
104
		      div_by_zero : out boolean );
105

    
106
  procedure bv_divu ( bv1, bv2 : in bit_vector;
107
      	       	      bv_quotient : out bit_vector;
108
		      div_by_zero : out boolean );
109

    
110
  function bv_divu ( bv1, bv2 : in bit_vector )  return bit_vector;
111

    
112
  function bv_lt ( bv1, bv2 : in bit_vector ) return boolean;
113

    
114
  function bv_le ( bv1, bv2 : in bit_vector ) return boolean;
115

    
116
  function bv_gt ( bv1, bv2 : in bit_vector ) return boolean;
117

    
118
  function bv_ge ( bv1, bv2 : in bit_vector ) return boolean;
119

    
120
  function bv_sext ( bv : in bit_vector;
121
      	      	     length : in natural ) return bit_vector;
122

    
123
  function bv_zext ( bv : in bit_vector;
124
      	      	     length : in natural ) return bit_vector;
125

    
126
end package bv_arithmetic;
(14-14/267)