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_05_fg_05_27.vhd,v 1.2 2001-10-26 16:29:34 paw Exp $
|
23
|
-- $Revision: 1.2 $
|
24
|
--
|
25
|
-- ---------------------------------------------------------------------
|
26
|
|
27
|
-- not in book
|
28
|
|
29
|
use work.counter_types.all;
|
30
|
|
31
|
-- end not in book
|
32
|
|
33
|
|
34
|
entity counter is
|
35
|
port ( clk, clr : in bit;
|
36
|
q0, q1 : out digit );
|
37
|
end entity counter;
|
38
|
|
39
|
--------------------------------------------------
|
40
|
|
41
|
architecture registered of counter is
|
42
|
|
43
|
signal current_val0, current_val1, next_val0, next_val1 : digit;
|
44
|
|
45
|
begin
|
46
|
|
47
|
val0_reg : entity work.reg4(struct)
|
48
|
port map ( d0 => next_val0(0), d1 => next_val0(1),
|
49
|
d2 => next_val0(2), d3 => next_val0(3),
|
50
|
q0 => current_val0(0), q1 => current_val0(1),
|
51
|
q2 => current_val0(2), q3 => current_val0(3),
|
52
|
clk => clk, clr => clr );
|
53
|
|
54
|
val1_reg : entity work.reg4(struct)
|
55
|
port map ( d0 => next_val1(0), d1 => next_val1(1),
|
56
|
d2 => next_val1(2), d3 => next_val1(3),
|
57
|
q0 => current_val1(0), q1 => current_val1(1),
|
58
|
q2 => current_val1(2), q3 => current_val1(3),
|
59
|
clk => clk, clr => clr );
|
60
|
|
61
|
incr0 : entity work.add_1(boolean_eqn) -- . . .;
|
62
|
-- not in book
|
63
|
port map ( d0 => current_val0(0), d1 => current_val0(1),
|
64
|
d2 => current_val0(2), d3 => current_val0(3),
|
65
|
y0 => next_val0(0), y1 => next_val0(1),
|
66
|
y2 => next_val0(2), y3 => next_val0(3) );
|
67
|
-- end not in book
|
68
|
|
69
|
incr1 : entity work.add_1(boolean_eqn) -- . . .;
|
70
|
-- not in book
|
71
|
port map ( d0 => current_val1(0), d1 => current_val1(1),
|
72
|
d2 => current_val1(2), d3 => current_val1(3),
|
73
|
y0 => next_val1(0), y1 => next_val1(1),
|
74
|
y2 => next_val1(2), y3 => next_val1(3) );
|
75
|
-- end not in book
|
76
|
|
77
|
buf0 : entity work.buf4(basic) -- . . .;
|
78
|
-- not in book
|
79
|
port map ( a0 => current_val0(0), a1 => current_val0(1),
|
80
|
a2 => current_val0(2), a3 => current_val0(3),
|
81
|
y0 => q0(0), y1 => q0(1),
|
82
|
y2 => q0(2), y3 => q0(3) );
|
83
|
-- end not in book
|
84
|
|
85
|
buf1 : entity work.buf4(basic) -- . . .;
|
86
|
-- not in book
|
87
|
port map ( a0 => current_val1(0), a1 => current_val1(1),
|
88
|
a2 => current_val1(2), a3 => current_val1(3),
|
89
|
y0 => q1(0), y1 => q1(1),
|
90
|
y2 => q1(2), y3 => q1(3) );
|
91
|
-- end not in book
|
92
|
|
93
|
end architecture registered;
|