-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmemory_test.vhd
214 lines (183 loc) · 5.85 KB
/
memory_test.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
------------------------------------
-- Fichier de test pour Banc Memoire
-- THIEBOLT Francois le 08/12/04
------------------------------------
-- Definition des librairies
library IEEE;
library WORK;
-- Definition des portee d'utilisation
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
-- use WORK.func_package.all;
use WORK.cpu_package.all;
-- Definition de l'entite
entity test_memory is
end test_memory;
-- Definition de l'architecture
architecture behavior of test_memory is
-- definition de constantes de test
constant S_DATA : positive := CPU_DATA_WIDTH; -- taille du bus de donnees
constant S_ADR : positive := CPU_ADR_WIDTH; -- taille du bus d'adresse
constant S_L1 : positive := L1_SIZE; -- taille du cache L1 en nombre de mots
-- constant S_L1 : positive := 32; -- taille du cache L1 en nombre de mots
constant WFRONT : std_logic := L1_FRONT; -- front actif pour ecriture
constant FILENAME : string := ""; -- init a 0 par defaut
-- constant FILENAME : string := "rom_file.0.txt"; -- init par fichier
constant TIMEOUT : time := 200 ns; -- timeout de la simulation
-- definition de constantes
constant clkpulse : Time := 5 ns; -- 1/2 periode horloge
-- definition de types
-- definition de ressources internes
-- definition de ressources externes
signal E_RST : std_logic; -- actif a l'etat bas
signal E_CLK : std_logic;
signal E_RW : std_logic;
signal E_DS : std_logic_vector(1 downto 0);
signal E_Signed : std_logic;
signal E_AS : std_logic;
signal E_Ready,E_Berr: std_logic;
signal E_ADR : std_logic_vector(S_ADR-1 downto 0); -- bus adresse au format octet !
signal E_D,E_Q : std_logic_vector(S_DATA-1 downto 0);
begin
--------------------------
-- definition de l'horloge
P_E_CLK: process
begin
E_CLK <= '1';
wait for clkpulse;
E_CLK <= '0';
wait for clkpulse;
end process P_E_CLK;
-----------------------------------------
-- definition du timeout de la simulation
P_TIMEOUT: process
begin
wait for TIMEOUT;
assert FALSE report "SIMULATION TIMEOUT!!!" severity FAILURE;
end process P_TIMEOUT;
-----------------------------------------
-- instanciation et mapping de composants
L1 : entity work.memory(behavior)
generic map (S_DATA,S_ADR,S_L1,WFRONT,FILENAME)
port map (RST => E_RST, CLK => E_CLK, RW => E_RW,
DS => E_DS, SIGN => E_Signed, AS => E_AS,
Ready => E_Ready, Berr => E_Berr,
ADR => E_ADR, D => E_D, Q => E_Q );
-----------------------------
-- debut sequence de test
P_TEST: process
begin
-- initialisations
E_RST <= '0';
E_RW <= MEM_READ;
E_DS <= MEM_8;
E_Signed <= MEM_UNSIGNED;
E_AS <= '0';
E_ADR <= (others => 'X');
E_D <= (others => 'X');
-- sequence RESET
E_RST <= '0';
wait for clkpulse*3;
E_RST <= '1';
wait for clkpulse;
-- ecriture octet a l'octet 1
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
E_ADR <= conv_std_logic_vector(1,S_ADR);
E_DS <= MEM_8;
E_D <= to_stdlogicvector(BIT_VECTOR'(X"FFFFFFAA"));
E_RW <= MEM_WRITE;
E_AS <= '1';
E_Signed <= MEM_UNSIGNED;
-- ecriture demi-mot a l'octet 2
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
E_ADR <= conv_std_logic_vector(2,S_ADR);
E_DS <= MEM_16;
E_D <= to_stdlogicvector(BIT_VECTOR'(X"FFFFBBBB"));
E_RW <= MEM_WRITE;
E_AS <= '1';
E_Signed <= MEM_UNSIGNED;
-- ecriture mot a l'octet 4
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
E_ADR <= conv_std_logic_vector(4,S_ADR);
E_DS <= MEM_32;
E_D <= to_stdlogicvector(BIT_VECTOR'(X"CCCCCCCC"));
E_RW <= MEM_WRITE;
E_AS <= '1';
E_Signed <= MEM_UNSIGNED;
-- ecriture octet a l'octet 6
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
E_ADR <= conv_std_logic_vector(6,S_ADR);
E_DS <= MEM_8;
E_D <= to_stdlogicvector(BIT_VECTOR'(X"FFFFFFDD"));
E_RW <= MEM_WRITE;
E_AS <= '1';
E_Signed <= MEM_UNSIGNED;
-- lecture octet a l'octet 2
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
E_D <= (others => 'X'); -- disable Datas on DataBus
E_RW <= MEM_READ;
E_ADR <= conv_std_logic_vector(2,S_ADR);
E_DS <= MEM_8;
E_AS <= '1';
E_Signed <= MEM_UNSIGNED;
-- tests & lecture demi-mot a l'octet 6
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
assert E_Q = to_stdlogicvector(BIT_VECTOR'(X"000000BB"))
report "Memory 2 BAD VALUE"
severity ERROR;
E_RW <= MEM_READ;
E_AS <= '1';
E_Signed <= MEM_UNSIGNED;
E_ADR <= conv_std_logic_vector(6,S_ADR);
E_DS <= MEM_16;
-- tests & lecture mot a l'octet 0
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
assert E_Q = to_stdlogicvector(BIT_VECTOR'(X"0000CCDD"))
report "Memory 6 BAD VALUE"
severity ERROR;
E_RW <= MEM_READ;
E_AS <= '1';
E_Signed <= MEM_UNSIGNED;
E_ADR <= conv_std_logic_vector(0,S_ADR);
E_DS <= MEM_32;
-- tests & lecture octet signe a l'adresse 6
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
assert E_Q = to_stdlogicvector(BIT_VECTOR'(X"BBBBAA00"))
report "Memory 0 BAD VALUE"
severity ERROR;
E_RW <= MEM_READ;
E_AS <= '1';
E_Signed <= MEM_SIGNED;
E_ADR <= conv_std_logic_vector(6,S_ADR);
E_DS <= MEM_8;
-- tests
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
E_RW <= MEM_READ;
E_AS <= '0';
E_Signed <= MEM_UNSIGNED;
assert E_Q = to_stdlogicvector(BIT_VECTOR'(X"FFFFFFDD"))
report "Memory 6 BAD VALUE"
severity ERROR;
-- erreur de lecture demi-mot a l'adresse 1
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
E_RW <= MEM_READ;
E_AS <= '1';
E_Signed <= MEM_UNSIGNED;
E_ADR <= conv_std_logic_vector(3,S_ADR);
E_DS <= MEM_16;
-- tests
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
E_RW <= MEM_READ;
E_AS <= '0';
E_Signed <= MEM_UNSIGNED;
assert E_Berr = '0'
report "Berr not reporting error !"
severity ERROR;
-- ADD NEW SEQUENCE HERE
-- LATEST COMMAND (NE PAS ENLEVER !!!)
wait until (E_CLK=(WFRONT)); wait for clkpulse/2;
assert FALSE report "FIN DE SIMULATION" severity FAILURE;
-- assert (NOW < TIMEOUT) report "FIN DE SIMULATION" severity FAILURE;
end process P_TEST;
end behavior;