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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_2_beta/] [bench/] [vhdl/] [tb.vhd] - Blame information for rev 10

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

powered by: WebSVN 2.1.0

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