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

Subversion Repositories single_port

[/] [single_port/] [trunk/] [VHDL/] [tb_single_port.vhd] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 mgeng
----------------------------------------------------------------------
2
----                                                              ----
3
---- Single port asynchronous RAM simulation model                ----
4
----                                                              ----
5
---- This file is part of the single_port project                 ----
6
----                                                              ----
7
---- Description                                                  ----
8
---- This file specifies test bench harness for the single_port   ----
9
---- Memory. It also contains the configuration files for all the ----
10
---- tests.                                                       ----
11
----                                                              ----
12
---- Authors:                                                     ----
13
---- - Robert Paley, rpaley_yid@yahoo.com                         ----
14
---- - Michael Geng, vhdl@MichaelGeng.de                          ----
15
----                                                              ----
16
---- References:                                                  ----
17
----   1. The Designer's Guide to VHDL by Peter Ashenden          ----
18
----      ISBN: 1-55860-270-4 (pbk.)                              ----
19
----   2. Writing Testbenches - Functional Verification of HDL    ----
20
----      models by Janick Bergeron | ISBN: 0-7923-7766-4         ----
21
----                                                              ----
22
----------------------------------------------------------------------
23
----                                                              ----
24
---- Copyright (C) 2005 Authors and OPENCORES.ORG                 ----
25
----                                                              ----
26
---- This source file may be used and distributed without         ----
27
---- restriction provided that this copyright statement is not    ----
28
---- removed from the file and that any derivative work contains  ----
29
---- the original copyright notice and the associated disclaimer. ----
30
----                                                              ----
31
---- This source file is free software; you can redistribute it   ----
32
---- and/or modify it under the terms of the GNU Lesser General   ----
33
---- Public License as published by the Free Software Foundation; ----
34
---- either version 2.1 of the License, or (at your option) any   ----
35
---- later version.                                               ----
36
----                                                              ----
37
---- This source is distributed in the hope that it will be       ----
38
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
39
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
40
---- PURPOSE. See the GNU Lesser General Public License for more  ----
41
---- details.                                                     ----
42
----                                                              ----
43
---- You should have received a copy of the GNU Lesser General    ----
44
---- Public License along with this source; if not, download it   ----
45
---- from http://www.opencores.org/lgpl.shtml                     ----
46
----                                                              ----
47
----------------------------------------------------------------------
48 2 rpaley_yid
--
49 6 mgeng
-- CVS Revision History
50 2 rpaley_yid
--
51 6 mgeng
-- $Log: not supported by cvs2svn $
52 13 mgeng
-- Revision 1.2  2005/10/12 19:39:27  mgeng
53
-- Buses unconstrained, LGPL header added
54
--
55 6 mgeng
-- Revision 1.1.1.1  2003/01/14 21:48:11  rpaley_yid
56
-- initial checkin 
57 2 rpaley_yid
--
58 6 mgeng
-- Revision 1.1  2003/01/14 17:49:04  Default
59
-- Initial revision
60
--
61
-- Revision 1.2  2002/12/31 19:19:43  Default
62
-- Updated 'transaction statements for fixed simulator.
63
--
64
-- Revision 1.1  2002/12/24 18:10:18  Default
65
-- Initial revision
66
--
67 2 rpaley_yid
LIBRARY IEEE;
68
USE IEEE.STD_LOGIC_1164.ALL;
69
USE IEEE.NUMERIC_STD.ALL;
70
USE WORK.linked_list_mem_pkg.ALL;
71
USE WORK.single_port_pkg.all;
72
USE STD.TEXTIO.ALL;
73
 
74
ENTITY tb_single_port IS
75
END ENTITY tb_single_port;
76
 
77
ARCHITECTURE BHV of tb_single_port IS
78
 
79
COMPONENT single_port IS
80
  GENERIC (
81 6 mgeng
    rnwtQ : TIME := 1 NS);
82 2 rpaley_yid
  PORT (
83 6 mgeng
    d           : IN STD_LOGIC_VECTOR;
84
    q           : OUT STD_LOGIC_VECTOR;
85
    a           : IN STD_LOGIC_VECTOR;
86 13 mgeng
    nce         : IN  STD_LOGIC;
87
    nwe         : IN  STD_LOGIC;
88
    noe         : IN  STD_LOGIC;
89 6 mgeng
    dealloc_mem : BOOLEAN);
90 2 rpaley_yid
END COMPONENT single_port;
91
 
92
COMPONENT tc_single_port IS
93
  PORT (
94 6 mgeng
    to_srv  : OUT to_srv_typ;
95
    frm_srv : IN  STD_LOGIC_VECTOR);
96 2 rpaley_yid
END COMPONENT tc_single_port;
97 6 mgeng
  CONSTANT DATA_WIDTH : INTEGER := 32;
98
  CONSTANT ADDR_WIDTH : INTEGER := 16;
99 2 rpaley_yid
 
100 13 mgeng
  SIGNAL d             : STD_LOGIC_VECTOR(DATA_WIDTH - 1 DOWNTO 0);
101
  SIGNAL q             : STD_LOGIC_VECTOR(DATA_WIDTH - 1 DOWNTO 0);
102
  SIGNAL a             : STD_LOGIC_VECTOR(ADDR_WIDTH - 1 DOWNTO 0);
103
  SIGNAL nce, nwe, noe : STD_LOGIC;
104
  SIGNAL dealloc_mem   : BOOLEAN;
105
  SIGNAL to_srv        : to_srv_typ;
106
  SIGNAL frm_srv       : STD_LOGIC_VECTOR(d'RANGE);
107
  SIGNAL tie_vdd       : STD_LOGIC := '1';
108 2 rpaley_yid
BEGIN
109
  dut : single_port
110
    PORT MAP (
111 6 mgeng
      d           => d,
112
      a           => a,
113
      q           => q,
114 13 mgeng
      nce         => nce,
115
      nwe         => nwe,
116
      noe         => noe,
117 6 mgeng
      dealloc_mem => dealloc_mem);
118 2 rpaley_yid
 
119
  tc : tc_single_port
120
    PORT MAP (
121 6 mgeng
       to_srv  => to_srv,
122
       frm_srv => frm_srv);
123 2 rpaley_yid
 
124
  single_port_server : PROCESS
125 6 mgeng
    VARIABLE frm_srv_v    : STD_LOGIC_VECTOR(d'RANGE);
126 2 rpaley_yid
    CONSTANT ACCESS_DELAY : TIME := 5 NS;
127
  BEGIN
128
    -- Wait until the test case is finished setting up the next memory access.
129
    WAIT ON to_srv'TRANSACTION;
130
    CASE to_srv.do IS
131
      WHEN init =>
132
        ASSERT FALSE
133
          REPORT "initialized"
134
          SEVERITY NOTE;
135
      WHEN read => -- perform memory read
136 6 mgeng
        d <= STD_LOGIC_VECTOR(TO_SIGNED(to_srv.data, d'length));
137
        a <= STD_LOGIC_VECTOR(TO_UNSIGNED(to_srv.addr, a'length));
138 13 mgeng
        nce <= '0';
139
        noe <= '0';
140
        nwe <= '1';
141 2 rpaley_yid
        -- Wait for data to appear 
142
        WAIT FOR ACCESS_DELAY;
143
      WHEN write => -- perform memory write
144 6 mgeng
        d <= STD_LOGIC_VECTOR(TO_SIGNED(to_srv.data, d'length));
145
        a <= STD_LOGIC_VECTOR(TO_UNSIGNED(to_srv.addr, a'length));
146 13 mgeng
        nce <= '0';
147
        noe <= '1';
148
        nwe <= '0';
149 2 rpaley_yid
        WAIT FOR ACCESS_DELAY;
150
      WHEN dealloc => -- deallocate the linked list for the LL architecture
151
        dealloc_mem <= true;
152
      WHEN end_test => -- reached the end of the test case
153
        WAIT;
154
    END CASE;
155 6 mgeng
    frm_srv_v := q;
156 2 rpaley_yid
    -- Send message to test case to continue the test.
157
    frm_srv <= frm_srv_v ; WAIT FOR 0 NS;
158
  END PROCESS single_port_server;
159
END BHV;
160
 
161
CONFIGURATION ll_main_cfg OF TB_SINGLE_PORT IS
162
  FOR BHV
163
    FOR dut : single_port
164
      USE ENTITY work.single_port(LinkedList);
165
    END FOR; -- dut 
166
    FOR tc : tc_single_port
167
      USE ENTITY work.tc_single_port(TC0);
168
    END FOR; -- tc;
169
  END FOR; -- BHV
170
END CONFIGURATION ll_main_cfg;
171
 
172
CONFIGURATION ll_error_cfg OF TB_SINGLE_PORT IS
173
  FOR BHV
174
    FOR dut : single_port
175
      USE ENTITY work.single_port(LinkedList);
176
    END FOR; -- dut 
177
    FOR tc : tc_single_port
178
      USE ENTITY work.tc_single_port(TC1);
179
    END FOR; -- tc;
180
  END FOR; -- BHV
181
END CONFIGURATION ll_error_cfg ;
182
 
183
CONFIGURATION mem_main_cfg of TB_SINGLE_PORT IS
184
  FOR BHV
185
    FOR dut : single_port
186
      USE ENTITY work.single_port(ArrayMem);
187
    END FOR; -- dut
188
    FOR tc : tc_single_port
189
      USE ENTITY work.tc_single_port(TC0);
190
    END FOR; -- tc;
191
  END FOR; -- BHV
192
END CONFIGURATION mem_main_cfg;
193
 
194
CONFIGURATION mem_error_cfg of TB_SINGLE_PORT IS
195
  FOR BHV
196
    FOR dut : single_port
197
      USE ENTITY work.single_port(ArrayMem);
198
    END FOR; -- dut
199
    FOR tc : tc_single_port
200
      USE ENTITY work.tc_single_port(TC1);
201
    END FOR; -- tc;
202
  END FOR; -- BHV
203
END CONFIGURATION mem_error_cfg;
204
 
205
CONFIGURATION memnoflag_main_cfg of TB_SINGLE_PORT IS
206
  FOR BHV
207
    FOR dut : single_port
208
      USE ENTITY work.single_port(ArrayMemNoFlag);
209
    END FOR; -- dut
210
    FOR tc : tc_single_port
211
      USE ENTITY work.tc_single_port(TC0);
212
    END FOR; -- tc;
213
  END FOR; -- BHV
214
END CONFIGURATION memnoflag_main_cfg;
215
 
216
CONFIGURATION memnoflag_error_cfg of TB_SINGLE_PORT IS
217
  FOR BHV
218
    FOR dut : single_port
219
      USE ENTITY work.single_port(ArrayMemNoFlag);
220
    END FOR; -- dut
221
    FOR tc : tc_single_port
222
      USE ENTITY work.tc_single_port(TC1);
223
    END FOR; -- tc;
224
  END FOR; -- BHV
225
END CONFIGURATION memnoflag_error_cfg;

powered by: WebSVN 2.1.0

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