Project

General

Profile

Download (2 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: ch_10_chkmult.vhd,v 1.3 2001-10-26 16:29:35 paw Exp $
23
-- $Revision: 1.3 $
24
--
25
-- ---------------------------------------------------------------------
26

    
27
entity check_mult is
28
end entity check_mult;
29

    
30
library bv_utilities;
31
use bv_utilities.bv_arithmetic.all;
32

    
33
architecture behav of check_mult is
34

    
35
begin
36

    
37
  checker : process is
38

    
39
                      variable bv_a, bv_b, bv_product : bit_vector(3 downto 0);
40
                    variable overflow : 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_multu(bv_a, bv_b, bv_product, overflow);
48
	if a * b > 15 then
49
	  assert overflow
50
	    report integer'image(a) & '*' & integer'image(b)
51
            & ": overflow not true";
52
	else
53
	  assert not overflow
54
	    report integer'image(a) & '*' & integer'image(b)
55
            & ": overflow not false";
56
	  assert bv_to_natural(bv_product) = a * b
57
	    report integer'image(a) & '*' & integer'image(b)
58
            & ": product = " & integer'image(bv_to_natural(bv_product));
59
	end if;
60
      end loop;
61
    end loop;
62
    wait;
63
  end process checker;
64

    
65
end architecture behav;
(173-173/267)