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

Subversion Repositories t400

[/] [t400/] [trunk/] [bench/] [vhdl/] [tb_t411.vhd] - Blame information for rev 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 arniml
-------------------------------------------------------------------------------
2
--
3
-- Testbench for the T411 system toplevel.
4
--
5 7 arniml
-- $Id: tb_t411.vhd,v 1.2 2006-05-06 13:34:25 arniml Exp $
6 2 arniml
--
7
-- Copyright (c) 2006 Arnim Laeuger (arniml@opencores.org)
8
--
9
-- All rights reserved
10
--
11
-- Redistribution and use in source and synthezised forms, with or without
12
-- modification, are permitted provided that the following conditions are met:
13
--
14
-- Redistributions of source code must retain the above copyright notice,
15
-- this list of conditions and the following disclaimer.
16
--
17
-- Redistributions in synthesized form must reproduce the above copyright
18
-- notice, this list of conditions and the following disclaimer in the
19
-- documentation and/or other materials provided with the distribution.
20
--
21
-- Neither the name of the author nor the names of other contributors may
22
-- be used to endorse or promote products derived from this software without
23
-- specific prior written permission.
24
--
25
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
29
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
-- POSSIBILITY OF SUCH DAMAGE.
36
--
37
-- Please report bugs to the author, but before you do so, please
38
-- make sure that this is not a derivative work and that
39
-- you have the latest version of this file.
40
--
41
-- The latest version of this file can be found at:
42
--      http://www.opencores.org/cvsweb.shtml/t400/
43
--
44
-------------------------------------------------------------------------------
45
 
46
entity tb_t411 is
47
 
48
end tb_t411;
49
 
50
 
51
library ieee;
52
use ieee.std_logic_1164.all;
53
use ieee.numeric_std.all;
54
 
55
use work.t400_system_comp_pack.t411;
56
 
57
architecture behav of tb_t411 is
58
 
59
  -- 210.4 kHz clock
60
  --  -> 52.6 kHz internal clock
61
  constant period_c : time := 4.75 us;
62
  signal   ck_s     : std_logic;
63
  signal   en_ck_s  : std_logic;
64
 
65
  signal reset_n_s  : std_logic;
66
 
67
  signal io_l_s     : std_logic_vector(7 downto 0);
68
  signal io_d_s     : std_logic_vector(1 downto 0);
69
  signal io_g_s     : std_logic_vector(2 downto 0);
70
 
71
  signal si_s,
72
         so_s,
73
         sk_s       : std_logic;
74
 
75
  signal vdd_s      : std_logic;
76
 
77
begin
78
 
79
  en_ck_s   <= 'H';
80
 
81
  vdd_s     <= '1';
82
  reset_n_s <= '1';
83
 
84
  -----------------------------------------------------------------------------
85
  -- DUT
86
  -----------------------------------------------------------------------------
87
  t411_b : t411
88
    port map (
89
      ck_i      => ck_s,
90
      ck_en_i   => vdd_s,
91
      reset_n_i => reset_n_s,
92
      si_i      => si_s,
93
      so_o      => so_s,
94
      sk_o      => sk_s,
95
      io_l_b    => io_l_s,
96
      io_d_o    => io_d_s,
97
      io_g_b    => io_g_s
98
    );
99
 
100
  io_l_s <= (others => 'H');
101
  io_d_s <= (others => 'H');
102
  io_g_s <= (others => 'H');
103
 
104
 
105
  -----------------------------------------------------------------------------
106
  -- Pass/fail catcher
107
  -----------------------------------------------------------------------------
108
  pass_fail: process (io_l_s)
109
    type pass_fail_t is (IDLE,
110
                         GOT_0, GOT_A, GOT_5);
111
    variable state_v : pass_fail_t := IDLE;
112
    variable sig_v   : std_logic_vector(3 downto 0);
113
  begin
114
    sig_v := to_X01(io_l_s(7 downto 4));
115
 
116
    case state_v is
117
      when IDLE =>
118
        en_ck_s <= 'Z';
119
        if sig_v = "0000" then
120
          state_v := GOT_0;
121
        end if;
122
      when GOT_0 =>
123
        if    sig_v = "1010" then
124
          state_v := GOT_A;
125
        elsif sig_v /= "0000" then
126
          state_v := IDLE;
127
        end if;
128
      when GOT_A =>
129
        if    sig_v = "0101" then
130
          state_v := GOT_5;
131
        elsif sig_v /= "1010" then
132
          state_v := IDLE;
133
        end if;
134
      when GOT_5 =>
135
        if    sig_v = "0000" then
136
          en_ck_s <= '0';
137
          assert false
138
            report "Simulation finished with PASS."
139
            severity note;
140
        elsif sig_v = "1111" then
141
          en_ck_s <= '0';
142
          assert false
143
            report "Simulation finished with FAIL."
144
            severity note;
145
        elsif sig_v /= "0101" then
146
          state_v := IDLE;
147
        end if;
148
    end case;
149
  end process pass_fail;
150
 
151
 
152
  -----------------------------------------------------------------------------
153
  -- D monitor
154
  -----------------------------------------------------------------------------
155
  d_moni: process (io_d_s)
156
    type d_moni_t is (IDLE,
157
                      STEP_1, STEP_2);
158
    variable state_v : d_moni_t := IDLE;
159
    variable sig_v   : unsigned(3 downto 0);
160
  begin
161
    sig_v := (others => '0');
162
    sig_v(io_d_s'range) := unsigned(to_X01(io_d_s));
163
 
164
    case state_v is
165
      when IDLE =>
166
        en_ck_s   <= 'Z';
167
        if sig_v = 1 then
168
          state_v := STEP_1;
169
        end if;
170
      when STEP_1 =>
171
        if sig_v = 2 then
172
          state_v := STEP_2;
173
        else
174
          state_v := IDLE;
175
        end if;
176
      when STEP_2 =>
177
        if sig_v /= 0 then
178
          state_v := IDLE;
179
        else
180
          en_ck_s <= '0';
181
          assert false
182
            report "Simulation finished with PASS (D-Port)."
183
            severity note;
184
        end if;
185
 
186
      when others =>
187
        null;
188
    end case;
189
 
190
  end process d_moni;
191
 
192
 
193
  -----------------------------------------------------------------------------
194
  -- G monitor
195
  -----------------------------------------------------------------------------
196
  g_moni: process (io_g_s)
197
    type d_moni_t is (IDLE,
198
                      STEP_1, STEP_2, STEP_3);
199
    variable state_v : d_moni_t := IDLE;
200
    variable sig_v   : unsigned(3 downto 0);
201
  begin
202
    sig_v := (others => '0');
203
    sig_v(io_g_s'range) := unsigned(to_X01(io_g_s));
204
 
205
    case state_v is
206
      when IDLE =>
207
        en_ck_s   <= 'Z';
208
        if sig_v = 1 then
209
          state_v := STEP_1;
210
        end if;
211
      when STEP_1 =>
212
        if sig_v = 2 then
213
          state_v := STEP_2;
214
        else
215
          state_v := IDLE;
216
        end if;
217
      when STEP_2 =>
218
        if sig_v = 4 then
219
          state_v := STEP_3;
220
        else
221
          state_v := IDLE;
222
        end if;
223
      when STEP_3 =>
224
        if sig_v /= 0 then
225
          state_v := IDLE;
226
        else
227
          en_ck_s <= '0';
228
          assert false
229
            report "Simulation finished with PASS (G-Port)."
230
            severity note;
231
        end if;
232
 
233
      when others =>
234
        null;
235
    end case;
236
 
237
  end process g_moni;
238
 
239
 
240
  -----------------------------------------------------------------------------
241
  -- SIO peer
242
  -----------------------------------------------------------------------------
243
  sio_peer: process
244
  begin
245
    si_s <= '0';
246
 
247
    wait until io_l_s(4) = '0';
248
 
249
    while io_l_s(4) = '0' loop
250
      wait for 10 us;
251
      si_s <= so_s xor sk_s;
252
 
253
      wait until io_l_s'event or so_s'event or sk_s'event;
254
    end loop;
255
 
256
    -- now feed SO back to SI upon SK edge
257
    loop
258 7 arniml
      wait until sk_s'event and sk_s = '1';
259 2 arniml
      wait for 10 us;
260
      si_s <= so_s;
261
    end loop;
262
 
263
    wait;
264
  end process sio_peer;
265
 
266
 
267
  -----------------------------------------------------------------------------
268
  -- Clock generator
269
  -----------------------------------------------------------------------------
270
  clk: process
271
  begin
272
    ck_s <= '0';
273
    wait for period_c / 2;
274
    ck_s <= '1';
275
    wait for period_c / 2;
276
 
277
    if to_X01(en_ck_s) /= '1' then
278
      wait;
279
    end if;
280
  end process clk;
281
 
282
end behav;
283
 
284
 
285
-------------------------------------------------------------------------------
286
-- File History:
287
--
288
-- $Log: not supported by cvs2svn $
289 7 arniml
-- Revision 1.1.1.1  2006/05/06 01:56:44  arniml
290
-- import from local CVS repository, LOC_CVS_0_1
291
--
292 2 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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