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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_0/] [bench/] [vhdl/] [tb_t8048.vhd] - Blame information for rev 292

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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