Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec-tests / vhdl_json / vhdl_files / 2-exportOK / ghdl / ghdl / testsuite / vests / vhdl-93 / ashenden / compliant / ch_07_fg_07_18.vhd @ 3fd18385

History | View | Annotate | Download (2.66 KB)

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_07_fg_07_18.vhd,v 1.2 2001-10-26 16:29:34 paw Exp $
23
-- $Revision: 1.2 $
24
--
25
-- ---------------------------------------------------------------------
26

    
27
entity fg_07_18 is
28
end entity fg_07_18;
29

    
30

    
31
architecture test of fg_07_18 is
32

    
33
  constant target_host_id : natural := 10;
34
  constant my_host_id : natural := 5;
35
  type pkt_types is (control_pkt, other_pkt);
36
  type pkt_header is record
37
                       dest, src : natural;
38
                       pkt_type : pkt_types;
39
                       seq : natural;
40
                     end record;
41

    
42
begin
43

    
44
  -- code from book
45

    
46
  network_driver : process is
47

    
48
                             constant seq_modulo : natural := 2**5;
49
                           subtype seq_number is natural range 0 to seq_modulo-1;
50
                           variable next_seq_number : seq_number := 0;
51
                           -- . . .
52
                           -- not in book
53
                           variable new_header : pkt_header;
54
                           -- end not in book
55

    
56
                           impure function generate_seq_number return seq_number is
57
                             variable number : seq_number;
58
                           begin
59
                             number := next_seq_number;
60
                             next_seq_number := (next_seq_number + 1) mod seq_modulo;
61
                             return number;
62
                           end function generate_seq_number;
63

    
64
  begin  -- network_driver
65
    -- not in book
66
    wait for 10 ns;
67
    -- end not in book
68
    -- . . .
69
    new_header := pkt_header'( dest => target_host_id,
70
                               src => my_host_id,
71
                               pkt_type => control_pkt,
72
                               seq => generate_seq_number );
73
    -- . . .
74
  end process network_driver;
75

    
76
  -- end code from book
77

    
78
end architecture test;