OpenCores
URL https://opencores.org/ocsvn/wb_tk/wb_tk/trunk

Subversion Repositories wb_tk

[/] [wb_tk/] [tags/] [a01/] [TestBench/] [wb_arbiter_TB.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tantos
library ieee;
2
use ieee.std_logic_1164.all;
3
 
4
library work;
5
use wb_tk.all;
6
 
7
entity wb_arbiter_tb is
8
end wb_arbiter_tb;
9
 
10
architecture TB of wb_arbiter_tb is
11
        -- Component declaration of the tested unit
12
        component wb_arbiter is
13
                port (
14
        --              clk: in std_logic;
15
                        rst_i: in std_logic := '0';
16
 
17
                        -- interface to master device a
18
                        a_we_i: in std_logic;
19
                        a_stb_i: in std_logic;
20
                        a_cyc_i: in std_logic;
21
                        a_ack_o: out std_logic;
22
                        a_ack_oi: in std_logic := '-';
23
                        a_err_o: out std_logic;
24
                        a_err_oi: in std_logic := '-';
25
                        a_rty_o: out std_logic;
26
                        a_rty_oi: in std_logic := '-';
27
 
28
                        -- interface to master device b
29
                        b_we_i: in std_logic;
30
                        b_stb_i: in std_logic;
31
                        b_cyc_i: in std_logic;
32
                        b_ack_o: out std_logic;
33
                        b_ack_oi: in std_logic := '-';
34
                        b_err_o: out std_logic;
35
                        b_err_oi: in std_logic := '-';
36
                        b_rty_o: out std_logic;
37
                        b_rty_oi: in std_logic := '-';
38
 
39
                        -- interface to shared devices
40
                        s_we_o: out std_logic;
41
                        s_stb_o: out std_logic;
42
                        s_cyc_o: out std_logic;
43
                        s_ack_i: in std_logic;
44
                        s_err_i: in std_logic := '-';
45
                        s_rty_i: in std_logic := '-';
46
 
47
                        mux_signal: out std_logic; -- 0: select A signals, 1: select B signals
48
 
49
                        -- misc control lines
50
                        priority: in std_logic -- 0: A have priority over B, 1: B have priority over A
51
                );
52
        end component;
53
 
54
        signal clk_i:  std_logic;
55
        signal rst_i:  std_logic := '0';
56
 
57
        -- interface to master device a
58
        signal a_we_i:  std_logic;
59
        signal a_stb_i:  std_logic;
60
        signal a_cyc_i:  std_logic;
61
        signal a_ack_o:  std_logic;
62
        signal a_ack_oi:  std_logic := 'U';
63
        signal a_err_o:  std_logic;
64
        signal a_err_oi:  std_logic := 'U';
65
        signal a_rty_o:  std_logic;
66
        signal a_rty_oi:  std_logic := 'U';
67
 
68
        -- interface to master device b
69
        signal b_we_i:  std_logic;
70
        signal b_stb_i:  std_logic;
71
        signal b_cyc_i:  std_logic;
72
        signal b_ack_o:  std_logic;
73
        signal b_ack_oi:  std_logic := 'U';
74
        signal b_err_o:  std_logic;
75
        signal b_err_oi:  std_logic := 'U';
76
        signal b_rty_o:  std_logic;
77
        signal b_rty_oi:  std_logic := 'U';
78
 
79
        -- interface to shared devices
80
        signal s_we_o:  std_logic;
81
        signal s_stb_o:  std_logic;
82
        signal s_cyc_o:  std_logic;
83
        signal s_ack_i:  std_logic;
84
        signal s_err_i:  std_logic := 'U';
85
        signal s_rty_i:  std_logic := 'U';
86
 
87
        signal mux_signal:  std_logic; -- 0: select A signals, 1: select B signals
88
 
89
        -- misc control lines
90
        signal priority:  std_logic; -- 0: A have priority over B, 1: B have priority over A
91
 
92
        signal start: std_logic := '0';
93
 
94
begin
95
 
96
        -- Unit Under Test port map
97
        UUT : wb_arbiter
98
                port map (
99
                        rst_i => rst_i,
100
 
101
                        -- interface to master device a
102
                        a_we_i => a_we_i,
103
                        a_stb_i => a_stb_i,
104
                        a_cyc_i => a_cyc_i,
105
                        a_ack_o => a_ack_o,
106
                        a_ack_oi => a_ack_oi,
107
                        a_err_o => a_err_o,
108
                        a_err_oi => a_err_oi,
109
                        a_rty_o => a_rty_o,
110
                        a_rty_oi => a_rty_oi,
111
 
112
                        -- interface to master device b
113
                        b_we_i => b_we_i,
114
                        b_stb_i => b_stb_i,
115
                        b_cyc_i => b_cyc_i,
116
                        b_ack_o => b_ack_o,
117
                        b_ack_oi => b_ack_oi,
118
                        b_err_o => b_err_o,
119
                        b_err_oi => b_err_oi,
120
                        b_rty_o => b_rty_o,
121
                        b_rty_oi => b_rty_oi,
122
 
123
                        -- interface to shared devices
124
                        s_we_o => s_we_o,
125
                        s_stb_o => s_stb_o,
126
                        s_cyc_o => s_cyc_o,
127
                        s_ack_i => s_ack_i,
128
                        s_err_i => s_err_i,
129
                        s_rty_i => s_rty_i,
130
 
131
                        mux_signal => mux_signal,
132
 
133
                        -- misc control lines
134
                        priority => priority
135
                );
136
 
137
        -- Reset the machine
138
        rst: process is
139
        begin
140
                rst_i <= '1';
141
                wait for 10ns;
142
                rst_i <= '0';
143
                start <= '1';
144
                wait;
145
        end process;
146
 
147
        clock: process is
148
        begin
149
                clk_i <= '0';
150
                wait for 10ns;
151
                clk_i <= '1';
152
                wait for 10ns;
153
        end process;
154
 
155
        -- Simulate a 3WS access time memory
156
        memory: process is
157
        begin
158
                s_ack_i <= '0';
159
                wait until (s_stb_o = '1' and clk_i'EVENT and clk_i = '1');
160
                wait until (clk_i'EVENT and clk_i = '1');
161
                wait until (clk_i'EVENT and clk_i = '1');
162
                wait until (clk_i'EVENT and clk_i = '1');
163
                s_ack_i <= '1';
164
                wait until (clk_i'EVENT and clk_i = '1');
165
        end process;
166
 
167
        -- Generate requests
168
        a_req: process is
169
        begin
170
                a_we_i <= '0';
171
                a_cyc_i <= '0';
172
                a_stb_i <= '0';
173
                wait for 100ns;
174
                a_cyc_i <= '1';
175
                a_stb_i <= '1';
176
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
177
                a_cyc_i <= '0';
178
                a_stb_i <= '0';
179
                wait for 20ns;
180
                a_cyc_i <= '1';
181
                a_stb_i <= '1';
182
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
183
                a_cyc_i <= '0';
184
                a_stb_i <= '0';
185
                -- Request 4 burst reads
186
                wait for 100ns;
187
                a_cyc_i <= '1';
188
                a_stb_i <= '1';
189
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
190
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
191
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
192
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
193
                a_cyc_i <= '0';
194
                a_stb_i <= '0';
195
        end process;
196
 
197
        b_req: process is
198
        begin
199
                b_we_i <= '0';
200
                b_cyc_i <= '0';
201
                b_stb_i <= '0';
202
                wait for 120ns;
203
                b_cyc_i <= '1';
204
                b_stb_i <= '1';
205
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
206
                b_cyc_i <= '0';
207
                b_stb_i <= '0';
208
                wait for 30ns;
209
                b_cyc_i <= '1';
210
                b_stb_i <= '1';
211
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
212
                b_cyc_i <= '0';
213
                b_stb_i <= '0';
214
                -- Request 4 burst reads
215
                wait for 120ns;
216
                b_cyc_i <= '1';
217
                b_stb_i <= '1';
218
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
219
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
220
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
221
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
222
                b_cyc_i <= '0';
223
                b_stb_i <= '0';
224
        end process;
225
 
226
        pri: process is
227
        begin
228
                priority <= '0';
229
                wait for 500ns;
230
                priority <= '1';
231
                wait for 500ns;
232
        end process;
233
 
234
end TB;
235
 
236
configuration TB_wb_arbiter of wb_arbiter_tb is
237
        for TB
238
                for UUT : wb_arbiter
239
                        use entity wb_arbiter(FPGA);
240
                end for;
241
        end for;
242
end TB_wb_arbiter;
243
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.