1-- ----------------------------------------------------------------- 2-- 3-- Copyright 2019 IEEE P1076 WG Authors 4-- 5-- See the LICENSE file distributed with this work for copyright and 6-- licensing information and the AUTHORS file. 7-- 8-- This file to you under the Apache License, Version 2.0 (the "License"). 9-- You may obtain a copy of the License at 10-- 11-- http://www.apache.org/licenses/LICENSE-2.0 12-- 13-- Unless required by applicable law or agreed to in writing, software 14-- distributed under the License is distributed on an "AS IS" BASIS, 15-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 16-- implied. See the License for the specific language governing 17-- permissions and limitations under the License. 18-- 19-- Title : Standard VHDL Synthesis Packages 20-- : (NUMERIC_BIT_UNSIGNED package declaration) 21-- : 22-- Library : This package shall be compiled into a library 23-- : symbolically named IEEE. 24-- : 25-- Developers: Accellera VHDL-TC, and IEEE P1076 Working Group 26-- : 27-- Purpose : This package defines numeric types and arithmetic functions 28-- : for use with synthesis tools. Values of type BIT_VECTOR 29-- : are interpreted as unsigned numbers in vector form. 30-- : The leftmost bit is treated as the most significant bit. 31-- : This package contains overloaded arithmetic operators on 32-- : the BIT_VECTOR type. The package also contains 33-- : useful type conversions functions, clock detection 34-- : functions, and other utility functions. 35-- : 36-- : If any argument to a function is a null array, a null array 37-- : is returned (exceptions, if any, are noted individually). 38-- 39-- Note : This package may be modified to include additional data 40-- : required by tools, but it must in no way change the 41-- : external interfaces or simulation behavior of the 42-- : description. It is permissible to add comments and/or 43-- : attributes to the package declarations, but not to change 44-- : or delete any original lines of the package declaration. 45-- : The package body may be changed only in accordance with 46-- : the terms of Clause 16 of this standard. 47-- : 48-- -------------------------------------------------------------------- 49-- $Revision: 1220 $ 50-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ 51-- -------------------------------------------------------------------- 52 53package NUMERIC_BIT_UNSIGNED is 54 constant CopyRightNotice : STRING := 55 "Copyright IEEE P1076 WG. Licensed Apache 2.0"; 56 57 -- Id: A.3 58 function "+" (L, R : BIT_VECTOR) return BIT_VECTOR; 59 -- Result subtype: bit_vector(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). 60 -- Result: Adds two UNSIGNED vectors that may be of different lengths. 61 62 -- Id: A.3R 63 function "+"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR; 64 -- Result subtype: bit_vector(L'LENGTH-1 downto 0) 65 -- Result: Similar to A.3 where R is a one bit bit_vector 66 67 -- Id: A.3L 68 function "+"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR; 69 -- Result subtype: bit_vector(R'LENGTH-1 downto 0) 70 -- Result: Similar to A.3 where L is a one bit UNSIGNED 71 72 -- Id: A.5 73 function "+" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; 74 -- Result subtype: bit_vector(L'LENGTH-1 downto 0). 75 -- Result: Adds an UNSIGNED vector, L, with a non-negative INTEGER, R. 76 77 -- Id: A.6 78 function "+" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; 79 -- Result subtype: bit_vector(R'LENGTH-1 downto 0). 80 -- Result: Adds a non-negative INTEGER, L, with an UNSIGNED vector, R. 81 82 --============================================================================ 83 84 -- Id: A.9 85 function "-" (L, R : BIT_VECTOR) return BIT_VECTOR; 86 -- Result subtype: UNSIGNED(MAXIMUM(L'LENGTH, R'LENGTH)-1 downto 0). 87 -- Result: Subtracts two UNSIGNED vectors that may be of different lengths. 88 89 -- Id: A.9R 90 function "-"(L : BIT_VECTOR; R : BIT) return BIT_VECTOR; 91 -- Result subtype: bit_vector(L'LENGTH-1 downto 0) 92 -- Result: Similar to A.9 where R is a one bit UNSIGNED 93 94 -- Id: A.9L 95 function "-"(L : BIT; R : BIT_VECTOR) return BIT_VECTOR; 96 -- Result subtype: bit_vector(R'LENGTH-1 downto 0) 97 -- Result: Similar to A.9 where L is a one bit UNSIGNED 98 99 -- Id: A.11 100 function "-" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; 101 -- Result subtype: bit_vector(L'LENGTH-1 downto 0). 102 -- Result: Subtracts a non-negative INTEGER, R, from an UNSIGNED vector, L. 103 104 -- Id: A.12 105 function "-" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; 106 -- Result subtype: bit_vector(R'LENGTH-1 downto 0). 107 -- Result: Subtracts an UNSIGNED vector, R, from a non-negative INTEGER, L. 108 109 --============================================================================ 110 111 -- Id: A.15 112 function "*" (L, R : BIT_VECTOR) return BIT_VECTOR; 113 -- Result subtype: bit_vector((L'LENGTH+R'LENGTH-1) downto 0). 114 -- Result: Performs the multiplication operation on two UNSIGNED vectors 115 -- that may possibly be of different lengths. 116 117 -- Id: A.17 118 function "*" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; 119 -- Result subtype: bit_vector((L'LENGTH+L'LENGTH-1) downto 0). 120 -- Result: Multiplies an UNSIGNED vector, L, with a non-negative 121 -- INTEGER, R. R is converted to an UNSIGNED vector of 122 -- SIZE L'LENGTH before multiplication. 123 124 -- Id: A.18 125 function "*" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; 126 -- Result subtype: bit_vector((R'LENGTH+R'LENGTH-1) downto 0). 127 -- Result: Multiplies an UNSIGNED vector, R, with a non-negative 128 -- INTEGER, L. L is converted to an UNSIGNED vector of 129 -- SIZE R'LENGTH before multiplication. 130 131 --============================================================================ 132 -- 133 -- NOTE: If second argument is zero for "/" operator, a severity level 134 -- of ERROR is issued. 135 136 -- Id: A.21 137 function "/" (L, R : BIT_VECTOR) return BIT_VECTOR; 138 -- Result subtype: bit_vector(L'LENGTH-1 downto 0) 139 -- Result: Divides an UNSIGNED vector, L, by another UNSIGNED vector, R. 140 141 -- Id: A.23 142 function "/" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; 143 -- Result subtype: bit_vector(L'LENGTH-1 downto 0) 144 -- Result: Divides an UNSIGNED vector, L, by a non-negative INTEGER, R. 145 -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. 146 147 -- Id: A.24 148 function "/" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; 149 -- Result subtype: bit_vector(R'LENGTH-1 downto 0) 150 -- Result: Divides a non-negative INTEGER, L, by an UNSIGNED vector, R. 151 -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. 152 153 --============================================================================ 154 -- 155 -- NOTE: If second argument is zero for "rem" operator, a severity level 156 -- of ERROR is issued. 157 158 -- Id: A.27 159 function "rem" (L, R : BIT_VECTOR) return BIT_VECTOR; 160 -- Result subtype: bit_vector(R'LENGTH-1 downto 0) 161 -- Result: Computes "L rem R" where L and R are UNSIGNED vectors. 162 163 -- Id: A.29 164 function "rem" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; 165 -- Result subtype: bit_vector(L'LENGTH-1 downto 0) 166 -- Result: Computes "L rem R" where L is an UNSIGNED vector and R is a 167 -- non-negative INTEGER. 168 -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. 169 170 -- Id: A.30 171 function "rem" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; 172 -- Result subtype: bit_vector(R'LENGTH-1 downto 0) 173 -- Result: Computes "L rem R" where R is an UNSIGNED vector and L is a 174 -- non-negative INTEGER. 175 -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. 176 177 --============================================================================ 178 -- 179 -- NOTE: If second argument is zero for "mod" operator, a severity level 180 -- of ERROR is issued. 181 182 -- Id: A.33 183 function "mod" (L, R : BIT_VECTOR) return BIT_VECTOR; 184 -- Result subtype: bit_vector(R'LENGTH-1 downto 0) 185 -- Result: Computes "L mod R" where L and R are UNSIGNED vectors. 186 187 -- Id: A.35 188 function "mod" (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; 189 -- Result subtype: bit_vector(L'LENGTH-1 downto 0) 190 -- Result: Computes "L mod R" where L is an UNSIGNED vector and R 191 -- is a non-negative INTEGER. 192 -- If NO_OF_BITS(R) > L'LENGTH, result is truncated to L'LENGTH. 193 194 -- Id: A.36 195 function "mod" (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; 196 -- Result subtype: bit_vector(R'LENGTH-1 downto 0) 197 -- Result: Computes "L mod R" where R is an UNSIGNED vector and L 198 -- is a non-negative INTEGER. 199 -- If NO_OF_BITS(L) > R'LENGTH, result is truncated to R'LENGTH. 200 201 --============================================================================ 202 -- Id: A.39 203 function find_leftmost (ARG : BIT_VECTOR; Y : BIT) return INTEGER; 204 -- Result subtype: INTEGER 205 -- Result: Finds the leftmost occurrence of the value of Y in ARG. 206 -- Returns the index of the occurrence if it exists, or -1 otherwise. 207 208 -- Id: A.41 209 function find_rightmost (ARG : BIT_VECTOR; Y : BIT) return INTEGER; 210 -- Result subtype: INTEGER 211 -- Result: Finds the leftmost occurrence of the value of Y in ARG. 212 -- Returns the index of the occurrence if it exists, or -1 otherwise. 213 214 --============================================================================ 215 -- Comparison Operators 216 --============================================================================ 217 -- Id: C.1 218 function ">" (L, R : BIT_VECTOR) return BOOLEAN; 219 -- Result subtype: BOOLEAN 220 -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly 221 -- of different lengths. 222 223 -- Id: C.3 224 function ">" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; 225 -- Result subtype: BOOLEAN 226 -- Result: Computes "L > R" where L is a non-negative INTEGER and 227 -- R is an UNSIGNED vector. 228 229 -- Id: C.5 230 function ">" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; 231 -- Result subtype: BOOLEAN 232 -- Result: Computes "L > R" where L is an UNSIGNED vector and 233 -- R is a non-negative INTEGER. 234 235 --============================================================================ 236 -- Id: C.7 237 function "<" (L, R : BIT_VECTOR) return BOOLEAN; 238 -- Result subtype: BOOLEAN 239 -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly 240 -- of different lengths. 241 242 -- Id: C.9 243 function "<" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; 244 -- Result subtype: BOOLEAN 245 -- Result: Computes "L < R" where L is a non-negative INTEGER and 246 -- R is an UNSIGNED vector. 247 248 -- Id: C.11 249 function "<" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; 250 -- Result subtype: BOOLEAN 251 -- Result: Computes "L < R" where L is an UNSIGNED vector and 252 -- R is a non-negative INTEGER. 253 254 --============================================================================ 255 -- Id: C.13 256 function "<=" (L, R : BIT_VECTOR) return BOOLEAN; 257 -- Result subtype: BOOLEAN 258 -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly 259 -- of different lengths. 260 261 -- Id: C.15 262 function "<=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; 263 -- Result subtype: BOOLEAN 264 -- Result: Computes "L <= R" where L is a non-negative INTEGER and 265 -- R is an UNSIGNED vector. 266 267 -- Id: C.17 268 function "<=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; 269 -- Result subtype: BOOLEAN 270 -- Result: Computes "L <= R" where L is an UNSIGNED vector and 271 -- R is a non-negative INTEGER. 272 273 --============================================================================ 274 -- Id: C.19 275 function ">=" (L, R : BIT_VECTOR) return BOOLEAN; 276 -- Result subtype: BOOLEAN 277 -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly 278 -- of different lengths. 279 280 -- Id: C.21 281 function ">=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; 282 -- Result subtype: BOOLEAN 283 -- Result: Computes "L >= R" where L is a non-negative INTEGER and 284 -- R is an UNSIGNED vector. 285 286 -- Id: C.23 287 function ">=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; 288 -- Result subtype: BOOLEAN 289 -- Result: Computes "L >= R" where L is an UNSIGNED vector and 290 -- R is a non-negative INTEGER. 291 292 --============================================================================ 293 -- Id: C.25 294 function "=" (L, R : BIT_VECTOR) return BOOLEAN; 295 -- Result subtype: BOOLEAN 296 -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly 297 -- of different lengths. 298 299 -- Id: C.27 300 function "=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; 301 -- Result subtype: BOOLEAN 302 -- Result: Computes "L = R" where L is a non-negative INTEGER and 303 -- R is an UNSIGNED vector. 304 305 -- Id: C.29 306 function "=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; 307 -- Result subtype: BOOLEAN 308 -- Result: Computes "L = R" where L is an UNSIGNED vector and 309 -- R is a non-negative INTEGER. 310 311 --============================================================================ 312 313 -- Id: C.31 314 function "/=" (L, R : BIT_VECTOR) return BOOLEAN; 315 -- Result subtype: BOOLEAN 316 -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly 317 -- of different lengths. 318 319 -- Id: C.33 320 function "/=" (L : NATURAL; R : BIT_VECTOR) return BOOLEAN; 321 -- Result subtype: BOOLEAN 322 -- Result: Computes "L /= R" where L is a non-negative INTEGER and 323 -- R is an UNSIGNED vector. 324 325 -- Id: C.35 326 function "/=" (L : BIT_VECTOR; R : NATURAL) return BOOLEAN; 327 -- Result subtype: BOOLEAN 328 -- Result: Computes "L /= R" where L is an UNSIGNED vector and 329 -- R is a non-negative INTEGER. 330 331 --============================================================================ 332 333 -- Id: C.37 334 function MINIMUM (L, R : BIT_VECTOR) return BIT_VECTOR; 335 -- Result subtype: BIT_VECTOR 336 -- Result: Returns the lesser of two UNSIGNED vectors that may be 337 -- of different lengths. 338 339 -- Id: C.39 340 function MINIMUM (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; 341 -- Result subtype: BIT_VECTOR 342 -- Result: Returns the lesser of a nonnegative INTEGER, L, and 343 -- an UNSIGNED vector, R. 344 345 -- Id: C.41 346 function MINIMUM (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; 347 -- Result subtype: BIT_VECTOR 348 -- Result: Returns the lesser of an UNSIGNED vector, L, and 349 -- a nonnegative INTEGER, R. 350 351 --============================================================================ 352 353 -- Id: C.43 354 function MAXIMUM (L, R : BIT_VECTOR) return BIT_VECTOR; 355 -- Result subtype: BIT_VECTOR 356 -- Result: Returns the greater of two UNSIGNED vectors that may be 357 -- of different lengths. 358 359 -- Id: C.45 360 function MAXIMUM (L : NATURAL; R : BIT_VECTOR) return BIT_VECTOR; 361 -- Result subtype: BIT_VECTOR 362 -- Result: Returns the greater of a nonnegative INTEGER, L, and 363 -- an UNSIGNED vector, R. 364 365 -- Id: C.47 366 function MAXIMUM (L : BIT_VECTOR; R : NATURAL) return BIT_VECTOR; 367 -- Result subtype: BIT_VECTOR 368 -- Result: Returns the greater of an UNSIGNED vector, L, and 369 -- a nonnegative INTEGER, R. 370 371 --============================================================================ 372 -- Id: C.49 373 function "?>" (L, R : BIT_VECTOR) return BIT; 374 -- Result subtype: BIT 375 -- Result: Computes "L > R" where L and R are UNSIGNED vectors possibly 376 -- of different lengths. 377 378 -- Id: C.51 379 function "?>" (L : NATURAL; R : BIT_VECTOR) return BIT; 380 -- Result subtype: BIT 381 -- Result: Computes "L > R" where L is a nonnegative INTEGER and 382 -- R is an UNSIGNED vector. 383 384 -- Id: C.53 385 function "?>" (L : BIT_VECTOR; R : NATURAL) return BIT; 386 -- Result subtype: BIT 387 -- Result: Computes "L > R" where L is an UNSIGNED vector and 388 -- R is a nonnegative INTEGER. 389 390 --============================================================================ 391 392 -- Id: C.55 393 function "?<" (L, R : BIT_VECTOR) return BIT; 394 -- Result subtype: BIT 395 -- Result: Computes "L < R" where L and R are UNSIGNED vectors possibly 396 -- of different lengths. 397 398 -- Id: C.57 399 function "?<" (L : NATURAL; R : BIT_VECTOR) return BIT; 400 -- Result subtype: BIT 401 -- Result: Computes "L < R" where L is a nonnegative INTEGER and 402 -- R is an UNSIGNED vector. 403 404 -- Id: C.59 405 function "?<" (L : BIT_VECTOR; R : NATURAL) return BIT; 406 -- Result subtype: BIT 407 -- Result: Computes "L < R" where L is an UNSIGNED vector and 408 -- R is a nonnegative INTEGER. 409 410 --============================================================================ 411 412 -- Id: C.61 413 function "?<=" (L, R : BIT_VECTOR) return BIT; 414 -- Result subtype: BIT 415 -- Result: Computes "L <= R" where L and R are UNSIGNED vectors possibly 416 -- of different lengths. 417 418 -- Id: C.63 419 function "?<=" (L : NATURAL; R : BIT_VECTOR) return BIT; 420 -- Result subtype: BIT 421 -- Result: Computes "L <= R" where L is a nonnegative INTEGER and 422 -- R is an UNSIGNED vector. 423 424 -- Id: C.65 425 function "?<=" (L : BIT_VECTOR; R : NATURAL) return BIT; 426 -- Result subtype: BIT 427 -- Result: Computes "L <= R" where L is an UNSIGNED vector and 428 -- R is a nonnegative INTEGER. 429 430 --============================================================================ 431 432 -- Id: C.67 433 function "?>=" (L, R : BIT_VECTOR) return BIT; 434 -- Result subtype: BIT 435 -- Result: Computes "L >= R" where L and R are UNSIGNED vectors possibly 436 -- of different lengths. 437 438 -- Id: C.69 439 function "?>=" (L : NATURAL; R : BIT_VECTOR) return BIT; 440 -- Result subtype: BIT 441 -- Result: Computes "L >= R" where L is a nonnegative INTEGER and 442 -- R is an UNSIGNED vector. 443 444 -- Id: C.71 445 function "?>=" (L : BIT_VECTOR; R : NATURAL) return BIT; 446 -- Result subtype: BIT 447 -- Result: Computes "L >= R" where L is an UNSIGNED vector and 448 -- R is a nonnegative INTEGER. 449 450 --============================================================================ 451 452 -- Id: C.73 453 function "?=" (L, R : BIT_VECTOR) return BIT; 454 -- Result subtype: BIT 455 -- Result: Computes "L = R" where L and R are UNSIGNED vectors possibly 456 -- of different lengths. 457 458 -- Id: C.75 459 function "?=" (L : NATURAL; R : BIT_VECTOR) return BIT; 460 -- Result subtype: BIT 461 -- Result: Computes "L = R" where L is a nonnegative INTEGER and 462 -- R is an UNSIGNED vector. 463 464 -- Id: C.77 465 function "?=" (L : BIT_VECTOR; R : NATURAL) return BIT; 466 -- Result subtype: BIT 467 -- Result: Computes "L = R" where L is an UNSIGNED vector and 468 -- R is a nonnegative INTEGER. 469 470 --============================================================================ 471 472 -- Id: C.79 473 function "?/=" (L, R : BIT_VECTOR) return BIT; 474 -- Result subtype: BIT 475 -- Result: Computes "L /= R" where L and R are UNSIGNED vectors possibly 476 -- of different lengths. 477 478 -- Id: C.81 479 function "?/=" (L : NATURAL; R : BIT_VECTOR) return BIT; 480 -- Result subtype: BIT 481 -- Result: Computes "L /= R" where L is a nonnegative INTEGER and 482 -- R is an UNSIGNED vector. 483 484 -- Id: C.83 485 function "?/=" (L : BIT_VECTOR; R : NATURAL) return BIT; 486 -- Result subtype: BIT 487 -- Result: Computes "L /= R" where L is an UNSIGNED vector and 488 -- R is a nonnegative INTEGER. 489 490 --============================================================================ 491 -- Shift and Rotate Functions 492 --============================================================================ 493 494 -- Id: S.1 495 function SHIFT_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; 496 -- Result subtype: bit_vector(ARG'LENGTH-1 downto 0) 497 -- Result: Performs a shift-left on an UNSIGNED vector COUNT times. 498 -- The vacated positions are filled with '0'. 499 -- The COUNT leftmost elements are lost. 500 501 -- Id: S.2 502 function SHIFT_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; 503 -- Result subtype: UNSIGNED(ARG'LENGTH-1 downto 0) 504 -- Result: Performs a shift-right on an UNSIGNED vector COUNT times. 505 -- The vacated positions are filled with '0'. 506 -- The COUNT rightmost elements are lost. 507 --============================================================================ 508 509 -- Id: S.5 510 function ROTATE_LEFT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; 511 -- Result subtype: bit_vector(ARG'LENGTH-1 downto 0) 512 -- Result: Performs a rotate-left of an UNSIGNED vector COUNT times. 513 514 -- Id: S.6 515 function ROTATE_RIGHT (ARG : BIT_VECTOR; COUNT : NATURAL) return BIT_VECTOR; 516 -- Result subtype: bit_vector(ARG'LENGTH-1 downto 0) 517 -- Result: Performs a rotate-right of an UNSIGNED vector COUNT times. 518 519 520 --============================================================================ 521 522 ------------------------------------------------------------------------------ 523 -- Note: Function S.9 is not compatible with IEEE Std 1076-1987. Comment 524 -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. 525 ------------------------------------------------------------------------------ 526 -- Id: S.9 527 function "sll" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; 528 -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) 529 -- Result: SHIFT_LEFT(ARG, COUNT) 530 531 ------------------------------------------------------------------------------ 532 -- Note: Function S.11 is not compatible with IEEE Std 1076-1987. Comment 533 -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. 534 ------------------------------------------------------------------------------ 535 -- Id: S.11 536 function "srl" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; 537 -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) 538 -- Result: SHIFT_RIGHT(ARG, COUNT) 539 540 ------------------------------------------------------------------------------ 541 -- Note: Function S.13 is not compatible with IEEE Std 1076-1987. Comment 542 -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. 543 ------------------------------------------------------------------------------ 544 -- Id: S.13 545 function "rol" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; 546 -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) 547 -- Result: ROTATE_LEFT(ARG, COUNT) 548 549 ------------------------------------------------------------------------------ 550 -- Note: Function S.15 is not compatible with IEEE Std 1076-1987. Comment 551 -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. 552 ------------------------------------------------------------------------------ 553 -- Id: S.15 554 function "ror" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; 555 -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) 556 -- Result: ROTATE_RIGHT(ARG, COUNT) 557 558 ------------------------------------------------------------------------------ 559 -- Note: Function S.17 is not compatible with IEEE Std 1076-1987. Comment 560 -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. 561 ------------------------------------------------------------------------------ 562 -- Id: S.17 563 function "sla" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; 564 -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) 565 -- Result: SHIFT_LEFT(ARG, COUNT) 566 567 ------------------------------------------------------------------------------ 568 -- Note: Function S.19 is not compatible with IEEE Std 1076-1987. Comment 569 -- out the function (declaration and body) for IEEE Std 1076-1987 compatibility. 570 ------------------------------------------------------------------------------ 571 -- Id: S.19 572 function "sra" (ARG : BIT_VECTOR; COUNT : INTEGER) return BIT_VECTOR; 573 -- Result subtype: BIT_VECTOR(ARG'LENGTH-1 downto 0) 574 -- Result: SHIFT_RIGHT(ARG, COUNT) 575 576 577 --============================================================================ 578 -- RESIZE Functions 579 --============================================================================ 580 581 -- Id: R.2 582 function RESIZE (ARG : BIT_VECTOR; NEW_SIZE : NATURAL) return BIT_VECTOR; 583 -- Result subtype: bit_vector(NEW_SIZE-1 downto 0) 584 -- Result: Resizes the UNSIGNED vector ARG to the specified size. 585 -- To create a larger vector, the new [leftmost] bit positions 586 -- are filled with '0'. When truncating, the leftmost bits 587 -- are dropped. 588 589 function RESIZE (ARG, SIZE_RES : BIT_VECTOR) return BIT_VECTOR; 590 -- Result subtype: BIT_VECTOR (SIZE_RES'length-1 downto 0) 591 592 --============================================================================ 593 -- Conversion Functions 594 --============================================================================ 595 596 -- Id: D.1 597 function TO_INTEGER (ARG : BIT_VECTOR) return NATURAL; 598 -- Result subtype: NATURAL. Value cannot be negative since parameter is an 599 -- UNSIGNED vector. 600 -- Result: Converts the UNSIGNED vector to an INTEGER. 601 602 -- Id: D.3 603 function To_BitVector (ARG, SIZE : NATURAL) return BIT_VECTOR; 604 -- Result subtype: bit_vector(SIZE-1 downto 0) 605 -- Result: Converts a non-negative INTEGER to an UNSIGNED vector with 606 -- the specified size. 607 608 function To_BitVector (ARG : NATURAL; SIZE_RES : BIT_VECTOR) 609 return BIT_VECTOR; 610 -- Result subtype: STD_LOGIC_VECTOR(SIZE_RES'length-1 downto 0) 611 612-- begin LCS-2006-130 613 alias To_Bit_Vector is 614 To_BitVector[NATURAL, NATURAL return BIT_VECTOR]; 615 alias To_BV is 616 To_BitVector[NATURAL, NATURAL return BIT_VECTOR]; 617 618 alias To_Bit_Vector is 619 To_BitVector[NATURAL, BIT_VECTOR return BIT_VECTOR]; 620 alias To_BV is 621 To_BitVector[NATURAL, BIT_VECTOR return BIT_VECTOR]; 622 623end package NUMERIC_BIT_UNSIGNED; 624