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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_5_beta/] [bench/] [vhdl/] [tb.vhd] - Blame information for rev 8

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

powered by: WebSVN 2.1.0

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