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

Subversion Repositories single_port

[/] [single_port/] [trunk/] [VHDL/] [tc_single_port.vhd] - Blame information for rev 17

Go to most recent revision | 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 cases for the single_port Memory.   ----
9
----                                                              ----
10
---- Authors:                                                     ----
11
---- - Robert Paley, rpaley_yid@yahoo.com                         ----
12
---- - Michael Geng, vhdl@MichaelGeng.de                          ----
13
----                                                              ----
14
---- References:                                                  ----
15
----   1. The Designer's Guide to VHDL by Peter Ashenden          ----
16
----      ISBN: 1-55860-270-4 (pbk.)                              ----
17
----   2. Writing Testbenches - Functional Verification of HDL    ----
18
----      models by Janick Bergeron | ISBN: 0-7923-7766-4         ----
19
----                                                              ----
20
----------------------------------------------------------------------
21
----                                                              ----
22
---- Copyright (C) 2005 Authors and OPENCORES.ORG                 ----
23
----                                                              ----
24
---- This source file may be used and distributed without         ----
25
---- restriction provided that this copyright statement is not    ----
26
---- removed from the file and that any derivative work contains  ----
27
---- the original copyright notice and the associated disclaimer. ----
28
----                                                              ----
29
---- This source file is free software; you can redistribute it   ----
30
---- and/or modify it under the terms of the GNU Lesser General   ----
31
---- Public License as published by the Free Software Foundation; ----
32
---- either version 2.1 of the License, or (at your option) any   ----
33
---- later version.                                               ----
34
----                                                              ----
35
---- This source is distributed in the hope that it will be       ----
36
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
37
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
38
---- PURPOSE. See the GNU Lesser General Public License for more  ----
39
---- details.                                                     ----
40
----                                                              ----
41
---- You should have received a copy of the GNU Lesser General    ----
42
---- Public License along with this source; if not, download it   ----
43
---- from http://www.opencores.org/lgpl.shtml                     ----
44
----                                                              ----
45
----------------------------------------------------------------------
46 2 rpaley_yid
--
47 6 mgeng
-- CVS Revision History
48 2 rpaley_yid
--
49 6 mgeng
-- $Log: not supported by cvs2svn $
50
-- Revision 1.1.1.1  2003/01/14 21:48:11  rpaley_yid
51
-- initial checkin 
52 2 rpaley_yid
--
53 6 mgeng
-- Revision 1.1  2003/01/14 17:49:04  Default
54
-- Initial revision
55
--
56
-- Revision 1.2  2002/12/31 19:19:43  Default
57
-- Updated 'transaction statements for fixed simulator.
58
--
59
-- Revision 1.1  2002/12/24 18:13:50  Default
60
-- Initial revision
61
--
62 2 rpaley_yid
LIBRARY IEEE;
63
USE IEEE.STD_LOGIC_1164.ALL;
64
USE IEEE.NUMERIC_STD.ALL;
65
USE WORK.SINGLE_PORT_PKG.ALL;
66
USE WORK.PKG_IMAGE.ALL;
67
 
68
ENTITY tc_single_port IS
69
PORT  (
70 6 mgeng
  to_srv  : OUT to_srv_typ;
71
  frm_srv : IN  STD_LOGIC_VECTOR);
72 2 rpaley_yid
END ENTITY tc_single_port;
73
 
74
-- --------------------------------------------------
75
-- Test Case TC0
76
-- This test case is to check two pages of memory 
77
-- Starting at physical address 0x0 , 
78
-- Write a '1' to bit position 0, leaving all other bits 0.
79
-- Increment the address, 
80
-- Write a '1' to bit position 1, leaving all other bits 0.
81
-- Increment the address.
82
-- Write a '1' to bit position 2, leaving all other bits 0.
83
-- Continue in this fasion, until write a 1 to the MSB.
84
-- increment the address,
85
-- Write a '1' to bit position 0, leaving all other bits 0.
86
-- Continue until the entire page is written to.
87
-- Read back all addresses in the page, ensuring the
88
-- correct data is read back.
89
-- --------------------------------------------------
90
 
91
 
92
ARCHITECTURE TC0 OF tc_single_port IS
93
BEGIN
94
  MAIN : PROCESS
95 6 mgeng
    VARIABLE to_srv_v  : to_srv_typ;
96
    VARIABLE frm_srv_v : STD_LOGIC_VECTOR(frm_srv'RANGE);
97
    VARIABLE dv        : STD_LOGIC_VECTOR(frm_srv'RANGE) :=
98
                         STD_LOGIC_VECTOR(TO_UNSIGNED(1, frm_srv'length));
99
    VARIABLE offset_v  : INTEGER;
100 2 rpaley_yid
  BEGIN
101
    offset_v := 0;
102
    -- Run this write/read test 10 times for benchmark
103
    -- purposes.
104 6 mgeng
    FOR i IN 0 to 9 LOOP
105
      FOR index IN 0 to 2*PAGEDEPTH-1 LOOP
106
        -- Specify to testbench server to perform write operation;
107
        to_srv_v.do := write;
108
        to_srv_v.data := TO_INTEGER(SIGNED(dv)); -- specify data to write
109
        dv := To_StdLogicVector(TO_BitVector(dv) ROL 1); -- ROL 1 for next write
110
        -- Specify physical address.
111
        to_srv_v.addr := index+offset_v;
112
        to_srv <= to_srv_v;
113
        WAIT ON frm_srv'TRANSACTION;
114
      END LOOP;
115
      -- Reset data to 1.
116
      dv := STD_LOGIC_VECTOR(TO_UNSIGNED(1,frm_srv'length));
117
      FOR index IN 0 to 2*PAGEDEPTH-1 LOOP
118
        -- Perform read operation. 
119
        to_srv_v.do := read;
120
        -- Specify physical address.
121
        to_srv_v.addr := index+offset_v;
122
        to_srv <= to_srv_v;
123
        WAIT ON frm_srv'TRANSACTION;
124
        -- Compare actual with expected read back data, if the
125
        -- the expected and actual to not compare, print the 
126
        -- expected and actual values.
127
        ASSERT frm_srv = dv
128
          REPORT "Expected: " & HexImage(frm_srv) &
129
                 " did not equal Actual: " & HexImage(dv)
130
          SEVERITY ERROR;
131
        -- Set expected data for next read.
132
        dv := TO_STDLOGICVECTOR(TO_BITVECTOR(dv) ROL 1);
133
      END LOOP;
134
    END LOOP;
135 2 rpaley_yid
    to_srv_v.do := dealloc; -- Deallocate memory
136
    --  
137 6 mgeng
    to_srv <= to_srv_v;
138 2 rpaley_yid
    -- Tell test bench server process test completed.
139
    to_srv_v.do := end_test;
140
    to_srv <= to_srv_v;
141
    ASSERT FALSE
142
      REPORT "Completed Test TC0"
143
      SEVERITY NOTE;
144
    WAIT;
145
  END PROCESS main;
146
END TC0;
147
 
148
-- --------------------------------------------------
149
-- Test Case TC1
150
-- This test case is to check if the test bench will
151
-- return 'U' for invalid memory locations for 
152 6 mgeng
-- single_port architectures ArrayMem and LinkedList
153 2 rpaley_yid
-- --------------------------------------------------
154
ARCHITECTURE TC1 OF tc_single_port IS
155
BEGIN
156
  MAIN : PROCESS
157 6 mgeng
    VARIABLE to_srv_v  : to_srv_typ;
158
    VARIABLE frm_srv_v : STD_LOGIC_VECTOR(frm_srv'RANGE);
159
    VARIABLE dv        : STD_LOGIC_VECTOR(frm_srv'RANGE) := (OTHERS => 'U');
160 2 rpaley_yid
  BEGIN
161
    -- Perform read operation. 
162
    to_srv_v.do := read;
163
    -- Specify physical address.
164 6 mgeng
    to_srv_v.addr := 0;
165
    to_srv <= to_srv_v;
166 2 rpaley_yid
    WAIT ON frm_srv'TRANSACTION;
167
    -- Compare actual with expected read back data, if the
168
    -- the expected and actual to not compare, print the 
169
    -- expected and actual values.
170 6 mgeng
    ASSERT frm_srv = dv
171
      REPORT "Expected: " & HexImage(frm_srv) &
172 2 rpaley_yid
             " did not equal Actual: " & HexImage(dv)
173
      SEVERITY ERROR;
174
 
175
    -- Write and read back from same address.
176
 
177
    -- Specify to testbench server to perform write operation;
178
    to_srv_v.do := write;
179
    dv := X"a5a5a5a5";
180 6 mgeng
    to_srv_v.data := TO_INTEGER(SIGNED(dv)); -- specify data to write
181 2 rpaley_yid
    -- Specify physical address.
182 6 mgeng
    to_srv_v.addr := 0;
183
    to_srv <= to_srv_v;
184 2 rpaley_yid
    -- Wait until the test bench server finished with the write.
185
    -- WAIT UNTIL frm_srv.event = true; 
186 6 mgeng
    WAIT ON frm_srv'TRANSACTION;
187 2 rpaley_yid
 
188
    to_srv_v.do := read;
189
    -- Specify physical address.
190 6 mgeng
    to_srv_v.addr := 0;
191
    to_srv <= to_srv_v;
192
    WAIT ON frm_srv'TRANSACTION;
193 2 rpaley_yid
 
194
    -- Compare actual with expected read back data, if the
195
    -- the expected and actual to not compare, print the 
196
    -- expected and actual values.
197 6 mgeng
    ASSERT frm_srv = dv
198
      REPORT "Expected: " & HexImage(frm_srv) &
199 2 rpaley_yid
             " did not equal Actual: " & HexImage(dv)
200
      SEVERITY ERROR;
201
 
202
    to_srv_v.do := dealloc; -- Deallocate memory
203
    --  
204 6 mgeng
    to_srv <= to_srv_v;
205 2 rpaley_yid
    -- Tell test bench server process test completed.
206
    to_srv_v.do := end_test;
207 6 mgeng
    to_srv <= to_srv_v;
208 2 rpaley_yid
 
209
    ASSERT FALSE
210
      REPORT "Completed Test TC1"
211
      SEVERITY NOTE;
212
    WAIT;
213
  END PROCESS main;
214
END TC1;

powered by: WebSVN 2.1.0

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