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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.storage/] [fifos/] [synchronizer/] [1.0/] [tb/] [tb_aif_we_top.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Testbench for design "aif_we_top_s"
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : tb_aif_we_top_send.vhd
6
-- Author     : 
7
-- Created    : 04.01.2006
8
-- Last update: 17.02.2006
9
-- Description: 
10
-------------------------------------------------------------------------------
11
-- Copyright (c) 2006 
12
-------------------------------------------------------------------------------
13
-- Revisions  :
14
-- Date        Version  Author  Description
15
-- 04.01.2006  1.0      AK      Created
16
-------------------------------------------------------------------------------
17
 
18
library ieee;
19
use ieee.std_logic_1164.all;
20
use ieee.std_logic_arith.all;
21
use ieee.std_logic_unsigned.all;
22
use work.txt_util.all;
23
-------------------------------------------------------------------------------
24
 
25
entity tb_aif_we_top is
26
 
27
end tb_aif_we_top;
28
 
29
-------------------------------------------------------------------------------
30
 
31
architecture rtl of tb_aif_we_top is
32
 
33
  component aif_we_out
34
    generic (
35
      data_width_g : integer := 32
36
      );
37
    port (
38
      clk      : in  std_logic;
39
      rst_n    : in  std_logic;
40
      a_we_in  : in  std_logic;
41
      ack_out  : out std_logic;
42
      we_out   : out std_logic;
43
      data_in  : in  std_logic_vector(data_width_g-1 downto 0);
44
      data_out : out std_logic_vector(data_width_g-1 downto 0);
45
      full_in : in  std_logic);
46
  end component;
47
 
48
  constant data_width_g : integer := 32;
49
 
50
  -- component ports
51
  signal clk          : std_logic;
52
  signal rst_n        : std_logic;
53
  signal ack_from_rx  : std_logic;
54
  signal we_from_rx   : std_logic;
55
  signal data_from_rx : std_logic_vector(data_width_g-1 downto 0);
56
  signal full_to_rx  : std_logic;
57
 
58
  -- clock and reset
59
  constant Period : time := 100 ns;
60
  constant Period2 : time := 10 ns;
61
 
62
  component aif_we_in
63
    generic (
64
      data_width_g : integer);
65
    port (
66
    clk : in std_logic;
67
      rst_n    : in  std_logic;
68
      we_in    : in  std_logic;
69
      data_in  : in  std_logic_vector(data_width_g-1 downto 0);
70
      data_out : out std_logic_vector(data_width_g-1 downto 0);
71
      full_out : out std_logic;
72
      a_we_out : out std_logic;
73
      ack_in   : in  std_logic
74
      );
75
  end component;
76
 
77
  signal we_to_tx     : std_logic;
78
  signal data_to_tx   : std_logic_vector(data_width_g-1 downto 0);
79
  signal data_from_tx : std_logic_vector(data_width_g-1 downto 0);
80
  signal full_from_tx : std_logic;
81
  signal a_we_from_tx : std_logic;
82
 
83
  signal   clk2        : std_logic;
84
--  constant clk2_scaler : integer := 3;
85
 
86
  signal cnt_tx_data_r  : std_logic_vector(data_width_g-1 downto 0);
87
  signal cnt_rx_data_r  : std_logic_vector(data_width_g-1 downto 0);
88
  signal rx_full_cnt_r : integer;
89
  signal tx_we_cnt_r    : integer;
90
 
91
  constant full_after_we_c : integer := 3;   -- after n data issue full
92
  constant full_length_c   : integer := 10;  -- cc full is asserted
93
  constant time_before_we_c : integer := 100;   -- delay after sending
94
  constant start_value_c    : integer := 3;
95
 
96
begin  -- rtl
97
 
98
  -- component instantiation
99
  DUT : aif_we_out
100
    generic map (
101
      data_width_g => data_width_g)
102
    port map (
103
      clk      => clk,
104
      rst_n    => rst_n,
105
      a_we_in  => a_we_from_tx,
106
      ack_out  => ack_from_rx,
107
      data_in  => data_from_tx,
108
      data_out => data_from_rx,
109
      we_out   => we_from_rx,
110
      full_in => full_to_rx
111
      );
112
 
113
  aif_we_in_1 : aif_we_in
114
    generic map (
115
      data_width_g => data_width_g)
116
    port map (
117
      clk      => clk2,
118
      rst_n    => rst_n,
119
      we_in    => we_to_tx,
120
      data_in  => data_to_tx,
121
      data_out => data_from_tx,
122
      full_out => full_from_tx,
123
      a_we_out => a_we_from_tx,
124
      ack_in   => ack_from_rx
125
      );
126
 
127
 
128
  -- receiving, use clk
129
  process (clk, rst_n)
130
  begin  -- process
131
    if rst_n = '0' then                 -- asynchronous reset (active low)
132
      cnt_rx_data_r  <= conv_std_logic_vector(start_value_c, data_width_g);
133
      full_to_rx    <= '0';
134
      rx_full_cnt_r <= 0;
135
 
136
    elsif clk'event and clk = '1' then  -- rising clock edge
137
      if we_from_rx = '1' and full_to_rx = '0' then
138
        assert cnt_rx_data_r = data_from_rx report "Error: rx data wrong wait: " &
139
          str(conv_integer(cnt_rx_data_r)) & "got: " &
140
          str(conv_integer(data_from_rx))
141
          severity error;
142
        cnt_rx_data_r  <= cnt_rx_data_r+1;
143
        rx_full_cnt_r <= rx_full_cnt_r + 1;
144
      end if;
145
 
146
      if rx_full_cnt_r > full_after_we_c + full_length_c -1 then
147
        full_to_rx    <= '0';
148
        rx_full_cnt_r <= 0;
149
      elsif rx_full_cnt_r > full_after_we_c-1 then
150
        full_to_rx    <= '1';
151
        rx_full_cnt_r <= rx_full_cnt_r+1;
152
      end if;
153
 
154
    end if;
155
 
156
  end process;
157
 
158
  -- transmit, use different clock.
159
  tx : process (clk2, rst_n)
160
  begin  -- process tx
161
    if rst_n = '0' then                 -- asynchronous reset (active low)
162
      tx_we_cnt_r   <= 0;
163
      data_to_tx    <= conv_std_logic_vector(start_value_c, data_width_g);
164
      cnt_tx_data_r <= conv_std_logic_vector(start_value_c, data_width_g);
165
      we_to_tx      <= '0';
166
 
167
    elsif clk2'event and clk2 = '1' then  -- rising clock edge
168
      if tx_we_cnt_r > 0 then
169
        tx_we_cnt_r <= tx_we_cnt_r-1;
170
        we_to_tx <= '0';
171
      end if;
172
      if full_from_tx = '0' then
173
        if tx_we_cnt_r = 0 then
174
          we_to_tx      <= '1';
175
          data_to_tx    <= cnt_tx_data_r;
176
          cnt_tx_data_r <= cnt_tx_data_r+1;
177
          tx_we_cnt_r   <= time_before_we_c;
178
        end if;
179
      end if;
180
    end if;
181
  end process tx;
182
 
183
  -- clock generation
184
  -- PROC  
185
  CLOCK1 : process                      -- generate clock signal for design
186
    variable clktmp : std_logic := '0';
187
  begin
188
    wait for PERIOD/2;
189
    clktmp := not clktmp;
190
    Clk    <= clktmp;
191
  end process CLOCK1;
192
 
193
  CLOCK2 : process                      -- generate clock signal for design
194
    variable clktmp : std_logic := '0';
195
  begin
196
    wait for PERIOD2/2;
197
    clktmp := not clktmp;
198
    Clk2   <= clktmp;
199
  end process CLOCK2;
200
 
201
  -- PROC
202
  RESET : process
203
  begin
204
    Rst_n <= '0';                       -- Reset the testsystem
205
    wait for 6*PERIOD;                  -- Wait 
206
    Rst_n <= '1';                       -- de-assert reset
207
    wait;
208
  end process RESET;
209
 
210
 
211
 
212
end rtl;
213
 
214
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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