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

Subversion Repositories memory_cores

[/] [memory_cores/] [trunk/] [dpmem/] [dpmem2clk/] [dpmem2clk_tb.vhd] - Blame information for rev 16

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

Line No. Rev Author Line
1 16 khatib
-------------------------------------------------------------------------------
2
-- Title      : dpmem Test Bench
3
-- Project    : Memory Cores/FIFO
4
-------------------------------------------------------------------------------
5
-- File        : DPMEM2CLK_TB.VHD
6
-- Author      : Jamil Khatib  <khatib@ieee.org>
7
-- Organization: OpenIPCore Project
8
-- Created     : 2000/03/19
9
-- Last update : 2000/03/19
10
-- Platform    : 
11
-- Simulators  : Modelsim 5.2EE / Windows98
12
-- Synthesizers: 
13
-- Target      :
14
-- Dependency  : It uses VHDL 93 file syntax
15
-------------------------------------------------------------------------------
16
-- Description: Dual port memory Test bench
17
-------------------------------------------------------------------------------
18
-- Copyright (c) 2000 Jamil Khatib
19
-- 
20
-- This VHDL design file is an open design; you can redistribute it and/or
21
-- modify it and/or implement it under the terms of the Openip General Public
22
-- License as it is going to be published by the OpenIPCore Organization and
23
-- any coming versions of this license.
24
-- You can check the draft license at
25
-- http://www.openip.org/oc/license.html
26
 
27
-------------------------------------------------------------------------------
28
-- Revisions  :
29
-- Revision Number : 1
30
-- Version              :   0.1
31
-- Date             :   19th Mar 2000
32
-- Modifier     :   Jamil Khatib (khatib@ieee.org)
33
-- Desccription :       Created
34
--
35
-------------------------------------------------------------------------------
36
 
37
library ieee;
38
use ieee.std_logic_arith.all;
39
use ieee.std_logic_1164.all;
40
use ieee.STD_LOGIC_UNSIGNED.all;
41
 
42
use std.textio.all;
43
 
44
entity dpmem2clk_tb is
45
  -- Generic declarations of the tested unit
46
  generic(
47
    WIDTH                                    :       integer   := 8;
48
    ADD_WIDTH                                :       integer   := 4;
49
    RCLKTIME                                 :       time      := 100 ns;
50
    WCLKTIME                                 :       time      := 90 ns;
51
    OUTPUTDELAY                              :       time      := 40 ns  -- output delay after teh rising edge
52
                                        -- of the clock
53
    );
54
end dpmem2clk_tb;
55
 
56
 
57
library ieee;
58
use ieee.std_logic_arith.all;
59
use ieee.std_logic_1164.all;
60
use ieee.STD_LOGIC_UNSIGNED.all;
61
 
62
library synopsys;
63
use synopsys.arithmetic.all;
64
 
65
architecture behavior of dpmem2clk_tb is
66
 
67
  constant                    MAX_STATES     :       integer   := 16;
68
 
69
  component dpmem2clk
70
 
71
    generic (
72
      ADD_WIDTH                              :       integer   := ADD_WIDTH;  -- Address width
73
      WIDTH                                  :       integer   := WIDTH;  -- Word Width
74
      coretype                               :       integer   := 0);  -- memory bulding block type
75
 
76
    port (
77
      Wclk                                   : in    std_logic;  -- write clock
78
      Wen                                    : in    std_logic;  -- Write Enable
79
      Wadd                                   : in    std_logic_vector(ADD_WIDTH -1 downto 0);  -- Write Address
80
      Datain                                 : in    std_logic_vector(WIDTH -1 downto 0);  -- Input Data
81
      Rclk                                   : in    std_logic;  -- Read clock
82
      Ren                                    : in    std_logic;  -- Read Enable
83
      Radd                                   : in    std_logic_vector(ADD_WIDTH -1 downto 0);  -- Read Address
84
      Dataout                                : out   std_logic_vector(WIDTH -1 downto 0));  -- Output data
85
 
86
  end component;
87
 
88
  type TABLE_typ is array (0 to MAX_STATES - 1 ) of std_logic_vector( 1 downto 0);
89
 
90
  signal                      TABLE          :       TABLE_typ;
91
 
92
 
93
 
94
  --INITs the table
95
  procedure init_table(signal L_TABLE        : inout TABLE_typ
96
                       ) is
97
  begin
98
    L_TABLE                                                    <= (
99
      "00",                             --nn
100
      "10",                             --wn
101
      "10",                             --wn
102
      "11",                             --wr
103
      "11",                             --wr
104
      "01",                             --nr
105
      "01",                             --nr
106
      "01",                             --nr
107
      "10",                             --wn
108
      "11",                             --wr
109
      "10",                             --wn
110
      "01",                             --nr
111
      "01",                             --nr
112
      "01",                             --nr
113
      "11",                             --wr
114
      "00"                              --nn
115
      );
116
 
117
  end;
118
 
119
 
120
 
121
  signal                      wclk_tb        :       std_logic := '0';
122
  signal                      wen_tb         :       std_logic;
123
  signal                      wadd_tb        :       std_logic_vector( ADD_WIDTH-1 downto 0);
124
  signal                      datain_tb      :       std_logic_vector(WIDTH -1 downto 0);
125
  signal                      rclk_tb        :       std_logic := '0';
126
  signal                      ren_tb         :       std_logic;
127
  signal                      radd_tb        :       std_logic_vector(ADD_WIDTH -1 downto 0);
128
  signal                      dataout_tb     :       std_logic_vector(WIDTH -1 downto 0);
129
  signal                      dataout_tb_syn :       std_logic_vector(WIDTH -1 downto 0);
130
  signal                      reset          :       std_logic;
131
 
132
 
133
 
134
begin
135
 
136
-- Reset generation
137
  reset                                                        <= transport '0'                               after 0 ns,
138
                                                                  '1'                                         after 10 ns;
139
 
140
-- Clock generation
141
  rclk_tb                                                      <= not rclk_tb                                 after RCLKTIME/2;
142
  wclk_tb                                                      <= not wclk_tb                                 after WCLKTIME/2;
143
 
144
-- UUT componenet 
145
  uut                                        :       dpmem2clk
146
    generic map
147
    (
148
      ADD_WIDTH => ADD_WIDTH,
149
      WIDTH     => WIDTH,
150
      coretype  => 0
151
      )
152
 
153
    port map (
154
 
155
      Wclk      => wclk_tb,
156
      Wen       => wen_tb,
157
      Wadd      => wadd_tb,
158
      Datain    => datain_tb,
159
      Rclk      => rclk_tb,
160
      Ren       => ren_tb,
161
      Radd      => radd_tb,
162
      Dataout   => dataout_tb
163
 
164
      );
165
 
166
 
167
  uut_syn                                    :       dpmem2clk
168
    port map (
169
 
170
      Wclk      => wclk_tb,
171
      Wen       => wen_tb,
172
      Wadd      => wadd_tb,
173
      Datain    => datain_tb,
174
      Rclk      => rclk_tb,
175
      Ren       => ren_tb,
176
      Radd      => radd_tb,
177
      Dataout   => dataout_tb_syn
178
 
179
      );
180
 
181
 
182
-- Read process 
183
  read_proc                                  :       process(rclk_tb, reset)
184
    variable                  count          :       integer;
185
    variable                  readcount      :       integer   := 0;
186
  begin
187
    if reset = '0' then
188
      init_table(TABLE);
189
 
190
    elsif rclk_tb'event and rclk_tb = '1' then
191
 
192
 
193
      count                                                    := count +1;
194
 
195
      if count > (MAX_STATES-1) or count < 0 then
196
        count                                                  := 0;
197
      end if;
198
 
199
      ren_tb                                                   <= TABLE(readcount)(0)                         after OUTPUTDELAY;
200
      readcount                                                := readcount +1;
201
 
202
 
203
      if readcount > ((2**ADD_WIDTH)-1) or readcount < 0 then
204
        readcount                                              := 0;
205
      end if;
206
    end if;
207
 
208
    radd_tb                                                    <= conv_std_logic_vector(readcount, ADD_WIDTH) after OUTPUTDELAY;
209
 
210
  end process read_proc;
211
 
212
 
213
-- Write process 
214
  write_proc                                 :       process(wclk_tb, reset)
215
    variable                  count          :       integer;
216
    variable                  writecount     :       integer   := 0;
217
    variable                  dataincount    :       integer   := 0;
218
  begin
219
 
220
    if wclk_tb'event and wclk_tb = '1' then
221
 
222
 
223
      count                                                    := count +1;
224
 
225
      if count > (MAX_STATES-1) or count < 0 then
226
        count                                                  := 0;
227
 
228
      end if;
229
 
230
      writecount                                               := writecount +1;
231
 
232
 
233
      if writecount > ((2**ADD_WIDTH)-1) or writecount < 0 then
234
        writecount                                             := 0;
235
      end if;
236
 
237
      wadd_tb                                                  <= conv_std_logic_vector(writecount, ADD_WIDTH);
238
 
239
      wen_tb                                                   <= TABLE(writecount)(1)                        after OUTPUTDELAY;
240
 
241
      dataincount                                              := dataincount +1;
242
 
243
      if dataincount > (WIDTH-1) or dataincount < 0 then
244
        dataincount                                            := 0;
245
      end if;
246
 
247
      datain_tb                                                <= conv_std_logic_vector(dataincount, WIDTH)   after OUTPUTDELAY;
248
 
249
    end if;
250
  end process write_proc;
251
 
252
 
253
end;
254
 
255
 
256
-- Test bench Configuration
257
configuration TESTBENCH_FOR_DPMEM of dpmem2clk_tb is
258
  for behavior
259
    for UUT                                  :       dpmem2clk
260
      use entity work.dpmem2clk(dpmem_arch);
261
    end for;
262
 
263
    for UUT_syn                              :       dpmem2clk
264
      use entity work.dpmem2clk(STRUCTURE);
265
    end for;
266
 
267
  end for;
268
end TESTBENCH_FOR_DPMEM;

powered by: WebSVN 2.1.0

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