Project

General

Profile

Download (2.47 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_16_fg_16_05.vhd,v 1.2 2001-10-26 16:29:36 paw Exp $
23
-- $Revision: 1.2 $
24
--
25
-- ---------------------------------------------------------------------
26
27
use work.fg_16_04.all;
28
29
-- code from book (in text)
30
31
entity tri_state_reg is
32
  port ( d : in resolved_byte;
33
         q : out resolved_byte bus;
34
         clock, out_enable : in bit );
35
end entity tri_state_reg;
36
37
-- end code from book
38
39
40
41
-- code from book
42
43
architecture behavioral of tri_state_reg is
44
begin
45
46
  reg_behavior : process (d, clock, out_enable) is
47
                                                  variable stored_byte : byte;
48
  begin
49
    if clock'event and clock = '1' then
50
      stored_byte := d;
51
    end if;
52
    if out_enable = '1' then
53
      q <= stored_byte;
54
    else
55
      q <= null;
56
    end if;
57
  end process reg_behavior;
58
59
end architecture behavioral;
60
61
-- end code from book
62
63
64
65
use work.fg_16_04.all;
66
67
entity fg_16_05 is
68
end entity fg_16_05;
69
70
71
architecture test of fg_16_05 is
72
73
  signal d1, d2, q : resolved_byte := X"00";
74
  signal clk1, clk2, oe1, oe2 : bit := '0';
75
76
begin
77
78
  dut1 : entity work.tri_state_reg(behavioral)
79
    port map ( d => d1, q => q, clock => clk1, out_enable => oe1 );
80
81
  dut2 : entity work.tri_state_reg(behavioral)
82
    port map ( d => d2, q => q, clock => clk2, out_enable => oe2 );
83
84
  stimulus : process is
85
  begin
86
    d1 <= X"11";  clk1 <= '1', '0' after 5 ns;  wait for 10 ns;
87
    oe1 <= '1', '0' after 5 ns;  wait for 10 ns;
88
    d2 <= X"21";  clk2 <= '1', '0' after 5 ns;  wait for 10 ns;
89
    oe2 <= '1', '0' after 5 ns;  wait for 10 ns;
90
    oe1 <= '1', '0' after 5 ns;
91
    oe2 <= '1', '0' after 5 ns;
92
93
    wait;
94
  end process stimulus;
95
96
end architecture test;