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_10_chkdiv.vhd,v 1.3 20011026 16:29:35 paw Exp $

23

 $Revision: 1.3 $

24



25

 

26


27

entity check_div is

28

end entity check_div;

29


30

library bv_utilities;

31

use bv_utilities.bv_arithmetic.all;

32


33

architecture behav of check_div is

34


35

begin

36


37

checker : process is

38


39

variable bv_a, bv_b, bv_quotient, bv_remainder : bit_vector(3 downto 0);

40

variable div_by_zero : boolean;

41


42

begin

43

for a in 0 to 15 loop

44

for b in 0 to 15 loop

45

bv_a := natural_to_bv(a, bv_a'length);

46

bv_b := natural_to_bv(b, bv_b'length);

47

bv_divu(bv_a, bv_b, bv_quotient, bv_remainder, div_by_zero);

48

if b = 0 then

49

assert div_by_zero

50

report integer'image(a) & '/' & integer'image(b)

51

& ": div_by_zero not true";

52

else

53

assert not div_by_zero

54

report integer'image(a) & '/' & integer'image(b)

55

& ": div_by_zero not false";

56

assert bv_to_natural(bv_quotient) = a / b

57

report integer'image(a) & '/' & integer'image(b)

58

& ": quotient = " & integer'image(bv_to_natural(bv_quotient));

59

assert bv_to_natural(bv_remainder) = a rem b

60

report integer'image(a) & '/' & integer'image(b)

61

& ": remainder = " & integer'image(bv_to_natural(bv_remainder));

62

end if;

63

end loop;

64

end loop;

65

wait;

66

end process checker;

67


68

end architecture behav;
