Project

General

Profile

Download (1.92 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
-- Copyright (C) 2002 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
entity bv_lt is
21
end entity bv_lt;
22

    
23

    
24

    
25
architecture test of bv_lt is
26

    
27
  -- code from book
28

    
29
  procedure bv_lt ( bv1, bv2 : in bit_vector;  result : out boolean ) is
30
    variable tmp1 : bit_vector(bv1'range) := bv1;
31
    variable tmp2 : bit_vector(bv2'range) := bv2;
32
  begin
33
    tmp1(tmp1'left) := not tmp1(tmp1'left);
34
    tmp2(tmp2'left) := not tmp2(tmp2'left);
35
    result :=  tmp1 < tmp2;
36
  end procedure bv_lt;
37

    
38
  -- end code from book
39

    
40
begin
41

    
42
  stimulus : process is
43

    
44
    subtype byte is bit_vector(0 to 7);
45
    variable result : boolean;
46

    
47
  begin
48
    bv_lt( byte'(X"02"), byte'(X"04"), result );
49
    assert result;
50

    
51
    bv_lt( byte'(X"02"), byte'(X"02"), result );
52
    assert not result;
53

    
54
    bv_lt( byte'(X"02"), byte'(X"02"), result );
55
    assert not result;
56

    
57
    bv_lt( byte'(X"FC"), byte'(X"04"), result );
58
    assert result;
59

    
60
    bv_lt( byte'(X"04"), byte'(X"FC"), result );
61
    assert not result;
62

    
63
    bv_lt( byte'(X"FC"), byte'(X"FC"), result );
64
    assert not result;
65

    
66
    bv_lt( byte'(X"FC"), byte'(X"FE"), result );
67
    assert result;
68

    
69
    bv_lt( byte'(X"FE"), byte'(X"FC"), result );
70
    assert not result;
71

    
72
    wait;
73
  end process stimulus;
74

    
75
end architecture test;
(2-2/12)