Project

General

Profile

Download (4.24 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_13_fg_13_23.vhd,v 1.2 2001-10-26 16:29:35 paw Exp $
23
-- $Revision: 1.2 $
24
--
25
-- ---------------------------------------------------------------------
26

    
27
library ieee;  use ieee.std_logic_1164.all;
28

    
29
               entity nor_gate is
30
                 generic ( width : positive;
31
                           Tpd01, Tpd10 : delay_length );
32
                 port ( input : in std_logic_vector(0 to width - 1);
33
                        output : out std_logic );
34
               end entity nor_gate;
35

    
36

    
37
               architecture primitive of nor_gate is
38

    
39
                 function max ( a, b : delay_length ) return delay_length is
40
                 begin
41
                   if a > b then
42
                     return a;
43
                   else
44
                     return b;
45
                   end if;
46
                 end function max;
47

    
48
               begin
49

    
50
                 reducer : process (input) is
51
                                             variable result : std_logic;
52
                 begin
53
                   result := '0';
54
                   for index in input'range loop
55
                     result := result or input(index);
56
                   end loop;
57
                   if not result = '1' then
58
                     output <= not result after Tpd01;
59
                   elsif not result = '0' then
60
                     output <= not result after Tpd10;
61
                   else
62
                     output <= not result after max(Tpd01, Tpd10);
63
                   end if;
64
                 end process reducer;
65

    
66
               end architecture primitive;
67

    
68

    
69

    
70
               library ieee;  use ieee.std_logic_1164.all;
71
               library cell_lib;
72

    
73
               entity interlock_control is
74
               end entity interlock_control;
75

    
76

    
77
-- code from book
78

    
79
               architecture detailed_timing of interlock_control is
80

    
81
                 component nor_gate is
82
                                      generic ( input_width : positive );
83
                                    port ( input : in std_logic_vector(0 to input_width - 1);
84
                                           output : out std_logic );
85
                 end component nor_gate;
86

    
87
                 for ex_interlock_gate : nor_gate
88
                   use entity cell_lib.nor_gate(primitive)
89
                   generic map ( width => input_width,
90
                                 Tpd01 => 250 ps, Tpd10 => 200 ps );  -- estimates
91

    
92
                 -- . . .
93

    
94
                 -- not in book
95
                 signal reg_access_hazard, load_hazard, stall_ex_n : std_logic;
96
                 -- end not in book
97

    
98
               begin
99

    
100
                 ex_interlock_gate : component nor_gate
101
                   generic map ( input_width => 2 )
102
                   port map ( input(0) => reg_access_hazard,
103
                              input(1) => load_hazard,
104
                              output => stall_ex_n);
105

    
106
                 -- . . .
107

    
108
                 -- not in book
109

    
110
                 reg_access_hazard <= '0' after 10 ns, '1' after 20 ns, 'X' after 30 ns;
111

    
112
                 load_hazard <= '0' after 2 ns, '1' after 4 ns, 'X' after 6 ns,
113
                                '0' after 12 ns, '1' after 14 ns, 'X' after 16 ns,
114
                                '0' after 22 ns, '1' after 24 ns, 'X' after 26 ns,
115
                                '0' after 32 ns, '1' after 34 ns, 'X' after 36 ns;
116

    
117
                 -- end not in book
118

    
119
               end architecture detailed_timing;
120

    
121
-- end code from book
(223-223/510)