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

Subversion Repositories memory_cores

[/] [memory_cores/] [trunk/] [FIFO2/] [FIFOTEST.VHD] - Blame information for rev 25

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 olupas
--============================================================================--
2
-- Design units   : TestBench for FIFO memory device.
3
--
4
-- File name      : FIFOTest.vhd
5
--
6
-- Purpose        : Implements the test bench for FIFO memory device.
7
--
8
-- Library        : ECO_Lib.vhd
9
--
10
-- Dependencies : None
11
--
12
-- Author         : Ovidiu Lupas
13
--                 http://www.opencores.org/people/olupas
14
--                 olupas@opencores.org
15
--
16
-- Simulator     : ModelSim PE/PLUS version 4.7b on a Windows95 PC
17
--------------------------------------------------------------------------------
18
--------------------------------------------------------------------------------
19
-- Revision list
20
-- Version   Author             Date          Changes
21
--
22
-- 0.1      Ovidiu Lupas     18 April 99     New model
23
--------------------------------------------------------------------------------
24
-------------------------------------------------------------------------------
25
-- Clock generator
26
-------------------------------------------------------------------------------
27
library IEEE,work;
28
use IEEE.Std_Logic_1164.all;
29
--
30
entity ClkGen is
31
   port (
32
      WrClk     : out Std_Logic;
33
      RdClk     : out Std_Logic);   -- Oscillator clock
34
end ClkGen;--==================== End of entity ==============================--
35
--------------------------------------------------------------------------------
36
-- Architecture for clock and reset signals generator
37
--------------------------------------------------------------------------------
38
architecture Behaviour of ClkGen is
39
begin --========================== Architecture ==============================--
40
  ------------------------------------------------------------------------------
41
  -- Provide the external clock signal
42
  ------------------------------------------------------------------------------
43
  WrClkDriver : process
44
    variable clktmp : Std_Logic := '1';
45
    variable tpw_CI_posedge : Time := 31 ns; -- 16 MHz
46
  begin
47
     WrClk <= clktmp;
48
     clktmp := not clktmp;
49
    wait for tpw_CI_posedge;
50
  end process;
51
  ------------------------------------------------------------------------------
52
  -- Provide the external clock signal
53
  ------------------------------------------------------------------------------
54
  RdClkDriver : process
55
    variable clktmp : Std_Logic := '1';
56
    variable tpw_CI_posedge : Time := 51 ns; -- 16 MHz
57
  begin
58
     RdClk <= clktmp;
59
     clktmp := not clktmp;
60
    wait for tpw_CI_posedge;
61
  end process;
62
end Behaviour; --=================== End of architecure =====================--
63
--------------------------------------------------------------------------------
64
-- Testbench for FIFO memory
65
--------------------------------------------------------------------------------
66
library ieee;
67
use ieee.std_logic_1164.all;
68
use std.textio.all;
69
use work.ECO_Def.all;
70
 
71
entity FIFOTEST is
72
end FIFOTEST;
73
 
74
architecture stimulus of FIFOTEST is
75
  -------------------------------------------------------------------
76
  -- Global declarations
77
  -------------------------------------------------------------------
78
  type MEMORY is array(0 to 15) of Std_Logic_Vector(15 downto 0);
79
  constant Data : MEMORY := ("0101010101010101", "1010101010101010",
80
                             "1111101010100000", "1111010101010000",
81
                             "1111101010100000", "1111010101010000",
82
                             "0101010101010101", "1010101010101010",
83
                             "1111111111111111", "0000000000000000",
84
                             "1111101010100000", "1111010101010000",
85
                             "0101010101010101", "1010101010101010",
86
                             "1111111111111111", "0000000000000000");
87
  -------------------------------------------------------------------
88
  -- Signals
89
  -------------------------------------------------------------------
90
  signal Reset    : Std_Logic;  -- Synchro signal
91
  signal RdClk    : Std_Logic;  -- Clock signal
92
  signal WrClk    : Std_Logic;  -- Clock signal
93
  signal DataIn   : Std_Logic_Vector(15 downto 0);
94
  signal DataOut  : Std_Logic_Vector(15 downto 0);
95
  signal Push_N   : Std_Logic;
96
  signal Pop_N    : Std_Logic;
97
  signal AlmFull  : Std_Logic;
98
  signal AlmEmpty : Std_Logic;
99
  signal Full     : Std_Logic;
100
  signal Empty    : Std_Logic;
101
  -------------------------------------------------------------------
102
  -- Clock Generator
103
  -------------------------------------------------------------------
104
  component ClkGen is
105
   port (
106
      WrClk     : out Std_Logic;   -- Oscillator clock
107
      RdClk     : out Std_Logic);   -- Oscillator clock
108
  end component;
109
  -------------------------------------------------------------------
110
  -- Sensor Control Unit
111
  -------------------------------------------------------------------
112
  component FIFO is
113
     port (
114
       DataIn   : in  Std_Logic_Vector(15 downto 0);
115
       DataOut  : out Std_Logic_Vector(15 downto 0);
116
       WrClk    : in  Std_Logic;  -- Clock signal
117
       Push_N   : in  Std_Logic;  -- Clock signal
118
       RdClk    : in  Std_Logic;  -- Clock signal
119
       Pop_N    : in  Std_Logic;  -- Clock signal
120
       AlmFull  : out Std_Logic;  -- Status signal
121
       AlmEmpty : out Std_Logic;  -- Status signal
122
       Full     : out Std_Logic;  -- Status signal
123
       Empty    : out Std_Logic;  -- Status signal
124
       Reset    : in  Std_Logic); -- Reset input
125
  end component;
126
begin --======================== Architecture ========================--
127
  ---------------------------------------------------------------------
128
  -- Instantiation of components
129
  ---------------------------------------------------------------------
130
  Clock  : ClkGen port map (WrClk,RdClk);
131
  Mem    : FIFO   port map (DataIn,DataOut,WrClk,Push_N,RdClk,Pop_N,
132
                            AlmFull,AlmEmpty,Full,Empty,Reset);
133
  ---------------------------------------------------------------------
134
  -- Reset cycle
135
  ---------------------------------------------------------------------
136
  RstCyc : process
137
  begin
138
     Reset <= '1';
139
     wait for 5 ns;
140
     Reset <= '0';
141
     wait for 50 ns;
142
     Reset <= '1';
143
     wait;
144
  end process;
145
  ---------------------------------------------------------------------
146
  -- Read cycle
147
  ---------------------------------------------------------------------
148
  RdCyc : process(RdClk,Reset)
149
      variable temp : Std_Logic := '0';
150
      variable i    : Integer := 0;
151
  begin
152
     if Falling_Edge(Reset) then
153
        temp := '0';
154
        i := 0;
155
        Pop_N <= '1';
156
     elsif (Rising_Edge(RdClk) and Empty = '0') then
157
        temp := not temp;
158
        i := i + 1;
159
        if i = 15 then
160
           i := 0;
161
        end if;
162
        if temp = '0' then
163
           Pop_N <= '0';
164
        else
165
           Pop_N <= '1';
166
        end if;
167
     end if;
168
  end process;
169
  ---------------------------------------------------------------------
170
  -- Write cycle
171
  ---------------------------------------------------------------------
172
  WrCyc : process(WrClk,Reset)
173
     variable temp : Std_Logic := '1';
174
     variable i    : Integer := 0;
175
  begin
176
     if Falling_Edge(Reset) then
177
        temp := '0';
178
        i := 0;
179
        Push_N <= '1';
180
     elsif (Rising_Edge(WrClk) and Full = '0') then
181
        temp := not temp;
182
        i := i + 1;
183
        if i = 15 then
184
           i := 0;
185
        end if;
186
        if temp = '0' then
187
           Push_N <= '0';
188
           DataIn <= Data(i);
189
        else
190
           Push_N <= '1';
191
           DataIn <= "ZZZZZZZZZZZZZZZZ";
192
        end if;
193
     end if;
194
  end process;
195
end stimulus; --================== End of TestBench ==================--
196
 

powered by: WebSVN 2.1.0

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