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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_2/] [bench/] [vhdl/] [tb_t8048_t8243.vhd] - Blame information for rev 295

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

Line No. Rev Author Line
1 247 arniml
-------------------------------------------------------------------------------
2
--
3
-- The testbench for t8048 driving a t8243.
4
--
5 295 arniml
-- $Id: tb_t8048_t8243.vhd 295 2009-04-01 19:32:48Z arniml $
6 247 arniml
--
7
-- Copyright (c) 2006, 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_t8243 is
50
 
51
end tb_t8048_t8243;
52
 
53
 
54
use work.t48_core_comp_pack.generic_ram_ena;
55
use work.t48_system_comp_pack.t8048;
56
use work.t8243_comp_pack.t8243;
57
 
58
use work.t48_tb_pack.all;
59
 
60
architecture behav of tb_t8048_t8243 is
61
 
62
  -- clock period, 11 MHz
63
  constant period_c : time := 90 ns;
64
 
65
  component lpm_rom
66
    generic (
67
      LPM_WIDTH           : positive;
68
      LPM_TYPE            : string    := "LPM_ROM";
69
      LPM_WIDTHAD         : positive;
70
      LPM_NUMWORDS        : natural   := 0;
71
      LPM_FILE            : string;
72
      LPM_ADDRESS_CONTROL : string    := "REGISTERED";
73
      LPM_OUTDATA         : string    := "REGISTERED";
74
      LPM_HINT            : string    := "UNUSED"
75
    );
76
    port (
77
      address             : in  std_logic_vector(LPM_WIDTHAD-1 downto 0);
78
      inclock             : in  std_logic;
79
      outclock            : in  std_logic;
80
      memenab             : in  std_logic;
81
      q                   : out std_logic_vector(LPM_WIDTH-1 downto 0)
82
    );
83
  end component;
84
 
85
  signal xtal_s          : std_logic;
86
  signal res_n_s         : std_logic;
87
  signal int_n_s         : std_logic;
88
  signal ale_s           : std_logic;
89
  signal psen_n_s        : std_logic;
90
  signal prog_n_s        : std_logic;
91
 
92
  signal p1_b : std_logic_vector( 7 downto 0);
93
  signal p2_b : std_logic_vector( 7 downto 0);
94
 
95
  signal p4_b : std_logic_vector( 3 downto 0);
96
  signal p5_b : std_logic_vector( 3 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
  -----------------------------------------------------------------------------
118
  -- External ROM, 3k bytes
119
  -- Initialized by file t48_ext_rom.hex.
120
  -----------------------------------------------------------------------------
121
  ext_rom_b : lpm_rom
122
    generic map (
123
      LPM_WIDTH           => 8,
124
      LPM_TYPE            => "LPM_ROM",
125
      LPM_WIDTHAD         => 12,
126
      LPM_NUMWORDS        => 3 * (2 ** 10),
127
      LPM_FILE            => "rom_t48_ext.hex",
128
      LPM_ADDRESS_CONTROL => "REGISTERED",
129
      LPM_OUTDATA         => "UNREGISTERED",
130
      LPM_HINT            => "UNUSED"
131
    )
132
    port map (
133
      address  => ext_mem_addr_s,
134
      inclock  => xtal_s,
135
      outclock => zero_s,               -- unused
136
      memenab  => one_s,
137
      q        => ext_rom_data_s
138
    );
139
 
140
  ext_ram_b : generic_ram_ena
141
    generic map (
142
      addr_width_g => 8,
143
      data_width_g => 8
144
    )
145
    port map (
146
      clk_i => xtal_s,
147
      a_i   => ext_mem_addr_s(7 downto 0),
148
      we_i  => ext_ram_we_s,
149
      ena_i => one_s,
150
      d_i   => db_b,
151
      d_o   => ext_ram_data_from_s
152
    );
153
 
154
  t8048_b : t8048
155
    port map (
156
      xtal_i    => xtal_s,
157
      reset_n_i => res_n_s,
158
      t0_b      => p1_b(0),
159
      int_n_i   => int_n_s,
160
      ea_i      => zero_s,
161
      rd_n_o    => rd_n_s,
162
      psen_n_o  => psen_n_s,
163
      wr_n_o    => wr_n_s,
164
      ale_o     => ale_s,
165
      db_b      => db_b,
166
      t1_i      => p1_b(1),
167
      p2_b      => p2_b,
168
      p1_b      => p1_b,
169
      prog_n_o  => prog_n_s
170
    );
171
 
172
  t8243_b : t8243
173
    port map (
174
      cs_n_i   => zero_s,
175
      prog_n_i => prog_n_s,
176
      p2_b     => p2_b(3 downto 0),
177
      p4_b     => p4_b,
178
      p5_b     => p5_b,
179
      p6_b     => p4_b,
180
      p7_b     => p5_b
181
    );
182
 
183
  p4_b <= (others => 'H');
184
  p5_b <= (others => 'H');
185
 
186
 
187
  -----------------------------------------------------------------------------
188
  -- Read from external memory
189
  --
190
  db_b <=   ext_rom_data_s
191
          when psen_n_s = '0' else
192
            (others => 'Z');
193
  db_b <=   ext_ram_data_from_s
194
          when rd_n_s = '0' else
195
            (others => 'Z');
196
  --
197
  -----------------------------------------------------------------------------
198
 
199
 
200
  -----------------------------------------------------------------------------
201
  -- External RAM access signals
202
  --
203
  ext_ram: process (wr_n_s,
204
                    ale_s,
205
                    p2_b,
206
                    db_b)
207
  begin
208
    -- lowest 1k of external ROM is not used
209
    ext_mem_addr_s(11 downto 8) <= To_X01Z(p2_b(3 downto 0));
210
 
211
    if ale_s'event and ale_s = '0' then
212
      if not is_X(db_b) then
213
        ext_mem_addr_s(7 downto 0) <= db_b;
214
      else
215
        ext_mem_addr_s(7 downto 0) <= (others => '0');
216
      end if;
217
    end if;
218
 
219
    if wr_n_s'event and wr_n_s = '1' then
220
      ext_ram_we_s <= '0';
221
    end if;
222
    if wr_n_s'event and wr_n_s = '0' then
223
      ext_ram_we_s <= '1';
224
    end if;
225
 
226
  end process ext_ram;
227
  --
228
  -----------------------------------------------------------------------------
229
 
230
  -----------------------------------------------------------------------------
231
  -- The clock generator
232
  --
233
  clk_gen: process
234
  begin
235
    xtal_s <= '0';
236
    wait for period_c/2;
237
    xtal_s <= '1';
238
    wait for period_c/2;
239
  end process clk_gen;
240
  --
241
  -----------------------------------------------------------------------------
242
 
243
 
244
  -----------------------------------------------------------------------------
245
  -- The reset generator
246
  --
247
  res_gen: process
248
  begin
249
    res_n_s <= '0';
250
    wait for 5 * period_c;
251
    res_n_s <= '1';
252
    wait;
253
  end process res_gen;
254
  --
255
  -----------------------------------------------------------------------------
256
 
257
 
258
  -----------------------------------------------------------------------------
259
  -- The interrupt generator
260
  --
261
  int_gen: process
262
  begin
263
    int_n_s <= '1';
264
    wait for 750 * period_c;
265
    int_n_s <= '0';
266
    wait for  45 * period_c;
267
  end process int_gen;
268
  --
269
  -----------------------------------------------------------------------------
270
 
271
 
272
  -----------------------------------------------------------------------------
273
  -- End of simulation detection
274
  --
275
  eos: process
276
  begin
277
 
278
    outer: loop
279
      wait on tb_accu_s;
280
      if tb_accu_s = "10101010" then
281
        wait on tb_accu_s;
282
        if tb_accu_s = "01010101" then
283
          wait on tb_accu_s;
284
          if tb_accu_s = "00000001" then
285
            -- wait for instruction strobe of this move
286
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
287
            -- wait for next strobe
288
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
289
            assert false
290
              report "Simulation Result: PASS."
291
              severity note;
292
          else
293
            assert false
294
              report "Simulation Result: FAIL."
295
              severity note;
296
          end if;
297
 
298
          assert false
299
            report "End of simulation reached."
300
            severity failure;
301
 
302
        end if;
303
      end if;
304
    end loop;
305
 
306
  end process eos;
307
  --
308
  -----------------------------------------------------------------------------
309
 
310
end behav;

powered by: WebSVN 2.1.0

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