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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_1_beta/] [bench/] [vhdl/] [tb_t8039.vhd] - Blame information for rev 312

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

Line No. Rev Author Line
1 67 arniml
-------------------------------------------------------------------------------
2
--
3
-- The testbench for t8039.
4
--
5
-- $Id: tb_t8039.vhd,v 1.1 2004-04-18 19:00:07 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_t8039 is
50
 
51
end tb_t8039;
52
 
53
use work.t48_core_comp_pack.syn_ram;
54
use work.t48_core_comp_pack.syn_rom;
55
 
56
use work.t48_tb_pack.all;
57
 
58
architecture behav of tb_t8039 is
59
 
60
  -- clock period, 11 MHz
61
  constant period_c : time := 90 ns;
62
 
63
  component t8039
64
    port (
65
      xtal_i    : in    std_logic;
66
      reset_n_i : in    std_logic;
67
      t0_b      : inout std_logic;
68
      int_n_i   : in    std_logic;
69
      ea_i      : in    std_logic;
70
      rd_n_o    : out   std_logic;
71
      psen_n_o  : out   std_logic;
72
      wr_n_o    : out   std_logic;
73
      ale_o     : out   std_logic;
74
      db_b      : inout std_logic_vector( 7 downto 0);
75
      t1_i      : in    std_logic;
76
      p2_b      : inout std_logic_vector( 7 downto 0);
77
      p1_b      : inout std_logic_vector( 7 downto 0);
78
      prog_n_o  : out   std_logic
79
    );
80
  end component;
81
 
82
  signal xtal_s          : std_logic;
83
  signal res_n_s         : std_logic;
84
  signal int_n_s         : std_logic;
85
  signal ale_s           : std_logic;
86
  signal psen_n_s        : std_logic;
87
  signal prog_n_s        : std_logic;
88
  signal rom_addr_s      : std_logic_vector(11 downto 0);
89
  signal rom_data_s      : std_logic_vector( 7 downto 0);
90
  signal ram_data_to_s   : std_logic_vector( 7 downto 0);
91
  signal ram_data_from_s : std_logic_vector( 7 downto 0);
92
  signal ram_addr_s      : std_logic_vector( 7 downto 0);
93
  signal ram_we_s        : std_logic;
94
 
95
  signal p1_b : std_logic_vector( 7 downto 0);
96
  signal p2_b : std_logic_vector( 7 downto 0);
97
 
98
  signal db_b                : std_logic_vector( 7 downto 0);
99
  signal ext_mem_addr_s      : std_logic_vector(11 downto 0);
100
  signal ext_ram_data_from_s : std_logic_vector( 7 downto 0);
101
  signal ext_ram_we_s        : std_logic;
102
  signal ext_rom_data_s      : std_logic_vector( 7 downto 0);
103
  signal rd_n_s              : std_logic;
104
  signal wr_n_s              : std_logic;
105
 
106
  signal zero_s          : std_logic;
107
  signal one_s           : std_logic;
108
 
109
begin
110
 
111
  zero_s <= '0';
112
  one_s  <= '1';
113
 
114
  p2_b   <= (others => 'H');
115
  p1_b   <= (others => 'H');
116
 
117
  ext_rom_b : syn_rom
118
    generic map (
119
      address_width_g => 12
120
    )
121
    port map (
122
      clk_i      => xtal_s,
123
      rom_addr_i => ext_mem_addr_s,
124
      rom_data_o => ext_rom_data_s
125
    );
126
 
127
  ext_ram_b : syn_ram
128
    generic map (
129
      address_width_g => 8
130
    )
131
    port map (
132
      clk_i      => zero_s,
133
      res_i      => res_n_s,
134
      ram_addr_i => ext_mem_addr_s(7 downto 0),
135
      ram_data_i => db_b,
136
      ram_we_i   => ext_ram_we_s,
137
      ram_data_o => ext_ram_data_from_s
138
    );
139
 
140
  t8039_b : t8039
141
    port map (
142
      xtal_i    => xtal_s,
143
      reset_n_i => res_n_s,
144
      t0_b      => p1_b(0),
145
      int_n_i   => int_n_s,
146
      ea_i      => one_s,
147
      rd_n_o    => rd_n_s,
148
      psen_n_o  => psen_n_s,
149
      wr_n_o    => wr_n_s,
150
      ale_o     => ale_s,
151
      db_b      => db_b,
152
      t1_i      => p1_b(1),
153
      p2_b      => p2_b,
154
      p1_b      => p1_b,
155
      prog_n_o  => prog_n_s
156
    );
157
 
158
 
159
  -----------------------------------------------------------------------------
160
  -- Read from external memory
161
  --
162
  db_b <=   ext_rom_data_s
163
          when psen_n_s = '0' else
164
            (others => 'Z');
165
  db_b <=   ext_ram_data_from_s
166
          when rd_n_s = '0' else
167
            (others => 'Z');
168
  --
169
  -----------------------------------------------------------------------------
170
 
171
 
172
  -----------------------------------------------------------------------------
173
  -- External memory access signals
174
  --
175
  ext_mem: process (wr_n_s,
176
                    ale_s,
177
                    p2_b,
178
                    db_b)
179
  begin
180
    ext_mem_addr_s(11 downto 8) <= p2_b(3 downto 0);
181
 
182
    if ale_s = '1' then
183
      if not is_X(db_b) then
184
        ext_mem_addr_s(7 downto 0) <= db_b;
185
      else
186
        ext_mem_addr_s(7 downto 0) <= (others => '0');
187
      end if;
188
    end if;
189
 
190
    if wr_n_s'event and wr_n_s = '1' then
191
      ext_ram_we_s <= '1';
192
    end if;
193
 
194
--    if clk_s'event then
195
--      ext_ram_we_s <= '0';
196
--    end if;
197
 
198
  end process ext_mem;
199
  --
200
  -----------------------------------------------------------------------------
201
 
202
  -----------------------------------------------------------------------------
203
  -- The clock generator
204
  --
205
  clk_gen: process
206
  begin
207
    xtal_s <= '0';
208
    wait for period_c/2;
209
    xtal_s <= '1';
210
    wait for period_c/2;
211
  end process clk_gen;
212
  --
213
  -----------------------------------------------------------------------------
214
 
215
 
216
  -----------------------------------------------------------------------------
217
  -- The reset generator
218
  --
219
  res_gen: process
220
  begin
221
    res_n_s <= '0';
222
    wait for 5 * period_c;
223
    res_n_s <= '1';
224
    wait;
225
  end process res_gen;
226
  --
227
  -----------------------------------------------------------------------------
228
 
229
 
230
  -----------------------------------------------------------------------------
231
  -- The interrupt generator
232
  --
233
  int_gen: process
234
  begin
235
    int_n_s <= '1';
236
    wait for 750 * period_c;
237
    int_n_s <= '0';
238
    wait for  45 * period_c;
239
  end process int_gen;
240
  --
241
  -----------------------------------------------------------------------------
242
 
243
 
244
  -----------------------------------------------------------------------------
245
  -- End of simulation detection
246
  --
247
  eos: process
248
  begin
249
 
250
    outer: loop
251
      wait on tb_accu_s;
252
      if tb_accu_s = "10101010" then
253
        wait on tb_accu_s;
254
        if tb_accu_s = "01010101" then
255
          wait on tb_accu_s;
256
          if tb_accu_s = "00000001" then
257
            -- wait for instruction strobe of this move
258
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
259
            -- wait for next strobe
260
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
261
            assert false
262
              report "Simulation Result: PASS."
263
              severity note;
264
          else
265
            assert false
266
              report "Simulation Result: FAIL."
267
              severity note;
268
          end if;
269
 
270
          assert false
271
            report "End of simulation reached."
272
            severity failure;
273
 
274
        end if;
275
      end if;
276
    end loop;
277
 
278
  end process eos;
279
  --
280
  -----------------------------------------------------------------------------
281
 
282
end behav;
283
 
284
 
285
-------------------------------------------------------------------------------
286
-- File History:
287
--
288
-- $Log: not supported by cvs2svn $
289
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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