1 |
12 |
dkoethe |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Title : Testbench for design "opb_if"
|
3 |
|
|
-- Project :
|
4 |
|
|
-------------------------------------------------------------------------------
|
5 |
|
|
-- File : opb_if_tb.vhd
|
6 |
|
|
-- Author :
|
7 |
|
|
-- Company :
|
8 |
|
|
-- Created : 2007-09-01
|
9 |
|
|
-- Last update: 2007-11-12
|
10 |
|
|
-- Platform :
|
11 |
|
|
-- Standard : VHDL'87
|
12 |
|
|
-------------------------------------------------------------------------------
|
13 |
|
|
-- Description:
|
14 |
|
|
-------------------------------------------------------------------------------
|
15 |
|
|
-- Copyright (c) 2007
|
16 |
|
|
-------------------------------------------------------------------------------
|
17 |
|
|
-- Revisions :
|
18 |
|
|
-- Date Version Author Description
|
19 |
|
|
-- 2007-09-01 1.0 d.koethe Created
|
20 |
|
|
-------------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
library ieee;
|
23 |
|
|
use ieee.std_logic_1164.all;
|
24 |
|
|
|
25 |
|
|
library work;
|
26 |
|
|
use work.opb_spi_slave_pack.all;
|
27 |
|
|
|
28 |
|
|
-------------------------------------------------------------------------------
|
29 |
|
|
|
30 |
|
|
entity opb_if_tb is
|
31 |
|
|
|
32 |
|
|
end opb_if_tb;
|
33 |
|
|
|
34 |
|
|
-------------------------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
architecture behavior of opb_if_tb is
|
37 |
|
|
|
38 |
|
|
component opb_if
|
39 |
|
|
generic (
|
40 |
|
|
C_BASEADDR : std_logic_vector(0 to 31);
|
41 |
|
|
C_HIGHADDR : std_logic_vector(0 to 31);
|
42 |
|
|
C_USER_ID_CODE : integer;
|
43 |
|
|
C_OPB_AWIDTH : integer;
|
44 |
|
|
C_OPB_DWIDTH : integer;
|
45 |
|
|
C_FAMILY : string;
|
46 |
|
|
C_SR_WIDTH : integer;
|
47 |
|
|
C_FIFO_SIZE_WIDTH : integer;
|
48 |
|
|
C_DMA_EN : boolean);
|
49 |
|
|
port (
|
50 |
|
|
OPB_ABus : in std_logic_vector(0 to C_OPB_AWIDTH-1);
|
51 |
|
|
OPB_BE : in std_logic_vector(0 to C_OPB_DWIDTH/8-1);
|
52 |
|
|
OPB_Clk : in std_logic;
|
53 |
|
|
OPB_DBus : in std_logic_vector(0 to C_OPB_DWIDTH-1);
|
54 |
|
|
OPB_RNW : in std_logic;
|
55 |
|
|
OPB_Rst : in std_logic;
|
56 |
|
|
OPB_select : in std_logic;
|
57 |
|
|
OPB_seqAddr : in std_logic;
|
58 |
|
|
Sln_DBus : out std_logic_vector(0 to C_OPB_DWIDTH-1);
|
59 |
|
|
Sln_errAck : out std_logic;
|
60 |
|
|
Sln_retry : out std_logic;
|
61 |
|
|
Sln_toutSup : out std_logic;
|
62 |
|
|
Sln_xferAck : out std_logic;
|
63 |
|
|
opb_s_tx_en : out std_logic;
|
64 |
|
|
opb_s_tx_data : out std_logic_vector(C_SR_WIDTH-1 downto 0);
|
65 |
|
|
opb_s_rx_en : out std_logic;
|
66 |
|
|
opb_s_rx_data : in std_logic_vector(C_SR_WIDTH-1 downto 0);
|
67 |
|
|
opb_ctl_reg : out std_logic_vector(C_OPB_CTL_REG_WIDTH-1 downto 0);
|
68 |
|
|
tx_thresh : out std_logic_vector((2*C_FIFO_SIZE_WIDTH)-1 downto 0);
|
69 |
|
|
rx_thresh : out std_logic_vector((2*C_FIFO_SIZE_WIDTH)-1 downto 0);
|
70 |
|
|
opb_fifo_flg : in std_logic_vector(C_NUM_FLG-1 downto 0);
|
71 |
|
|
opb_dgie : out std_logic;
|
72 |
|
|
opb_ier : out std_logic_vector(C_NUM_INT-1 downto 0);
|
73 |
|
|
opb_isr : in std_logic_vector(C_NUM_INT-1 downto 0);
|
74 |
|
|
opb_isr_clr : out std_logic_vector(C_NUM_INT-1 downto 0);
|
75 |
|
|
opb_tx_dma_addr : out std_logic_vector(C_OPB_DWIDTH-1 downto 0);
|
76 |
|
|
opb_tx_dma_ctl : out std_logic_vector(0 downto 0);
|
77 |
|
|
opb_tx_dma_num : out std_logic_vector(15 downto 0);
|
78 |
|
|
opb_rx_dma_addr : out std_logic_vector(C_OPB_DWIDTH-1 downto 0);
|
79 |
|
|
opb_rx_dma_ctl : out std_logic_vector(0 downto 0);
|
80 |
|
|
opb_rx_dma_num : out std_logic_vector(15 downto 0));
|
81 |
|
|
end component;
|
82 |
|
|
|
83 |
|
|
constant C_BASEADDR : std_logic_vector(0 to 31) := X"00000000";
|
84 |
|
|
constant C_HIGHADDR : std_logic_vector(0 to 31) := X"FFFFFFFF";
|
85 |
|
|
constant C_USER_ID_CODE : integer := 3;
|
86 |
|
|
constant C_OPB_AWIDTH : integer := 32;
|
87 |
|
|
constant C_OPB_DWIDTH : integer := 32;
|
88 |
|
|
constant C_FAMILY : string := "virtex-4";
|
89 |
|
|
constant C_SR_WIDTH : integer := 8;
|
90 |
|
|
constant C_FIFO_SIZE_WIDTH : integer := 4;
|
91 |
|
|
constant C_DMA_EN : boolean := true;
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
signal OPB_ABus : std_logic_vector(0 to C_OPB_AWIDTH-1);
|
95 |
|
|
signal OPB_BE : std_logic_vector(0 to C_OPB_DWIDTH/8-1);
|
96 |
|
|
signal OPB_Clk : std_logic;
|
97 |
|
|
signal OPB_DBus : std_logic_vector(0 to C_OPB_DWIDTH-1);
|
98 |
|
|
signal OPB_RNW : std_logic;
|
99 |
|
|
signal OPB_Rst : std_logic;
|
100 |
|
|
signal OPB_select : std_logic;
|
101 |
|
|
signal OPB_seqAddr : std_logic;
|
102 |
|
|
signal Sln_DBus : std_logic_vector(0 to C_OPB_DWIDTH-1);
|
103 |
|
|
signal Sln_errAck : std_logic;
|
104 |
|
|
signal Sln_retry : std_logic;
|
105 |
|
|
signal Sln_toutSup : std_logic;
|
106 |
|
|
signal Sln_xferAck : std_logic;
|
107 |
|
|
signal opb_s_tx_en : std_logic;
|
108 |
|
|
signal opb_s_tx_data : std_logic_vector(C_SR_WIDTH-1 downto 0);
|
109 |
|
|
signal opb_s_rx_en : std_logic;
|
110 |
|
|
signal opb_s_rx_data : std_logic_vector(C_SR_WIDTH-1 downto 0);
|
111 |
|
|
signal opb_ctl_reg : std_logic_vector(C_OPB_CTL_REG_WIDTH-1 downto 0);
|
112 |
|
|
signal tx_thresh : std_logic_vector((2*C_FIFO_SIZE_WIDTH)-1 downto 0);
|
113 |
|
|
signal rx_thresh : std_logic_vector((2*C_FIFO_SIZE_WIDTH)-1 downto 0);
|
114 |
|
|
signal opb_fifo_flg : std_logic_vector(C_NUM_FLG-1 downto 0);
|
115 |
|
|
signal opb_dgie : std_logic;
|
116 |
|
|
signal opb_ier : std_logic_vector(C_NUM_INT-1 downto 0);
|
117 |
|
|
signal opb_isr : std_logic_vector(C_NUM_INT-1 downto 0);
|
118 |
|
|
signal opb_isr_clr : std_logic_vector(C_NUM_INT-1 downto 0);
|
119 |
|
|
signal opb_tx_dma_addr : std_logic_vector(C_OPB_DWIDTH-1 downto 0);
|
120 |
|
|
signal opb_tx_dma_ctl : std_logic_vector(0 downto 0);
|
121 |
|
|
signal opb_tx_dma_num : std_logic_vector(15 downto 0);
|
122 |
|
|
signal opb_rx_dma_addr : std_logic_vector(C_OPB_DWIDTH-1 downto 0);
|
123 |
|
|
signal opb_rx_dma_ctl : std_logic_vector(0 downto 0);
|
124 |
|
|
signal opb_rx_dma_num : std_logic_vector(15 downto 0);
|
125 |
|
|
|
126 |
|
|
constant clk_period : time := 25 ns;
|
127 |
|
|
|
128 |
|
|
begin -- behavior
|
129 |
|
|
|
130 |
|
|
-- component instantiation
|
131 |
|
|
DUT: opb_if
|
132 |
|
|
generic map (
|
133 |
|
|
C_BASEADDR => C_BASEADDR,
|
134 |
|
|
C_HIGHADDR => C_HIGHADDR,
|
135 |
|
|
C_USER_ID_CODE => C_USER_ID_CODE,
|
136 |
|
|
C_OPB_AWIDTH => C_OPB_AWIDTH,
|
137 |
|
|
C_OPB_DWIDTH => C_OPB_DWIDTH,
|
138 |
|
|
C_FAMILY => C_FAMILY,
|
139 |
|
|
C_SR_WIDTH => C_SR_WIDTH,
|
140 |
|
|
C_FIFO_SIZE_WIDTH => C_FIFO_SIZE_WIDTH,
|
141 |
|
|
C_DMA_EN => C_DMA_EN)
|
142 |
|
|
port map (
|
143 |
|
|
OPB_ABus => OPB_ABus,
|
144 |
|
|
OPB_BE => OPB_BE,
|
145 |
|
|
OPB_Clk => OPB_Clk,
|
146 |
|
|
OPB_DBus => OPB_DBus,
|
147 |
|
|
OPB_RNW => OPB_RNW,
|
148 |
|
|
OPB_Rst => OPB_Rst,
|
149 |
|
|
OPB_select => OPB_select,
|
150 |
|
|
OPB_seqAddr => OPB_seqAddr,
|
151 |
|
|
Sln_DBus => Sln_DBus,
|
152 |
|
|
Sln_errAck => Sln_errAck,
|
153 |
|
|
Sln_retry => Sln_retry,
|
154 |
|
|
Sln_toutSup => Sln_toutSup,
|
155 |
|
|
Sln_xferAck => Sln_xferAck,
|
156 |
|
|
opb_s_tx_en => opb_s_tx_en,
|
157 |
|
|
opb_s_tx_data => opb_s_tx_data,
|
158 |
|
|
opb_s_rx_en => opb_s_rx_en,
|
159 |
|
|
opb_s_rx_data => opb_s_rx_data,
|
160 |
|
|
opb_ctl_reg => opb_ctl_reg,
|
161 |
|
|
tx_thresh => tx_thresh,
|
162 |
|
|
rx_thresh => rx_thresh,
|
163 |
|
|
opb_fifo_flg => opb_fifo_flg,
|
164 |
|
|
opb_dgie => opb_dgie,
|
165 |
|
|
opb_ier => opb_ier,
|
166 |
|
|
opb_isr => opb_isr,
|
167 |
|
|
opb_isr_clr => opb_isr_clr,
|
168 |
|
|
opb_tx_dma_addr => opb_tx_dma_addr,
|
169 |
|
|
opb_tx_dma_ctl => opb_tx_dma_ctl,
|
170 |
|
|
opb_tx_dma_num => opb_tx_dma_num,
|
171 |
|
|
opb_rx_dma_addr => opb_rx_dma_addr,
|
172 |
|
|
opb_rx_dma_ctl => opb_rx_dma_ctl,
|
173 |
|
|
opb_rx_dma_num => opb_rx_dma_num);
|
174 |
|
|
|
175 |
|
|
-- clock generation
|
176 |
|
|
process
|
177 |
|
|
begin
|
178 |
|
|
OPB_Clk <= '0';
|
179 |
|
|
wait for clk_period;
|
180 |
|
|
OPB_Clk <= '1';
|
181 |
|
|
wait for clk_period;
|
182 |
|
|
end process;
|
183 |
|
|
|
184 |
|
|
-- waveform generation
|
185 |
|
|
WaveGen_Proc : process
|
186 |
|
|
begin
|
187 |
|
|
OPB_ABus <= (others => '0');
|
188 |
|
|
OPB_BE <= (others => '0');
|
189 |
|
|
OPB_DBus <= (others => '0');
|
190 |
|
|
OPB_RNW <= '0';
|
191 |
|
|
OPB_select <= '0';
|
192 |
|
|
OPB_seqAddr <= '0';
|
193 |
|
|
-- reset active
|
194 |
|
|
OPB_Rst <= '1';
|
195 |
|
|
wait for 100 ns;
|
196 |
|
|
-- reset inactive
|
197 |
|
|
OPB_Rst <= '0';
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
-- write acess
|
201 |
|
|
wait until rising_edge(OPB_Clk);
|
202 |
|
|
OPB_ABus <= X"10000000";
|
203 |
|
|
OPB_select <= '1';
|
204 |
|
|
OPB_RNW <= '0';
|
205 |
|
|
OPB_DBus <= X"12345678";
|
206 |
|
|
|
207 |
|
|
for i in 0 to 3 loop
|
208 |
|
|
wait until rising_edge(OPB_Clk);
|
209 |
|
|
if (Sln_xferAck = '1') then
|
210 |
|
|
exit;
|
211 |
|
|
end if;
|
212 |
|
|
end loop; -- i
|
213 |
|
|
OPB_DBus <= X"00000000";
|
214 |
|
|
OPB_ABus <= X"00000000";
|
215 |
|
|
OPB_select <= '0';
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
-- read acess
|
219 |
|
|
wait until rising_edge(OPB_Clk);
|
220 |
|
|
OPB_ABus <= X"10000000";
|
221 |
|
|
OPB_select <= '1';
|
222 |
|
|
OPB_RNW <= '1';
|
223 |
|
|
|
224 |
|
|
for i in 0 to 3 loop
|
225 |
|
|
wait until rising_edge(OPB_Clk);
|
226 |
|
|
if (Sln_xferAck = '1') then
|
227 |
|
|
exit;
|
228 |
|
|
end if;
|
229 |
|
|
end loop; -- i
|
230 |
|
|
OPB_ABus <= X"00000000";
|
231 |
|
|
OPB_select <= '0';
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
wait for 100 ns;
|
236 |
|
|
assert false report "Simulation sucessful" severity failure;
|
237 |
|
|
|
238 |
|
|
|
239 |
|
|
end process WaveGen_Proc;
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
end behavior;
|
244 |
|
|
|
245 |
|
|
-------------------------------------------------------------------------------
|
246 |
|
|
|
247 |
|
|
configuration opb_if_tb_behavior_cfg of opb_if_tb is
|
248 |
|
|
for behavior
|
249 |
|
|
end for;
|
250 |
|
|
end opb_if_tb_behavior_cfg;
|
251 |
|
|
|
252 |
|
|
-------------------------------------------------------------------------------
|