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 021111307 USA

19


20

 

21



22

 $Id: ch_08_fg_08_08.vhd,v 1.3 20011026 16:29:34 paw Exp $

23

 $Revision: 1.3 $

24



25

 

26


27

package bit_vector_signed_arithmetic is

28


29

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

30


31

function "" ( bv : bit_vector ) return bit_vector;

32


33

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

34


35

 . . .

36


37

end package bit_vector_signed_arithmetic;

38


39

 not in book

40

library bv_utilities;

41

use bv_utilities.bv_arithmetic;

42

 end not in book

43


44

package body bit_vector_signed_arithmetic is

45


46

function "+" ( bv1, bv2 : bit_vector ) return bit_vector is  . . .

47

 not in book

48

begin

49

return bv_arithmetic."+"(bv1, bv2);

50

end function "+";

51

 end not in book

52


53

function "" ( bv : bit_vector ) return bit_vector is  . . .

54

 not in book

55

begin

56

return bv_arithmetic.""(bv);

57

end function "";

58

 end not in book

59


60

function mult_unsigned ( bv1, bv2 : bit_vector ) return bit_vector is

61

 . . .

62

begin

63

 not in book

64

 . . .

65

return bv_arithmetic.bv_multu(bv1, bv2);

66

 end not in book

67

end function mult_unsigned;

68


69

function "*" ( bv1, bv2 : bit_vector ) return bit_vector is

70

begin

71

if bv1(bv1'left) = '0' and bv2(bv2'left) = '0' then

72

return mult_unsigned(bv1, bv2);

73

elsif bv1(bv1'left) = '0' and bv2(bv2'left) = '1' then

74

return mult_unsigned(bv1, bv2);

75

elsif bv1(bv1'left) = '1' and bv2(bv2'left) = '0' then

76

return mult_unsigned(bv1, bv2);

77

else

78

return mult_unsigned(bv1, bv2);

79

end if;

80

end function "*";

81


82

 . . .

83


84

end package body bit_vector_signed_arithmetic;

85


86

 not in book

87


88

entity fg_08_08 is

89

end entity fg_08_08;

90


91

library bv_utilities;

92

use bv_utilities.bit_vector_signed_arithmetic.all;

93


94

use std.textio.all;

95


96

architecture test of fg_08_08 is

97

begin

98


99

stimulus : process is

100

variable L : line;

101

begin

102

write(L, X"0002" + X"0005");

103

writeline(output, L);

104

write(L, X"0002" + X"FFFE");

105

writeline(output, L);

106

write(L,  X"0005");

107

writeline(output, L);

108

write(L,  X"FFFE");

109

writeline(output, L);

110

write(L, X"0002" * X"0005");

111

writeline(output, L);

112

write(L, X"0002" * X"FFFD");

113

writeline(output, L);

114


115

wait;

116

end process stimulus;

117


118

end architecture test;

119


120

 end not in book
