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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_0/] [bench/] [vhdl/] [tb_t8039.vhd] - Blame information for rev 339

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

powered by: WebSVN 2.1.0

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