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_18_fg_18_01.vhd,v 1.2 2001-10-26 16:29:36 paw Exp $
|
23
|
-- $Revision: 1.2 $
|
24
|
--
|
25
|
-- ---------------------------------------------------------------------
|
26
|
|
27
|
-- not in book
|
28
|
|
29
|
library ieee; use ieee.std_logic_1164.all;
|
30
|
|
31
|
entity fg_18_01_a is
|
32
|
end entity fg_18_01_a;
|
33
|
|
34
|
|
35
|
architecture writer of fg_18_01_a is
|
36
|
begin
|
37
|
|
38
|
process is
|
39
|
|
40
|
subtype word is std_logic_vector(0 to 7);
|
41
|
type load_file_type is file of word;
|
42
|
file load_file : load_file_type open write_mode is "fg_18_01.dat";
|
43
|
|
44
|
begin
|
45
|
write(load_file, word'(X"00"));
|
46
|
write(load_file, word'(X"01"));
|
47
|
write(load_file, word'(X"02"));
|
48
|
write(load_file, word'(X"03"));
|
49
|
write(load_file, word'(X"04"));
|
50
|
write(load_file, word'(X"05"));
|
51
|
write(load_file, word'(X"06"));
|
52
|
write(load_file, word'(X"07"));
|
53
|
write(load_file, word'(X"08"));
|
54
|
write(load_file, word'(X"09"));
|
55
|
write(load_file, word'(X"0A"));
|
56
|
write(load_file, word'(X"0B"));
|
57
|
write(load_file, word'(X"0C"));
|
58
|
write(load_file, word'(X"0D"));
|
59
|
write(load_file, word'(X"0E"));
|
60
|
write(load_file, word'(X"0F"));
|
61
|
|
62
|
wait;
|
63
|
end process;
|
64
|
|
65
|
end architecture writer;
|
66
|
|
67
|
-- end not in book
|
68
|
|
69
|
|
70
|
library ieee; use ieee.std_logic_1164.all;
|
71
|
|
72
|
entity ROM is
|
73
|
generic ( load_file_name : string );
|
74
|
port ( sel : in std_logic;
|
75
|
address : in std_logic_vector;
|
76
|
data : inout std_logic_vector );
|
77
|
end entity ROM;
|
78
|
|
79
|
--------------------------------------------------
|
80
|
|
81
|
architecture behavioral of ROM is
|
82
|
|
83
|
begin
|
84
|
|
85
|
behavior : process is
|
86
|
|
87
|
subtype word is std_logic_vector(0 to data'length - 1);
|
88
|
type storage_array is
|
89
|
array (natural range 0 to 2**address'length - 1) of word;
|
90
|
variable storage : storage_array;
|
91
|
variable index : natural;
|
92
|
-- . . . -- other declarations
|
93
|
|
94
|
type load_file_type is file of word;
|
95
|
file load_file : load_file_type open read_mode is load_file_name;
|
96
|
|
97
|
begin
|
98
|
|
99
|
-- load ROM contents from load_file
|
100
|
index := 0;
|
101
|
while not endfile(load_file) loop
|
102
|
read(load_file, storage(index));
|
103
|
index := index + 1;
|
104
|
end loop;
|
105
|
|
106
|
-- respond to ROM accesses
|
107
|
loop
|
108
|
-- . . .
|
109
|
end loop;
|
110
|
|
111
|
end process behavior;
|
112
|
|
113
|
end architecture behavioral;
|
114
|
|
115
|
|
116
|
|
117
|
-- not in book
|
118
|
|
119
|
library ieee; use ieee.std_logic_1164.all;
|
120
|
|
121
|
entity fg_18_01 is
|
122
|
end entity fg_18_01;
|
123
|
|
124
|
|
125
|
architecture test of fg_18_01 is
|
126
|
|
127
|
signal sel : std_logic;
|
128
|
signal address : std_logic_vector(3 downto 0);
|
129
|
signal data : std_logic_vector(0 to 7);
|
130
|
|
131
|
begin
|
132
|
|
133
|
dut : entity work.ROM(behavioral)
|
134
|
generic map ( load_file_name => "fg_18_01.dat" )
|
135
|
port map ( sel, address, data );
|
136
|
|
137
|
end architecture test;
|
138
|
|
139
|
-- end not in book
|