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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_6_1_beta/] [bench/] [vhdl/] [tb.vhd] - Blame information for rev 30

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

Line No. Rev Author Line
1 8 arniml
-------------------------------------------------------------------------------
2
--
3
-- The testbench for t48_core.
4
--
5 30 arniml
-- $Id: tb.vhd,v 1.4 2004-03-28 21:30:25 arniml Exp $
6 8 arniml
--
7
-- Copyright (c) 2004, 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/t48/
43
--
44
-------------------------------------------------------------------------------
45
 
46
library ieee;
47
use ieee.std_logic_1164.all;
48
 
49
entity tb is
50
 
51
end tb;
52
 
53
 
54
use work.t48_core_comp_pack.all;
55
 
56
use work.t48_tb_pack.all;
57
 
58
architecture behav of tb is
59
 
60
  -- clock period, 11 MHz
61
  constant period_c : time := 90 ns;
62
 
63
  signal xtal_s          : std_logic;
64 10 arniml
  signal xtal_n_s        : std_logic;
65 8 arniml
  signal res_n_s         : std_logic;
66
  signal xtal3_s         : std_logic;
67
  signal int_n_s         : std_logic;
68
  signal ale_s           : std_logic;
69
  signal rom_addr_s      : std_logic_vector(11 downto 0);
70
  signal rom_data_s      : std_logic_vector( 7 downto 0);
71
  signal ram_data_to_s   : std_logic_vector( 7 downto 0);
72
  signal ram_data_from_s : std_logic_vector( 7 downto 0);
73
  signal ram_addr_s      : std_logic_vector( 7 downto 0);
74
  signal ram_we_s        : std_logic;
75
 
76
  signal p1_s            : std_logic_vector( 7 downto 0);
77
  signal t48_p1_s        : std_logic_vector( 7 downto 0);
78
  signal p1_limp_s       : std_logic;
79
  signal p2_s            : std_logic_vector( 7 downto 0);
80
  signal t48_p2_s        : std_logic_vector( 7 downto 0);
81
  signal p2_limp_s       : std_logic;
82 30 arniml
  signal prog_n_s        : std_logic;
83 8 arniml
 
84
  signal bus_s           : std_logic_vector( 7 downto 0);
85
  signal t48_bus_s       : std_logic_vector( 7 downto 0);
86
  signal bus_dir_s       : std_logic;
87
 
88
  signal ext_ram_addr_s      : std_logic_vector( 7 downto 0);
89
  signal ext_ram_data_from_s : std_logic_vector( 7 downto 0);
90
  signal ext_ram_we_s        : std_logic;
91
  signal rd_n_s              : std_logic;
92
  signal wr_n_s              : std_logic;
93
 
94
  signal zero_s          : std_logic;
95
  signal one_s           : std_logic;
96
  signal zero_byte_s     : std_logic_vector( 7 downto 0);
97
 
98
begin
99
 
100
  zero_s      <= '0';
101
  one_s       <= '1';
102
  zero_byte_s <= (others => '0');
103
 
104
  rom_4k : syn_rom
105
    generic map (
106
      address_width_g => 12
107
    )
108
    port map (
109
      clk_i      => xtal_s,
110
      rom_addr_i => rom_addr_s,
111
      rom_data_o => rom_data_s
112
    );
113
 
114
  ram_256 : syn_ram
115
    generic map (
116
      address_width_g => 8
117
    )
118
    port map (
119
      clk_i      => xtal_s,
120
      res_i      => res_n_s,
121
      ram_addr_i => ram_addr_s,
122
      ram_data_i => ram_data_to_s,
123
      ram_we_i   => ram_we_s,
124
      ram_data_o => ram_data_from_s
125
    );
126
 
127
  ext_ram_b : syn_ram
128
    generic map (
129
      address_width_g => 8
130
    )
131
    port map (
132
      clk_i      => xtal_s,
133
      res_i      => res_n_s,
134
      ram_addr_i => ext_ram_addr_s,
135
      ram_data_i => bus_s,
136
      ram_we_i   => ext_ram_we_s,
137
      ram_data_o => ext_ram_data_from_s
138
    );
139
 
140
  t48_core_b : t48_core
141
    generic map (
142
      xtal_div_3_g        => 1,
143
      register_mnemonic_g => 1,
144
      include_port1_g     => 1,
145
      include_port2_g     => 1,
146
      include_bus_g       => 1,
147
      include_timer_g     => 1,
148
      sample_t1_state_g   => 4
149
    )
150
    port map (
151
      xtal_i      => xtal_s,
152
      reset_i     => res_n_s,
153
      t0_i        => p1_s(0),
154
      t0_o        => open,
155
      t0_dir_o    => open,
156
      int_n_i     => int_n_s,
157
      ea_i        => zero_s,
158
      rd_n_o      => rd_n_s,
159
      psen_n_o    => open,
160
      wr_n_o      => wr_n_s,
161
      ale_o       => ale_s,
162
      db_i        => bus_s,
163
      db_o        => t48_bus_s,
164
      db_dir_o    => bus_dir_s,
165
      t1_i        => p1_s(1),
166
      p2_i        => p2_s,
167
      p2_o        => t48_p2_s,
168
      p2_limp_o   => p2_limp_s,
169
      p1_i        => p1_s,
170
      p1_o        => t48_p1_s,
171
      p1_limp_o   => p1_limp_s,
172 30 arniml
      prog_n_o    => prog_n_s,
173 8 arniml
      clk_i       => xtal_s,
174
      en_clk_i    => xtal3_s,
175
      xtal3_o     => xtal3_s,
176
      dmem_addr_o => ram_addr_s,
177
      dmem_we_o   => ram_we_s,
178
      dmem_data_i => ram_data_from_s,
179
      dmem_data_o => ram_data_to_s,
180
      pmem_addr_o => rom_addr_s,
181
      pmem_data_i => rom_data_s
182
    );
183
 
184
 
185
  -----------------------------------------------------------------------------
186
  -- Port logic
187
  --
188
  ports: process (t48_p1_s,
189
                  p1_limp_s,
190
                  t48_p2_s,
191
                  p2_limp_s)
192
    function t48_port_f(t48_p : std_logic_vector(7 downto 0);
193
                        limp  : std_logic) return std_logic_vector is
194
      variable p_v : std_logic_vector(7 downto 0);
195
    begin
196
      if limp = '1' then
197
        p_v := t48_p;
198
 
199
      else
200
        for i in p_v'range loop
201
          if t48_p(i) = '1' then
202
            p_v(i) := 'H';
203
          else
204
            p_v(i) := t48_p(i);
205
          end if;
206
        end loop;
207
 
208
      end if;
209
 
210
      return p_v;
211
    end;
212
 
213
  begin
214
 
215
    p1_s <= t48_port_f(t48_p => t48_p1_s,
216
                       limp  => p1_limp_s);
217
 
218
    p2_s <= t48_port_f(t48_p => t48_p2_s,
219
                       limp  => p2_limp_s);
220
 
221
  end process ports;
222
  --
223
  -----------------------------------------------------------------------------
224
 
225
  bus_s <=   t48_bus_s
226
           when bus_dir_s = '1' else
227
             (others => 'Z');
228
 
229
  bus_s <=   ext_ram_data_from_s
230
           when rd_n_s = '0' else
231
             (others => 'Z');
232
 
233
 
234
  -----------------------------------------------------------------------------
235
  -- External RAM access signals
236
  --
237
  ext_ram: process (wr_n_s,
238
                    ext_ram_addr_s,
239
                    ale_s,
240
                    bus_s,
241
                    xtal_s)
242
  begin
243
    if ale_s'event and ale_s = '0' then
244
      if not is_X(bus_s) then
245
        ext_ram_addr_s <= bus_s;
246
      else
247
        ext_ram_addr_s <= (others => '0');
248
      end if;
249
    end if;
250
 
251
    if wr_n_s'event and wr_n_s = '1' then
252
      ext_ram_we_s <= '1';
253
    end if;
254
 
255 10 arniml
    if xtal_s'event and xtal_s = '1' then
256 8 arniml
      ext_ram_we_s <= '0';
257
    end if;
258
 
259
  end process ext_ram;
260
  --
261
  -----------------------------------------------------------------------------
262
 
263 10 arniml
  xtal_n_s <= not xtal_s;
264
 
265 8 arniml
  -----------------------------------------------------------------------------
266
  -- The clock generator
267
  --
268
  clk_gen: process
269
  begin
270
    xtal_s <= '0';
271
    wait for period_c/2;
272
    xtal_s <= '1';
273
    wait for period_c/2;
274
  end process clk_gen;
275
  --
276
  -----------------------------------------------------------------------------
277
 
278
 
279
  -----------------------------------------------------------------------------
280
  -- The reset generator
281
  --
282
  res_gen: process
283
  begin
284
    res_n_s <= '0';
285
    wait for 5 * period_c;
286
    res_n_s <= '1';
287
    wait;
288
  end process res_gen;
289
  --
290
  -----------------------------------------------------------------------------
291
 
292
 
293
  -----------------------------------------------------------------------------
294
  -- The interrupt generator
295
  --
296
  int_gen: process
297
  begin
298
    int_n_s <= '1';
299
    wait for 750 * period_c;
300
    int_n_s <= '0';
301
    wait for  45 * period_c;
302
  end process int_gen;
303
  --
304
  -----------------------------------------------------------------------------
305
 
306
 
307
  -----------------------------------------------------------------------------
308
  -- End of simulation detection
309
  --
310
  eos: process
311
  begin
312
 
313
    outer: loop
314
      wait on tb_accu_s;
315
      if tb_accu_s = "10101010" then
316
        wait on tb_accu_s;
317
        if tb_accu_s = "01010101" then
318
          wait on tb_accu_s;
319
          if tb_accu_s = "00000001" then
320
            assert false
321 19 arniml
              report "Simulation Result: PASS."
322 8 arniml
              severity note;
323
          else
324
            assert false
325 19 arniml
              report "Simulation Result: FAIL."
326 8 arniml
              severity note;
327
          end if;
328
 
329
          assert false
330
            report "End of simulation reached."
331
            severity failure;
332
 
333
        end if;
334
      end if;
335
    end loop;
336
 
337
  end process eos;
338
  --
339
  -----------------------------------------------------------------------------
340
 
341
end behav;
342
 
343
 
344
-------------------------------------------------------------------------------
345
-- File History:
346
--
347
-- $Log: not supported by cvs2svn $
348 30 arniml
-- Revision 1.3  2004/03/26 22:39:28  arniml
349
-- enhance simulation result string
350
--
351 19 arniml
-- Revision 1.2  2004/03/24 23:22:35  arniml
352
-- put ext_ram on falling clock edge to sample the write enable properly
353
--
354 10 arniml
-- Revision 1.1  2004/03/24 21:42:10  arniml
355
-- initial check-in
356
--
357 8 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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