Project

General

Profile

Download (2.14 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_11_fg_11_05.vhd,v 1.1.1.1 2001-08-22 18:20:48 paw Exp $
23
-- $Revision: 1.1.1.1 $
24
--
25
-- ---------------------------------------------------------------------
26

    
27
package words is
28

    
29
  type X01Z is ('X', '0', '1', 'Z');
30
  type uword is array (0 to 31) of X01Z;
31

    
32
  type uword_vector is array (natural range <>) of uword;
33

    
34
  function resolve_word ( contribution : uword_vector ) return uword;
35

    
36
  subtype word is resolve_word uword;
37

    
38
  -- not in book
39
  type ubyte is array (0 to 7) of X01Z;
40
  -- end not in book
41

    
42
end package words;
43

    
44
--------------------------------------------------
45

    
46
package body words is
47

    
48
  type table is array (X01Z, X01Z) of X01Z;
49

    
50
  constant resolution_table : table :=
51
    --  'X'  '0'  '1'  'Z'
52
    --  ------------------
53
    ( ( 'X', 'X', 'X', 'X' ),    -- 'X'
54
      ( 'X', '0', 'X', '0' ),    -- '0'
55
      ( 'X', 'X', '1', '1' ),    -- '1'
56
      ( 'X', '0', '1', 'Z' ) );  -- 'Z'
57

    
58
  function resolve_word ( contribution : uword_vector ) return uword is
59
    variable result : uword := (others => 'Z');
60
  begin
61
    for index in contribution'range loop
62
      for element in uword'range loop
63
        result(element) :=
64
          resolution_table( result(element), contribution(index)(element) );
65
      end loop;
66
    end loop;
67
    return result;
68
  end function resolve_word;
69

    
70
end package body words;
(180-180/267)