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

Subversion Repositories xmatchpro

[/] [xmatchpro/] [trunk/] [xmw4-comdec/] [xmatch_sim7/] [lib/] [dzx/] [bit_arith_pkg.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 eejlny
--D  sccsid @(#)bit_arith.vhdl  1.3 daisy(C) 2/13/95 /files1/SCCS.model/bvhdl/vhdl_packages/dzx/src/s.bit_arith.vhdl
2
-------------------------------------------------------------------------------
3
--    File: Bit_Arith
4
-------------------------------------------------------------------------------
5
 
6
package Bit_Arith is
7
 
8
    --=============================
9
    -- Bit_Vector arithemetics   --
10
    --=============================
11
 
12
    ----------------------------
13
    -- Bit_Vector Basic Types --
14
    ----------------------------
15
 
16
    subtype nibble is Bit_Vector ( 3 downto 0 ) ;
17
    subtype byte   is Bit_Vector ( 7 downto 0 ) ;
18
    subtype word   is Bit_Vector (15 downto 0 ) ;
19
    subtype long   is Bit_Vector (31 downto 0 ) ;
20
 
21
    -------------------------
22
    -- Conversion routines --
23
    -------------------------
24
 
25
    function To_Integer    (v : Bit_Vector) return Integer;
26
    function To_BitVector (i : Integer) return Long;
27
    function To_BitVector (i, size : Integer) return Bit_Vector;
28
 
29
    ------------------------------
30
    -- Bit_Vector OP Bit_Vector --
31
    ------------------------------
32
 
33
    function "+" ( left , right : Bit_Vector ) return Bit_Vector ;
34
    function "-" ( left , right : Bit_Vector ) return Bit_Vector ;
35
    function "*" ( left , right : Bit_Vector ) return Bit_Vector ;
36
    function "/" ( left , right : Bit_Vector ) return Bit_Vector ;
37
 
38
    function "mod" ( left , right : Bit_Vector ) return Bit_Vector ;
39
    function "rem" ( left , right : Bit_Vector ) return Bit_Vector ;
40
 
41
 
42
    ---------------------------
43
    -- Bit_Vector OP Integer --
44
    ---------------------------
45
 
46
    function "+" ( left : Bit_Vector ; right : Integer ) return Bit_Vector ;
47
    function "-" ( left : Bit_Vector ; right : Integer ) return Bit_Vector ;
48
    function "*" ( left : Bit_Vector ; right : Integer ) return Bit_Vector ;
49
    function "/" ( left : Bit_Vector ; right : Integer ) return Bit_Vector ;
50
 
51
    function "mod" ( left : Bit_Vector ; right : Integer ) return Bit_Vector ;
52
    function "rem" ( left : Bit_Vector ; right : Integer ) return Bit_Vector ;
53
 
54
 
55
    ----------------------------
56
    -- Integer OP Bit_Vector  --
57
    ----------------------------
58
 
59
    function "+" ( left : Integer ; right : Bit_Vector ) return Bit_Vector ;
60
    function "-" ( left : Integer ; right : Bit_Vector ) return Bit_Vector ;
61
    function "*" ( left : Integer ; right : Bit_Vector ) return Bit_Vector ;
62
    function "/" ( left : Integer ; right : Bit_Vector ) return Bit_Vector ;
63
 
64
    function "mod" ( left : Integer ; right : Bit_Vector ) return Bit_Vector ;
65
    function "rem" ( left : Integer ; right : Bit_Vector ) return Bit_Vector ;
66
 
67
    -------------------------------------------------
68
    -- Bit_Vector Extension & Truncation functions --
69
    -------------------------------------------------
70
    function ext      ( b : Bit_Vector ; size : Integer ) return Bit_Vector ;
71
    function trunc    ( b : Bit_Vector ; size : Integer ) return Bit_Vector ;
72
 
73
    --==================================
74
    -- SIGNED & UNSIGNED arithemetics --
75
    --==================================
76
 
77
    ------------------
78
    -- Basic types: --
79
    ------------------
80
    type Unsigned is array (Natural range <>) of Bit;
81
    type Signed is array (Natural range <>) of Bit;
82
 
83
    subtype UNnibble is Unsigned ( 3 downto 0 ) ;
84
    subtype UNbyte   is Unsigned ( 7 downto 0 ) ;
85
    subtype UNword   is Unsigned (15 downto 0 ) ;
86
    subtype UNlong   is Unsigned (31 downto 0 ) ;
87
 
88
    subtype SInibble is Signed ( 3 downto 0 ) ;
89
    subtype SIbyte   is Signed ( 7 downto 0 ) ;
90
    subtype SIword   is Signed (15 downto 0 ) ;
91
    subtype SIlong   is Signed (31 downto 0 ) ;
92
 
93
    ---------------------------
94
    -- Conversion functions: --
95
    ---------------------------
96
 
97
    function To_Integer (u : Unsigned) return Integer;
98
    function To_Integer (s: Signed) return Integer;
99
 
100
    function To_BitVector (u: Unsigned; size : Integer) return Bit_Vector;
101
 
102
    function To_Unsigned (i, size : Integer) return Unsigned;
103
    function To_Unsigned (s: Signed; size: Integer)  return Unsigned;
104
    function To_Unsigned (u: Unsigned; size: Integer)  return Unsigned;
105
 
106
    function To_Signed (i, size : Integer)  return Signed;
107
    function To_Signed (u : Unsigned; size : Integer) return Signed;
108
    function To_Signed (s: Signed; size: Integer) return Signed;
109
 
110
    ----------------------------------
111
    -- Binary arithmetic functions: --
112
    ----------------------------------
113
 
114
    function "+" (L: Unsigned; R: Unsigned) return Unsigned;
115
    function "+" (L: Signed;   R: Signed)   return Signed;
116
-- ADDED following 4 lines: BHASKER:
117
    function "+" (L: Signed;   R: INTEGER)   return Signed;
118
    function "+" (L: INTEGER;   R: Signed)   return Signed;
119
    function "+" (L: Unsigned;   R: INTEGER)   return Unsigned;
120
    function "+" (L: INTEGER;   R: Unsigned)   return Unsigned;
121
 
122
    function "-" (L: Unsigned; R: Unsigned) return Unsigned;
123
    function "-" (L: Signed;   R: Signed)   return Signed;
124
-- ADDED following 4 lines: BHASKER:
125
    function "-" (L: Signed;   R: INTEGER)   return Signed;
126
    function "-" (L: INTEGER;   R: Signed)   return Signed;
127
    function "-" (L: Unsigned;   R: INTEGER)   return Unsigned;
128
    function "-" (L: INTEGER;   R: Unsigned)   return Unsigned;
129
 
130
    function "*" (L: Unsigned; R: Unsigned) return Unsigned;
131
    function "*" (L: Signed; R: Signed) return Signed;
132
 
133
    function "/" (L: Unsigned; R: Unsigned) return Unsigned;
134
    function "/" (L: Signed; R: Signed) return Signed;
135
 
136
    function "mod" (L: Unsigned; R: Unsigned) return Unsigned;
137
    function "mod" (L: Signed; R: Signed) return Signed;
138
 
139
    function "rem" (L: Unsigned; R: Unsigned) return Unsigned;
140
    function "rem" (L: Signed; R: Signed) return Signed;
141
 
142
    ---------------------------------
143
    -- Unary arithmetic functions: --
144
    ---------------------------------
145
 
146
    function "-" (L: Signed) return Signed;
147
    function "abs" (L: Signed) return Signed;
148
 
149
    ---------------------------
150
    -- Comparison functions: --
151
    ---------------------------
152
    function "<" (L: Unsigned; R: Unsigned) return Boolean;
153
    function "<" (L: Signed;   R: Signed)   return Boolean;
154
 
155
    function "<=" (L: Unsigned; R: Unsigned) return Boolean;
156
    function "<=" (L: Signed;   R: Signed)   return Boolean;
157
 
158
    function ">=" (L: Unsigned; R: Unsigned) return Boolean;
159
    function ">=" (L: Signed;   R: Signed)   return Boolean;
160
 
161
    function ">" (L: Unsigned; R: Unsigned) return Boolean;
162
    function ">" (L: Signed;   R: Signed)   return Boolean;
163
 
164
    function "=" (L: Unsigned; R: Integer)  return Boolean;
165
    function "=" (L: Unsigned; R: Unsigned) return Boolean;
166
    function "=" (L: Signed;   R: Signed)   return Boolean;
167
 
168
    function "/=" (L: Unsigned; R: Unsigned) return Boolean;
169
    function "/=" (L: Signed;   R: Signed)   return Boolean;
170
 
171
    ------------------------
172
    -- Shift   functions: --
173
    ------------------------
174
 
175
    function Shift_Left  (u : Unsigned; size : Natural) return Unsigned;
176
    function Shift_Left  (s: Signed;    size : Natural) return Signed;
177
    function Shift_Right (u: Unsigned;  size : Natural)  return Unsigned;
178
    function Shift_Right (s: Signed;    size : Natural)  return Signed;
179
 
180
    -------------------------------
181
    -- preset / clear procedure: --
182
    -------------------------------
183
    procedure Preset_Clear (signal FF: out Unsigned; Pc_Value: Unsigned);
184
    procedure Preset_Clear (signal FF: out Signed; Pc_Value: Signed);
185
 
186
  -------------------------
187
  -- types for MacroSyn: --
188
  -------------------------
189
 
190
  type Bcd_Bit_Vector is array (Natural range <>) of Bit;
191
  type Johnson_Bit_Vector is array (Natural range <>) of Bit;
192
  type Xs_3_Bit_Vector is array (Natural range <>) of Bit;
193
  type Xs_3_Gray_Bit_Vector is array (Natural range <>) of Bit;
194
 
195
  ----------------------------------------
196
  -- conversion functions for MacroSyn: --
197
  ----------------------------------------
198
  function To_Integer (opd: Bcd_Bit_Vector) return Integer;
199
  function To_Integer (opd: Xs_3_Bit_Vector) return Integer;
200
  function To_Integer (opd: Xs_3_Gray_Bit_Vector) return Integer;
201
  function To_Integer (opd: Johnson_Bit_Vector) return Integer;
202
 
203
 
204
    attribute BUILT_IN: Boolean;                           --D
205
    attribute BUILT_IN of EXT: function is TRUE;           --D
206
    attribute BUILT_IN of TRUNC: function is TRUE;         --D
207
    attribute BUILT_IN of Shift_Left: function is TRUE;    --D
208
    attribute BUILT_IN of Shift_Right: function is TRUE;   --D
209
    attribute BUILT_IN of Preset_Clear: procedure is TRUE; --D
210
 
211
   attribute Built_In of To_Integer   : function is TRUE;   --D
212
   attribute Built_In of To_BitVector : function is TRUE;   --D
213
   attribute Built_In of To_Unsigned  : function is TRUE;   --D
214
   attribute Built_In of To_Signed    : function is TRUE;   --D
215
 
216
--****** 4 NEW LINES Added: BHASKER:
217
  function MAX (L, R: INTEGER) return INTEGER;
218
  function MIN (L, R: INTEGER) return INTEGER;
219
 
220
  attribute BUILT_IN of MAX: function is TRUE;
221
  attribute BUILT_IN of MIN: function is TRUE;
222
 
223
end Bit_Arith;
224
 

powered by: WebSVN 2.1.0

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