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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_1/] [bench/] [vhdl/] [tb_t8039.vhd] - Blame information for rev 282

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 282 arniml
-- $Id: tb_t8039.vhd,v 1.5 2008-04-28 22:13:33 arniml Exp $
6 67 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_t8039 is
50
 
51
end tb_t8039;
52
 
53 228 arniml
use work.t48_core_comp_pack.generic_ram_ena;
54
use work.t48_system_comp_pack.t8039;
55 67 arniml
 
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 228 arniml
  component lpm_rom
64
    generic (
65
      LPM_WIDTH           : positive;
66
      LPM_TYPE            : string    := "LPM_ROM";
67
      LPM_WIDTHAD         : positive;
68
      LPM_NUMWORDS        : natural   := 0;
69
      LPM_FILE            : string;
70
      LPM_ADDRESS_CONTROL : string    := "REGISTERED";
71
      LPM_OUTDATA         : string    := "REGISTERED";
72
      LPM_HINT            : string    := "UNUSED"
73
    );
74 67 arniml
    port (
75 228 arniml
      address             : in  std_logic_vector(LPM_WIDTHAD-1 downto 0);
76
      inclock             : in  std_logic;
77
      outclock            : in  std_logic;
78
      memenab             : in  std_logic;
79
      q                   : out std_logic_vector(LPM_WIDTH-1 downto 0)
80 67 arniml
    );
81
  end component;
82
 
83
  signal xtal_s          : std_logic;
84
  signal res_n_s         : std_logic;
85
  signal int_n_s         : std_logic;
86
  signal ale_s           : std_logic;
87
  signal psen_n_s        : std_logic;
88
  signal prog_n_s        : std_logic;
89
 
90 282 arniml
  signal t0_b : std_logic;
91
 
92 67 arniml
  signal p1_b : std_logic_vector( 7 downto 0);
93
  signal p2_b : std_logic_vector( 7 downto 0);
94
 
95
  signal db_b                : std_logic_vector( 7 downto 0);
96
  signal ext_mem_addr_s      : std_logic_vector(11 downto 0);
97
  signal ext_ram_data_from_s : std_logic_vector( 7 downto 0);
98
  signal ext_ram_we_s        : std_logic;
99
  signal ext_rom_data_s      : std_logic_vector( 7 downto 0);
100
  signal rd_n_s              : std_logic;
101
  signal wr_n_s              : std_logic;
102
 
103
  signal zero_s          : std_logic;
104
  signal one_s           : std_logic;
105
 
106
begin
107
 
108
  zero_s <= '0';
109
  one_s  <= '1';
110
 
111
  p2_b   <= (others => 'H');
112
  p1_b   <= (others => 'H');
113
 
114 228 arniml
  -----------------------------------------------------------------------------
115
  -- External ROM, 4k bytes
116
  -- Initialized by file t3x_ext_rom.hex.
117
  -----------------------------------------------------------------------------
118
  ext_rom_b : lpm_rom
119 67 arniml
    generic map (
120 228 arniml
      LPM_WIDTH           => 8,
121
      LPM_TYPE            => "LPM_ROM",
122
      LPM_WIDTHAD         => 12,
123
      LPM_NUMWORDS        => 2 ** 12,
124
      LPM_FILE            => "rom_t3x_ext.hex",
125
      LPM_ADDRESS_CONTROL => "REGISTERED",
126
      LPM_OUTDATA         => "UNREGISTERED",
127
      LPM_HINT            => "UNUSED"
128 67 arniml
    )
129
    port map (
130 228 arniml
      address  => ext_mem_addr_s,
131
      inclock  => xtal_s,
132
      outclock => zero_s,               -- unused
133
      memenab  => one_s,
134
      q        => ext_rom_data_s
135 67 arniml
    );
136
 
137 228 arniml
  ext_ram_b : generic_ram_ena
138 67 arniml
    generic map (
139 228 arniml
      addr_width_g => 8,
140
      data_width_g => 8
141 67 arniml
    )
142
    port map (
143 228 arniml
      clk_i => xtal_s,
144
      a_i   => ext_mem_addr_s(7 downto 0),
145
      we_i  => ext_ram_we_s,
146
      ena_i => one_s,
147
      d_i   => db_b,
148
      d_o   => ext_ram_data_from_s
149 67 arniml
    );
150
 
151
  t8039_b : t8039
152
    port map (
153
      xtal_i    => xtal_s,
154
      reset_n_i => res_n_s,
155 282 arniml
      t0_b      => t0_b,
156 67 arniml
      int_n_i   => int_n_s,
157
      ea_i      => one_s,
158
      rd_n_o    => rd_n_s,
159
      psen_n_o  => psen_n_s,
160
      wr_n_o    => wr_n_s,
161
      ale_o     => ale_s,
162
      db_b      => db_b,
163
      t1_i      => p1_b(1),
164
      p2_b      => p2_b,
165
      p1_b      => p1_b,
166
      prog_n_o  => prog_n_s
167
    );
168
 
169
 
170
  -----------------------------------------------------------------------------
171
  -- Read from external memory
172
  --
173
  db_b <=   ext_rom_data_s
174
          when psen_n_s = '0' else
175
            (others => 'Z');
176
  db_b <=   ext_ram_data_from_s
177
          when rd_n_s = '0' else
178
            (others => 'Z');
179
  --
180
  -----------------------------------------------------------------------------
181
 
182
 
183
  -----------------------------------------------------------------------------
184
  -- External memory access signals
185
  --
186
  ext_mem: process (wr_n_s,
187
                    ale_s,
188
                    p2_b,
189
                    db_b)
190
  begin
191 202 arniml
    ext_mem_addr_s(11 downto 8) <= To_X01Z(p2_b(3 downto 0));
192 67 arniml
 
193 234 arniml
    if ale_s'event and ale_s = '0' then
194 67 arniml
      if not is_X(db_b) then
195
        ext_mem_addr_s(7 downto 0) <= db_b;
196
      else
197
        ext_mem_addr_s(7 downto 0) <= (others => '0');
198
      end if;
199
    end if;
200
 
201
    if wr_n_s'event and wr_n_s = '1' then
202 234 arniml
      ext_ram_we_s <= '0';
203
    end if;
204
    if wr_n_s'event and wr_n_s = '0' then
205 67 arniml
      ext_ram_we_s <= '1';
206
    end if;
207
 
208
  end process ext_mem;
209
  --
210
  -----------------------------------------------------------------------------
211
 
212 282 arniml
  t0_b <= p1_b(0);
213
 
214 67 arniml
  -----------------------------------------------------------------------------
215
  -- The clock generator
216
  --
217
  clk_gen: process
218
  begin
219
    xtal_s <= '0';
220
    wait for period_c/2;
221
    xtal_s <= '1';
222
    wait for period_c/2;
223
  end process clk_gen;
224
  --
225
  -----------------------------------------------------------------------------
226
 
227
 
228
  -----------------------------------------------------------------------------
229
  -- The reset generator
230
  --
231
  res_gen: process
232
  begin
233
    res_n_s <= '0';
234
    wait for 5 * period_c;
235
    res_n_s <= '1';
236
    wait;
237
  end process res_gen;
238
  --
239
  -----------------------------------------------------------------------------
240
 
241
 
242
  -----------------------------------------------------------------------------
243
  -- The interrupt generator
244
  --
245
  int_gen: process
246
  begin
247
    int_n_s <= '1';
248
    wait for 750 * period_c;
249
    int_n_s <= '0';
250
    wait for  45 * period_c;
251
  end process int_gen;
252
  --
253
  -----------------------------------------------------------------------------
254
 
255
 
256
  -----------------------------------------------------------------------------
257
  -- End of simulation detection
258
  --
259
  eos: process
260
  begin
261
 
262
    outer: loop
263
      wait on tb_accu_s;
264
      if tb_accu_s = "10101010" then
265
        wait on tb_accu_s;
266
        if tb_accu_s = "01010101" then
267
          wait on tb_accu_s;
268
          if tb_accu_s = "00000001" then
269
            -- wait for instruction strobe of this move
270
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
271
            -- wait for next strobe
272
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
273
            assert false
274
              report "Simulation Result: PASS."
275
              severity note;
276
          else
277
            assert false
278
              report "Simulation Result: FAIL."
279
              severity note;
280
          end if;
281
 
282
          assert false
283
            report "End of simulation reached."
284
            severity failure;
285
 
286
        end if;
287
      end if;
288
    end loop;
289
 
290
  end process eos;
291
  --
292
  -----------------------------------------------------------------------------
293
 
294
end behav;
295
 
296
 
297
-------------------------------------------------------------------------------
298
-- File History:
299
--
300
-- $Log: not supported by cvs2svn $
301 282 arniml
-- Revision 1.4  2006/06/22 00:21:58  arniml
302
-- cleanup & enhance external access
303
--
304 234 arniml
-- Revision 1.3  2006/06/21 01:04:05  arniml
305
-- replaced syn_ram and syn_rom with generic_ram_ena and t48_rom/t49_rom/t3x_rom
306
--
307 228 arniml
-- Revision 1.2  2005/11/01 21:22:28  arniml
308
-- fix address assignment
309
--
310 202 arniml
-- Revision 1.1  2004/04/18 19:00:07  arniml
311
-- initial check-in
312
--
313 67 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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