Project

General

Profile

Download (2.61 KB) Statistics
| Branch: | Tag: | Revision:
1 d93979b7 Arnaud Dieumegard
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_17_fg_17_08.vhd,v 1.2 2001-10-26 16:29:36 paw Exp $
23
-- $Revision: 1.2 $
24
--
25
-- ---------------------------------------------------------------------
26
27
package bounded_buffer_adt is
28
29
  subtype byte is bit_vector(0 to 7);
30
31
  type bounded_buffer_object;  -- private
32
33
  type bounded_buffer is access bounded_buffer_object;
34
35
  function new_bounded_buffer ( size : in positive ) return bounded_buffer;
36
  -- creates a bounded buffer object with 'size' bytes of storage
37
38
  procedure test_empty ( variable the_bounded_buffer : in bounded_buffer;
39
                         is_empty : out boolean );
40
  -- tests whether the bounded buffer is empty (i.e., no data to read)
41
42
  procedure test_full ( variable the_bounded_buffer : in bounded_buffer;
43
                        is_full : out boolean );
44
  -- tests whether the bounded buffer is full (i.e., no data can be written)
45
46
  procedure write ( the_bounded_buffer : inout bounded_buffer;  data : in byte );
47
  -- if the bounded buffer is not full, writes the data
48
  -- if it is full, assertion violation with severity failure
49
50
  procedure read ( the_bounded_buffer : inout bounded_buffer;  data : out byte );
51
  -- if the bounded buffer is not empty, read the first byte of data
52
  -- if it is empty, assertion violation with severity failure
53
54
  --------------------------------------------------
55
56
  -- the following types are private to the ADT
57
58
  type store_array is array (natural range <>) of byte;
59
60
  type store_ptr is access store_array;
61
62
  type bounded_buffer_object is record
63
                                  byte_count : natural;
64
                                  head_index, tail_index : natural;
65
                                  store : store_ptr;
66
                                end record bounded_buffer_object;
67
68
end package bounded_buffer_adt;