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_05_pk_test.vhd,v 1.2 2001-10-24 23:30:59 paw Exp $
23-- $Revision: 1.2 $
24--
25-- ---------------------------------------------------------------------
26
27package stimulus_generators is
28
29  procedure all_possible_values ( signal bv : out bit_vector;
30				  delay_between_values : in delay_length );
31
32end package stimulus_generators;
33
34package body stimulus_generators is
35
36  type digit_table is array ( natural range 0 to 1 ) of bit;
37  constant digit : digit_table := ( '0', '1' );
38
39  function natural_to_bv ( nat : in natural;
40      	      	      	   length : in natural ) return bit_vector is
41
42    variable temp : natural := nat;
43    variable result : bit_vector(0 to length - 1);
44
45  begin
46    for index in result'reverse_range loop
47      result(index) := digit( temp rem 2 );
48      temp := temp / 2;
49    end loop;
50    return result;
51  end function natural_to_bv;
52
53  procedure all_possible_values ( signal bv : out bit_vector;
54				  delay_between_values : in delay_length ) is
55  begin
56    bv <= natural_to_bv(0, bv'length);
57    for value in 1 to 2**bv'length - 1 loop
58      wait for delay_between_values;
59      bv <= natural_to_bv(value, bv'length);
60    end loop;
61  end procedure all_possible_values;
62
63end package body stimulus_generators;
64