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/] [sdram2hibi/] [1.0/] [tb/] [tb_sdram_toplevel.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : tb_sdram_toplevel
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : tb_sdram_toplevel.vhd
6
-- Author     : 
7
-- Company    : 
8
-- Created    : 2006-10-03
9
-- Last update: 2006-10-24
10
-- Platform   : 
11
-- Standard   : VHDL'87
12
-------------------------------------------------------------------------------
13
-- Description: Toplevel for SDRAM testbench
14
-------------------------------------------------------------------------------
15
-- Copyright (c) 2006 
16
-------------------------------------------------------------------------------
17
-- Revisions  :
18
-- Date        Version  Author  Description
19
-- 2006-10-03  1.0      penttin5        Created
20
-------------------------------------------------------------------------------
21
 
22
library ieee;
23
use ieee.std_logic_1164.all;
24
use ieee.numeric_std.all;
25
 
26
entity tb_sdram_toplevel is
27
end tb_sdram_toplevel;
28
 
29
architecture behavioral of tb_sdram_toplevel is
30
 
31
  constant clk_per_c             : time    := 10 ns;
32
  constant clk_freq_mhz_c        : integer := 100;
33
  constant num_of_agents_c       : integer := 9;
34
  constant check_rd_data_c       : integer := 0;
35
  constant data_width_c          : integer := 32;
36
  constant addr_width_c          : integer := 32;
37
  constant fifo_depth_c          : integer := 5;
38
  constant tb_arb_type_c         : integer := 2;  -- variable prior
39
 
40
  -- SDRAM
41
  constant mem_addr_width_c    : integer := 22;
42
  constant block_read_length_c : integer := 640;
43
 
44
  -- sdram2hibi
45
  constant comm_width_c         : integer := 3;
46
  constant num_of_read_ports_c  : integer := 2;
47
  constant num_of_write_ports_c : integer := 2;
48
  constant offset_width_c       : integer := 16;
49
  constant rq_fifo_depth_c      : integer := 9;
50
  constant op_arb_type_c        : integer := 1;
51
  constant port_arb_type_c      : integer := 0;
52
  constant blk_rd_prior_c       : integer := 0;
53
  constant blk_wr_prior_c       : integer := 1;
54
  constant single_op_prior_c    : integer := 2;
55
  constant block_overlap_c      : integer := 1;
56
 
57
  type ag_addr_array_type is array (0 to num_of_agents_c - 1) of integer;
58
  constant ag_addr_array : ag_addr_array_type := (
59
    16#10000#, 16#20000#, 16#30000#, 16#40000#, 16#50000#, 16#60000#, 16#70000#, 16#80000#, 16#90000#
60
    );
61
 
62
  component arbiter
63
    generic (
64
      arb_width_g : integer;
65
      arb_type_g  : integer);
66
    port (
67
      clk       : in  std_logic;
68
      rst_n     : in  std_logic;
69
      req_in    : in  std_logic_vector(arb_width_g - 1 downto 0);
70
      hold_in   : in  std_logic_vector(arb_width_g - 1 downto 0);
71
      grant_out : out std_logic_vector(arb_width_g - 1 downto 0));
72
  end component;
73
 
74
  component fifo
75
    generic (
76
      data_width_g : integer := 0;
77
      depth_g      : integer := 0
78
      );
79
    port (
80
      clk       : in  std_logic;
81
      rst_n     : in  std_logic;
82
      data_in   : in  std_logic_vector(data_width_g - 1 downto 0);
83
      we_in     : in  std_logic;
84
      one_p_out : out std_logic;
85
      full_out  : out std_logic;
86
      data_out  : out std_logic_vector(data_width_g - 1 downto 0);
87
      re_in     : in  std_logic;
88
      empty_out : out std_logic;
89
      one_d_out : out std_logic
90
      );
91
  end component;
92
 
93
  component tb_agent
94
    generic (
95
      own_addr_g    : integer;
96
      check_rd_data : integer;
97
      data_width_g  : integer;
98
      addr_width_g  : integer);
99
    port (
100
      clk          : in  std_logic;
101
      rst_n        : in  std_logic;
102
      req_out      : out std_logic;
103
      hold_out     : out std_logic;
104
      grant_in     : in  std_logic;
105
      comm_out     : out std_logic_vector(2 downto 0);
106
      data_out     : out std_logic_vector(data_width_g - 1 downto 0);
107
      addr_out     : out std_logic_vector(addr_width_g - 1 downto 0);
108
      we_out       : out std_logic;
109
      re_out       : out std_logic;
110
      full_in      : in  std_logic;
111
      one_p_in     : in  std_logic;
112
      data_in      : in  std_logic_vector(data_width_g - 1 downto 0);
113
      addr_in      : in  std_logic_vector(data_width_g - 1 downto 0);
114
      empty_in     : in  std_logic;
115
      one_d_in     : in  std_logic;
116
      msg_req_out  : out std_logic;
117
      msg_hold_out : out std_logic;
118
      msg_grant_in : in  std_logic;
119
      msg_full_in  : in  std_logic;
120
      msg_one_p_in : in  std_logic;
121
      msg_data_in  : in  std_logic_vector(data_width_g - 1 downto 0);
122
      msg_addr_in  : in  std_logic_vector(data_width_g - 1 downto 0);
123
      msg_empty_in : in  std_logic;
124
      msg_one_d_in : in  std_logic;
125
      msg_data_out : out std_logic_vector(data_width_g - 1 downto 0);
126
      msg_addr_out : out std_logic_vector(addr_width_g - 1 downto 0);
127
      msg_we_out   : out std_logic;
128
      msg_re_out   : out std_logic);
129
  end component;
130
 
131
  component sdram2hibi
132
    generic (
133
      hibi_data_width_g    : integer;
134
      mem_data_width_g     : integer;
135
      mem_addr_width_g     : integer;
136
      comm_width_g         : integer;
137
      input_fifo_depth_g   : integer;
138
      num_of_read_ports_g  : integer;
139
      num_of_write_ports_g : integer;
140
      offset_width_g       : integer;
141
      rq_fifo_depth_g      : integer;
142
      op_arb_type_g        : integer;
143
      port_arb_type_g      : integer;
144
      blk_rd_prior_g       : integer;
145
      blk_wr_prior_g       : integer;
146
      single_op_prior_g    : integer;
147
      block_overlap_g      : integer);
148
    port (
149
      clk                        : in  std_logic;
150
      rst_n                      : in  std_logic;
151
      hibi_addr_in               : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
152
      hibi_data_in               : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
153
      hibi_comm_in               : in  std_logic_vector(comm_width_g - 1 downto 0);
154
      hibi_empty_in              : in  std_logic;
155
      hibi_re_out                : out std_logic;
156
      hibi_addr_out              : out std_logic_vector(hibi_data_width_g - 1 downto 0);
157
      hibi_data_out              : out std_logic_vector(hibi_data_width_g - 1 downto 0);
158
      hibi_comm_out              : out std_logic_vector(comm_width_g - 1 downto 0);
159
      hibi_full_in               : in  std_logic;
160
      hibi_we_out                : out std_logic;
161
      hibi_msg_addr_in           : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
162
      hibi_msg_data_in           : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
163
      hibi_msg_comm_in           : in  std_logic_vector(comm_width_g - 1 downto 0);
164
      hibi_msg_empty_in          : in  std_logic;
165
      hibi_msg_re_out            : out std_logic;
166
      hibi_msg_data_out          : out std_logic_vector(hibi_data_width_g - 1 downto 0);
167
      hibi_msg_addr_out          : out std_logic_vector(hibi_data_width_g - 1 downto 0);
168
      hibi_msg_comm_out          : out std_logic_vector(comm_width_g - 1 downto 0);
169
      hibi_msg_full_in           : in  std_logic;
170
      hibi_msg_we_out            : out std_logic;
171
      sdram_ctrl_write_on_in     : in  std_logic;
172
      sdram_ctrl_comm_out        : out std_logic_vector(1 downto 0);
173
      sdram_ctrl_addr_out        : out std_logic_vector(21 downto 0);
174
      sdram_ctrl_data_amount_out : out std_logic_vector(mem_addr_width_g - 1
175
                                                        downto 0);
176
      sdram_ctrl_input_one_d_out : out std_logic;
177
      sdram_ctrl_input_empty_out : out std_logic;
178
      sdram_ctrl_output_full_out : out std_logic;
179
      sdram_ctrl_busy_in         : in  std_logic;
180
      sdram_ctrl_re_in           : in  std_logic;
181
      sdram_ctrl_we_in           : in  std_logic;
182
      sdram_ctrl_data_out        : out std_logic_vector(31 downto 0);
183
      sdram_ctrl_data_in         : in  std_logic_vector(31 downto 0);
184
      sdram_ctrl_byte_select_out : out std_logic_vector(3 downto 0));
185
  end component;
186
 
187
  component sdram_controller
188
    generic (
189
      clk_freq_mhz_g      : integer;
190
      mem_addr_width_g    : integer;
191
      block_read_length_g : integer);
192
    port (
193
      clk                    : in    std_logic;
194
      rst_n                  : in    std_logic;
195
      command_in             : in    std_logic_vector(1 downto 0);
196
      address_in             : in    std_logic_vector(21 downto 0);
197
      data_amount_in         : in    std_logic_vector(mem_addr_width_g - 1
198
                                                      downto 0);
199
      byte_select_in         : in    std_logic_vector(3 downto 0);
200
      input_empty_in         : in    std_logic;
201
      input_one_d_in         : in    std_logic;
202
      output_full_in         : in    std_logic;
203
      data_in                : in    std_logic_vector(31 downto 0);
204
      write_on_out           : out   std_logic;
205
      busy_out               : out   std_logic;
206
      output_we_out          : out   std_logic;
207
      input_re_out           : out   std_logic;
208
      data_to_sdram2hibi_out : out   std_logic_vector(31 downto 0);
209
      sdram_data_inout       : inout std_logic_vector(31 downto 0);
210
      sdram_cke_out          : out   std_logic;
211
      sdram_cs_n_out         : out   std_logic;
212
      sdram_we_n_out         : out   std_logic;
213
      sdram_ras_n_out        : out   std_logic;
214
      sdram_cas_n_out        : out   std_logic;
215
      sdram_dqm_out          : out   std_logic_vector(3 downto 0);
216
      sdram_ba_out           : out   std_logic_vector(1 downto 0);
217
      sdram_address_out      : out   std_logic_vector(11 downto 0));
218
  end component;
219
 
220
  component mt48lc4m32b2
221
    generic (
222
      addr_bits : integer;
223
      data_bits : integer;
224
      col_bits  : integer;
225
      mem_sizes : integer);
226
    port (
227
      Dq    : inout std_logic_vector(data_bits - 1 downto 0);
228
      Addr  : in    std_logic_vector(addr_bits - 1 downto 0);
229
      Ba    : in    std_logic_vector(1 downto 0);
230
      Clk   : in    std_logic;
231
      Cke   : in    std_logic;
232
      Cs_n  : in    std_logic;
233
      Ras_n : in    std_logic;
234
      Cas_n : in    std_logic;
235
      We_n  : in    std_logic;
236
      Dqm   : in    std_logic_vector(3 downto 0)
237
      );
238
  end component;
239
 
240
 
241
  signal clk   : std_logic;
242
  signal rst_n : std_logic;
243
 
244
  -- arbiters
245
  signal req       : std_logic_vector(num_of_agents_c - 1 downto 0);
246
  signal grant     : std_logic_vector(num_of_agents_c - 1 downto 0);
247
  signal hold      : std_logic_vector(num_of_agents_c - 1 downto 0);
248
  signal msg_req   : std_logic_vector(num_of_agents_c - 1 downto 0);
249
  signal msg_grant : std_logic_vector(num_of_agents_c - 1 downto 0);
250
  signal msg_hold  : std_logic_vector(num_of_agents_c - 1 downto 0);
251
 
252
  type comm_type_arr is array (num_of_agents_c - 1 downto 0)
253
    of std_logic_vector(2 downto 0);
254
  type data_type_arr is array (num_of_agents_c - 1 downto 0)
255
    of std_logic_vector(data_width_c - 1 downto 0);
256
  type addr_type_arr is array (num_of_agents_c - 1 downto 0)
257
    of std_logic_vector(data_width_c - 1 downto 0);
258
 
259
  -- tb_agents -> dut_input fifo
260
  signal comm_tb_fifo     : comm_type_arr;
261
  signal data_tb_fifo     : data_type_arr;
262
  signal addr_tb_fifo     : addr_type_arr;
263
  signal msg_data_tb_fifo : data_type_arr;
264
  signal msg_addr_tb_fifo : addr_type_arr;
265
  signal we_tb_fifo       : std_logic_vector(num_of_agents_c - 1 downto 0);
266
  signal msg_we_tb_fifo   : std_logic_vector(num_of_agents_c - 1 downto 0);
267
 
268
  -- dut_input fifo -> tb_agents
269
  signal full_inp_fifo      : std_logic;
270
  signal one_p_inp_fifo     : std_logic;
271
  signal msg_full_inp_fifo  : std_logic;
272
  signal msg_one_p_inp_fifo : std_logic;
273
  signal we_inp_fifo        : std_logic;
274
  signal comm_inp_fifo      : std_logic_vector(2 downto 0);
275
  signal data_inp_fifo      : std_logic_vector(data_width_c - 1 downto 0);
276
  signal addr_inp_fifo      : std_logic_vector(addr_width_c - 1 downto 0);
277
  signal msg_we_inp_fifo    : std_logic;
278
  signal msg_data_inp_fifo  : std_logic_vector(data_width_c - 1 downto 0);
279
  signal msg_addr_inp_fifo  : std_logic_vector(addr_width_c - 1 downto 0);
280
  signal full_fifo_tb       : std_logic_vector(num_of_agents_c - 1 downto 0);
281
  signal one_p_fifo_tb      : std_logic_vector(num_of_agents_c - 1 downto 0);
282
  signal msg_full_fifo_tb   : std_logic_vector(num_of_agents_c - 1 downto 0);
283
  signal msg_one_p_fifo_tb  : std_logic_vector(num_of_agents_c - 1 downto 0);
284
 
285
  -- dut_output fifo -> tb_agents
286
  signal data_outp_fifo      : std_logic_vector(data_width_c - 1 downto 0);
287
  signal addr_outp_fifo      : std_logic_vector(addr_width_c - 1 downto 0);
288
  signal re_outp_fifo        : std_logic;
289
  signal empty_outp_fifo     : std_logic;
290
  signal one_d_outp_fifo     : std_logic;
291
  signal msg_data_outp_fifo  : std_logic_vector(data_width_c - 1 downto 0);
292
  signal msg_addr_outp_fifo  : std_logic_vector(addr_width_c - 1 downto 0);
293
  signal msg_re_outp_fifo    : std_logic;
294
  signal msg_empty_outp_fifo : std_logic;
295
  signal msg_one_d_outp_fifo : std_logic;
296
 
297
  signal data_fifo_tb      : data_type_arr;
298
  signal addr_fifo_tb      : addr_type_arr;
299
  signal re_tb_fifo        : std_logic_vector(num_of_agents_c - 1 downto 0);
300
  signal empty_fifo_tb     : std_logic_vector(num_of_agents_c - 1 downto 0);
301
  signal one_d_fifo_tb     : std_logic_vector(num_of_agents_c - 1 downto 0);
302
  signal msg_data_fifo_tb  : data_type_arr;
303
  signal msg_addr_fifo_tb  : addr_type_arr;
304
  signal msg_re_tb_fifo    : std_logic_vector(num_of_agents_c - 1 downto 0);
305
  signal msg_empty_fifo_tb : std_logic_vector(num_of_agents_c - 1 downto 0);
306
  signal msg_one_d_fifo_tb : std_logic_vector(num_of_agents_c - 1 downto 0);
307
 
308
  -- dut_input fifo -> dut
309
  signal empty_fifo_dut     : std_logic;
310
  signal msg_empty_fifo_dut : std_logic;
311
  signal comm_fifo_dut      : std_logic_vector(2 downto 0);
312
  signal data_fifo_dut      : std_logic_vector(data_width_c - 1 downto 0);
313
  signal addr_fifo_dut      : std_logic_vector(addr_width_c - 1 downto 0);
314
  signal msg_data_fifo_dut  : std_logic_vector(data_width_c - 1 downto 0);
315
  signal msg_addr_fifo_dut  : std_logic_vector(addr_width_c - 1 downto 0);
316
 
317
  -- output fifo -> dut
318
  signal full_outp_fifo     : std_logic;
319
  signal msg_full_outp_fifo : std_logic;
320
 
321
  -- dut -> input fifo
322
  signal re_dut_fifo     : std_logic;
323
  signal msg_re_dut_fifo : std_logic;
324
 
325
  -- dut -> output fifo
326
  signal addr_dut_fifo     : std_logic_vector(addr_width_c - 1 downto 0);
327
  signal data_dut_fifo     : std_logic_vector(data_width_c - 1 downto 0);
328
  signal we_dut_fifo       : std_logic;
329
  signal full_fifo_dut     : std_logic;
330
  signal msg_addr_dut_fifo : std_logic_vector(addr_width_c - 1 downto 0);
331
  signal msg_data_dut_fifo : std_logic_vector(data_width_c - 1 downto 0);
332
  signal msg_we_dut_fifo   : std_logic;
333
  signal msg_full_fifo_dut : std_logic;
334
 
335
  -- sdram_ctrl -> dut
336
  signal write_on_sdram_dut : std_logic;
337
  signal busy_sdram_dut     : std_logic;
338
  signal re_sdram_dut       : std_logic;
339
  signal we_sdram_dut       : std_logic;
340
  signal data_sdram_dut     : std_logic_vector(data_width_c - 1 downto 0);
341
 
342
  -- dut -> sdram_ctrl
343
  signal comm_dut_sdram     : std_logic_vector(1 downto 0);
344
  signal addr_dut_sdram     : std_logic_vector(mem_addr_width_c - 1 downto 0);
345
  signal amount_dut_sdram   : std_logic_vector(mem_addr_width_c - 1 downto 0);
346
  signal one_d_dut_sdram    : std_logic;
347
  signal empty_dut_sdram    : std_logic;
348
  signal full_dut_sdram     : std_logic;
349
  signal data_dut_sdram     : std_logic_vector(data_width_c - 1 downto 0);
350
  signal byte_sel_dut_sdram : std_logic_vector(data_width_c/8 - 1 downto 0);
351
 
352
  -- SDRAM controller <-> SDRAM
353
  signal sdram_dq    : std_logic_vector(31 downto 0);
354
  signal sdram_addr  : std_logic_vector(11 downto 0);
355
  signal sdram_ba    : std_logic_vector(1 downto 0);
356
  signal sdram_clk   : std_logic;
357
  signal sdram_cke   : std_logic;
358
  signal sdram_cs_n  : std_logic;
359
  signal sdram_ras_n : std_logic;
360
  signal sdram_cas_n : std_logic;
361
  signal sdram_we_n  : std_logic;
362
  signal sdram_dqm   : std_logic_vector(3 downto 0);
363
 
364
  signal sdram_dq_d    : std_logic_vector(31 downto 0);
365
  signal sdram_addr_d  : std_logic_vector(11 downto 0);
366
  signal sdram_ba_d    : std_logic_vector(1 downto 0);
367
  signal sdram_clk_d   : std_logic;
368
  signal sdram_cke_d   : std_logic;
369
  signal sdram_cs_n_d  : std_logic;
370
  signal sdram_ras_n_d : std_logic;
371
  signal sdram_cas_n_d : std_logic;
372
  signal sdram_we_n_d  : std_logic;
373
  signal sdram_dqm_d   : std_logic_vector(3 downto 0);
374
 
375
begin  -- behavioral
376
 
377
  check_sdram_access: postponed process (we_sdram_dut, comm_dut_sdram,
378
                               addr_dut_sdram, data_dut_sdram,
379
                               data_dut_fifo)
380
  begin  -- process check_sdram_access
381
 
382
    if comm_dut_sdram = "10" then
383
      -- write
384
      assert addr_dut_sdram(19 downto 16) = data_dut_sdram(19 downto 16)
385
        report "SDRAM is getting wrong write parameters"
386
        severity failure;
387
    elsif we_sdram_dut = '1' then
388
      assert data_dut_fifo(19 downto 16) = addr_dut_sdram(19 downto 16)
389
        report "SDRAM is getting wrong read parameters"
390
        severity failure;
391
    end if;
392
 
393
  end process check_sdram_access;
394
 
395
  mux_agents : process (grant, msg_grant,
396
                        we_tb_fifo, msg_we_tb_fifo,
397
                        full_inp_fifo, msg_full_inp_fifo,
398
                        one_p_inp_fifo, msg_one_p_inp_fifo,
399
                        data_tb_fifo, msg_data_tb_fifo,
400
                        addr_tb_fifo, msg_addr_tb_fifo,
401
                        comm_tb_fifo,
402
                        addr_outp_fifo, msg_addr_outp_fifo,
403
                        data_outp_fifo, msg_data_outp_fifo,
404
                        re_tb_fifo, msg_re_tb_fifo,
405
                        empty_outp_fifo, msg_empty_outp_fifo,
406
                        we_inp_fifo, msg_we_inp_fifo,
407
                        re_outp_fifo, msg_re_outp_fifo,
408
                        one_d_outp_fifo, msg_one_d_outp_fifo)
409
 
410
  begin  -- process mux_agents
411
 
412
    -- mux agents to input fifo
413
    we_inp_fifo   <= '0';
414
    data_inp_fifo <= (others => '0');
415
    addr_inp_fifo <= (others => '0');
416
    full_fifo_tb  <= (others => '1');
417
    one_p_fifo_tb <= (others => '0');
418
    comm_inp_fifo <= (others => '0');
419
    for ag_num in num_of_agents_c - 1 downto 0 loop
420
      if grant(ag_num) = '1' then
421
        comm_inp_fifo         <= comm_tb_fifo(ag_num);
422
        we_inp_fifo           <= we_tb_fifo(ag_num);
423
        data_inp_fifo         <= data_tb_fifo(ag_num);
424
        addr_inp_fifo         <= addr_tb_fifo(ag_num);
425
        full_fifo_tb(ag_num)  <= full_inp_fifo and not(one_p_inp_fifo and we_inp_fifo);
426
        one_p_fifo_tb(ag_num) <= one_p_inp_fifo;
427
      end if;
428
    end loop;  -- i
429
 
430
    -- mux agents to input msg fifo
431
    msg_we_inp_fifo   <= '0';
432
    msg_data_inp_fifo <= (others => '0');
433
    msg_addr_inp_fifo <= (others => '0');
434
    msg_full_fifo_tb  <= (others => '1');
435
    msg_one_p_fifo_tb <= (others => '0');
436
    for ag_num in num_of_agents_c - 1 downto 0 loop
437
      if msg_grant(ag_num) = '1' then
438
        msg_we_inp_fifo           <= msg_we_tb_fifo(ag_num);
439
        msg_data_inp_fifo         <= msg_data_tb_fifo(ag_num);
440
        msg_addr_inp_fifo         <= msg_addr_tb_fifo(ag_num);
441
        msg_full_fifo_tb(ag_num)  <= msg_full_inp_fifo and not(msg_one_p_inp_fifo and msg_we_inp_fifo);
442
        msg_one_p_fifo_tb(ag_num) <= msg_one_p_inp_fifo;
443
      end if;
444
    end loop;  -- i
445
 
446
    -- mux output fifo to agents
447
    data_fifo_tb  <= (others => (others => '0'));
448
    addr_fifo_tb  <= (others => (others => '0'));
449
    re_outp_fifo  <= '0';
450
    empty_fifo_tb <= (others => '1');
451
    one_d_fifo_tb <= (others => '0');
452
    for ag_num in num_of_agents_c - 1 downto 0 loop
453
      if to_integer(unsigned(addr_outp_fifo)) = ag_addr_array(ag_num) then
454
        re_outp_fifo          <= re_tb_fifo(ag_num);
455
        data_fifo_tb(ag_num)  <= data_outp_fifo;
456
        addr_fifo_tb(ag_num)  <= addr_outp_fifo;
457
        empty_fifo_tb(ag_num) <= empty_outp_fifo and not(one_d_outp_fifo and re_outp_fifo);
458
        one_d_fifo_tb(ag_num) <= one_d_outp_fifo;
459
      end if;
460
    end loop;  -- i
461
 
462
    -- mux msg output fifo to agents
463
    msg_data_fifo_tb  <= (others => (others => '0'));
464
    msg_addr_fifo_tb  <= (others => (others => '0'));
465
    msg_re_outp_fifo  <= '0';
466
    msg_empty_fifo_tb <= (others => '1');
467
    msg_one_d_fifo_tb <= (others => '0');
468
    for ag_num in num_of_agents_c - 1 downto 0 loop
469
      if to_integer(unsigned(msg_addr_outp_fifo)) = ag_addr_array(ag_num) then
470
        msg_re_outp_fifo          <= msg_re_tb_fifo(ag_num);
471
        msg_data_fifo_tb(ag_num)  <= msg_data_outp_fifo;
472
        msg_addr_fifo_tb(ag_num)  <= msg_addr_outp_fifo;
473
        msg_empty_fifo_tb(ag_num) <= msg_empty_outp_fifo and not(msg_one_d_outp_fifo and msg_re_outp_fifo);
474
        msg_one_d_fifo_tb(ag_num) <= msg_one_d_outp_fifo;
475
      end if;
476
    end loop;  -- i
477
  end process mux_agents;
478
 
479
  gen_clk : process
480
  begin
481
    clk <= '1';
482
    wait for clk_per_c/2;
483
    clk <= '0';
484
    wait for clk_per_c/2;
485
  end process gen_clk;
486
 
487
  gen_rst : process
488
  begin
489
    rst_n <= '0';
490
    wait for 3*clk_per_c;
491
    wait for clk_per_c/3;
492
    rst_n <= '1';
493
    wait;
494
  end process gen_rst;
495
 
496
  arbiter_lo_1 : arbiter
497
    generic map (
498
      arb_width_g => num_of_agents_c,
499
      arb_type_g  => tb_arb_type_c)
500
    port map (
501
      clk       => clk,
502
      rst_n     => rst_n,
503
      req_in    => req,
504
      hold_in   => hold,
505
      grant_out => grant);
506
 
507
  arbiter_hi_1 : arbiter
508
    generic map (
509
      arb_width_g => num_of_agents_c,
510
      arb_type_g  => tb_arb_type_c)
511
    port map (
512
      clk       => clk,
513
      rst_n     => rst_n,
514
      req_in    => msg_req,
515
      hold_in   => msg_hold,
516
      grant_out => msg_grant);
517
 
518
  gen_tb_agents : for i in num_of_agents_c - 1 downto 0 generate
519
    tb_agent_i : tb_agent
520
      generic map (
521
        own_addr_g    => ag_addr_array(i),
522
        check_rd_data => check_rd_data_c,
523
        data_width_g  => data_width_c,
524
        addr_width_g  => addr_width_c)
525
      port map (
526
        clk          => clk,
527
        rst_n        => rst_n,
528
        req_out      => req(i),
529
        hold_out     => hold(i),
530
        grant_in     => grant(i),
531
        comm_out     => comm_tb_fifo(i),
532
        data_out     => data_tb_fifo(i),
533
        addr_out     => addr_tb_fifo(i),
534
        we_out       => we_tb_fifo(i),
535
        re_out       => re_tb_fifo(i),
536
        full_in      => full_fifo_tb(i),
537
        one_p_in     => one_p_fifo_tb(i),
538
        data_in      => data_fifo_tb(i),
539
        addr_in      => addr_fifo_tb(i),
540
        empty_in     => empty_fifo_tb(i),
541
        one_d_in     => one_d_fifo_tb(i),
542
        msg_req_out  => msg_req(i),
543
        msg_hold_out => msg_hold(i),
544
        msg_grant_in => msg_grant(i),
545
        msg_full_in  => msg_full_fifo_tb(i),
546
        msg_one_p_in => msg_one_p_fifo_tb(i),
547
        msg_data_in  => msg_data_fifo_tb(i),
548
        msg_addr_in  => msg_addr_fifo_tb(i),
549
        msg_empty_in => msg_empty_fifo_tb(i),
550
        msg_one_d_in => msg_one_d_fifo_tb(i),
551
        msg_data_out => msg_data_tb_fifo(i),
552
        msg_addr_out => msg_addr_tb_fifo(i),
553
        msg_we_out   => msg_we_tb_fifo(i),
554
        msg_re_out   => msg_re_tb_fifo(i));
555
  end generate gen_tb_agents;
556
 
557
  process (clk, rst_n)
558
  begin  -- process
559
    if rst_n = '0' then                 -- asynchronous reset (active low)
560
      data_sdram_dut <= (others => 'Z');
561
    elsif clk'event and clk = '1' then  -- rising clock edge
562
      data_sdram_dut <= sdram_dq_d;
563
    end if;
564
  end process;
565
 
566
  sdram2hibi_1 : sdram2hibi
567
    generic map (
568
      hibi_data_width_g    => data_width_c,
569
      mem_data_width_g     => data_width_c,
570
      mem_addr_width_g     => mem_addr_width_c,
571
      comm_width_g         => comm_width_c,
572
      input_fifo_depth_g   => fifo_depth_c,
573
      num_of_read_ports_g  => num_of_read_ports_c,
574
      num_of_write_ports_g => num_of_write_ports_c,
575
      offset_width_g       => offset_width_c,
576
      rq_fifo_depth_g      => rq_fifo_depth_c,
577
      op_arb_type_g        => op_arb_type_c,
578
      port_arb_type_g      => port_arb_type_c,
579
      blk_rd_prior_g       => blk_rd_prior_c,
580
      blk_wr_prior_g       => blk_wr_prior_c,
581
      single_op_prior_g    => single_op_prior_c,
582
      block_overlap_g      => block_overlap_c
583
      )
584
    port map (
585
      clk                        => clk,
586
      rst_n                      => rst_n,
587
      hibi_addr_in               => addr_fifo_dut,
588
      hibi_data_in               => data_fifo_dut,
589
      hibi_comm_in               => comm_fifo_dut,
590
      hibi_empty_in              => empty_fifo_dut,
591
      hibi_re_out                => re_dut_fifo,
592
      hibi_addr_out              => addr_dut_fifo,
593
      hibi_data_out              => data_dut_fifo,
594
--      hibi_comm_out              => comm_dut_fifo,
595
      hibi_full_in               => full_outp_fifo,
596
      hibi_we_out                => we_dut_fifo,
597
      hibi_msg_addr_in           => msg_addr_fifo_dut,
598
      hibi_msg_data_in           => msg_data_fifo_dut,
599
      hibi_msg_comm_in           => "000",  --hibi_msg_comm_tb_dut,
600
      hibi_msg_empty_in          => msg_empty_fifo_dut,
601
      hibi_msg_re_out            => msg_re_dut_fifo,
602
      hibi_msg_data_out          => msg_data_dut_fifo,
603
      hibi_msg_addr_out          => msg_addr_dut_fifo,
604
--      hibi_msg_comm_out          => hibi_msg_comm_dut_tb,
605
      hibi_msg_full_in           => msg_full_outp_fifo,
606
      hibi_msg_we_out            => msg_we_dut_fifo,
607
      sdram_ctrl_write_on_in     => write_on_sdram_dut,
608
      sdram_ctrl_comm_out        => comm_dut_sdram,
609
      sdram_ctrl_addr_out        => addr_dut_sdram,
610
      sdram_ctrl_data_amount_out => amount_dut_sdram,
611
      sdram_ctrl_input_one_d_out => one_d_dut_sdram,
612
      sdram_ctrl_input_empty_out => empty_dut_sdram,
613
      sdram_ctrl_output_full_out => full_dut_sdram,
614
      sdram_ctrl_busy_in         => busy_sdram_dut,
615
      sdram_ctrl_re_in           => re_sdram_dut,
616
      sdram_ctrl_we_in           => we_sdram_dut,
617
      sdram_ctrl_data_out        => data_dut_sdram,
618
      sdram_ctrl_data_in         => data_sdram_dut,
619
      sdram_ctrl_byte_select_out => byte_sel_dut_sdram);
620
 
621
  sdram_controller_1 : sdram_controller
622
    generic map (
623
      clk_freq_mhz_g      => clk_freq_mhz_c,
624
      mem_addr_width_g    => mem_addr_width_c,
625
      block_read_length_g => block_read_length_c)
626
    port map (
627
      clk                    => clk,
628
      rst_n                  => rst_n,
629
      command_in             => comm_dut_sdram,
630
      address_in             => addr_dut_sdram,
631
      data_amount_in         => amount_dut_sdram,
632
      byte_select_in         => byte_sel_dut_sdram,
633
      input_empty_in         => empty_dut_sdram,
634
      input_one_d_in         => one_d_dut_sdram,
635
      output_full_in         => full_dut_sdram,
636
      data_in                => data_dut_sdram,
637
      write_on_out           => write_on_sdram_dut,
638
      busy_out               => busy_sdram_dut,
639
      output_we_out          => we_sdram_dut,
640
      input_re_out           => re_sdram_dut,
641
      data_to_sdram2hibi_out => data_sdram_dut,
642
      sdram_data_inout       => sdram_dq,
643
      sdram_cke_out          => sdram_cke,
644
      sdram_cs_n_out         => sdram_cs_n,
645
      sdram_we_n_out         => sdram_we_n,
646
      sdram_ras_n_out        => sdram_ras_n,
647
      sdram_cas_n_out        => sdram_cas_n,
648
      sdram_dqm_out          => sdram_dqm,
649
      sdram_ba_out           => sdram_ba,
650
      sdram_address_out      => sdram_addr
651
      );
652
 
653
  fifo_inp_data : fifo
654
    generic map (
655
      data_width_g => data_width_c,
656
      depth_g      => fifo_depth_c)
657
    port map (
658
      clk       => clk,
659
      rst_n     => rst_n,
660
      data_in   => data_inp_fifo,
661
      we_in     => we_inp_fifo,
662
      one_p_out => one_p_inp_fifo,
663
      full_out  => full_inp_fifo,
664
      data_out  => data_fifo_dut,
665
      re_in     => re_dut_fifo,
666
      empty_out => empty_fifo_dut);
667
--      one_d_out => one_d_out);
668
 
669
  fifo_msg_inp_data : fifo
670
    generic map (
671
      data_width_g => data_width_c,
672
      depth_g      => fifo_depth_c)
673
    port map (
674
      clk       => clk,
675
      rst_n     => rst_n,
676
      data_in   => msg_data_inp_fifo,
677
      we_in     => msg_we_inp_fifo,
678
      one_p_out => msg_one_p_inp_fifo,
679
      full_out  => msg_full_inp_fifo,
680
      data_out  => msg_data_fifo_dut,
681
      re_in     => msg_re_dut_fifo,
682
      empty_out => msg_empty_fifo_dut);
683
--      one_d_out => msg_one_d_out);
684
 
685
  fifo_inp_addr : fifo
686
    generic map (
687
      data_width_g => data_width_c,
688
      depth_g      => fifo_depth_c)
689
    port map (
690
      clk      => clk,
691
      rst_n    => rst_n,
692
      data_in  => addr_inp_fifo,
693
      we_in    => we_inp_fifo,
694
--      one_p_out => one_p_fifo_tb,
695
--      full_out  => full_inp_fifo,
696
      data_out => addr_fifo_dut,
697
      re_in    => re_dut_fifo);
698
--      empty_out => empty_fifo_dut);
699
--      one_d_out => one_d_out);
700
 
701
  fifo_inp_comm : fifo
702
    generic map (
703
      data_width_g => 3,
704
      depth_g      => fifo_depth_c)
705
    port map (
706
      clk      => clk,
707
      rst_n    => rst_n,
708
      data_in  => comm_inp_fifo,
709
      we_in    => we_inp_fifo,
710
--      one_p_out => one_p_fifo_tb,
711
--      full_out  => full_inp_fifo,
712
      data_out => comm_fifo_dut,
713
      re_in    => re_dut_fifo);
714
--      empty_out => empty_fifo_dut);
715
--      one_d_out => one_d_out);
716
 
717
  fifo_msg_inp_addr : fifo
718
    generic map (
719
      data_width_g => data_width_c,
720
      depth_g      => fifo_depth_c)
721
    port map (
722
      clk      => clk,
723
      rst_n    => rst_n,
724
      data_in  => msg_addr_inp_fifo,
725
      we_in    => msg_we_inp_fifo,
726
--      one_p_out => msg_one_p_out,
727
--      full_out  => msg_full_inp_fifo,
728
      data_out => msg_addr_fifo_dut,
729
      re_in    => msg_re_dut_fifo);
730
--      empty_out => msg_empty_fifo_dut,
731
--      one_d_out => msg_one_d_out);
732
 
733
  fifo_outp_data : fifo
734
    generic map (
735
      data_width_g => data_width_c,
736
      depth_g      => fifo_depth_c)
737
    port map (
738
      clk       => clk,
739
      rst_n     => rst_n,
740
      data_in   => data_dut_fifo,
741
      we_in     => we_dut_fifo,
742
--      one_p_out => one_p_outp_fifo,
743
      full_out  => full_outp_fifo,
744
      data_out  => data_outp_fifo,
745
      re_in     => re_outp_fifo,
746
      empty_out => empty_outp_fifo,
747
      one_d_out => one_d_outp_fifo);
748
 
749
  fifo_msg_outp_data : fifo
750
    generic map (
751
      data_width_g => data_width_c,
752
      depth_g      => fifo_depth_c)
753
    port map (
754
      clk       => clk,
755
      rst_n     => rst_n,
756
      data_in   => msg_data_dut_fifo,
757
      we_in     => msg_we_dut_fifo,
758
--      one_p_out => msg_one_p_outp_fifo,
759
      full_out  => msg_full_outp_fifo,
760
      data_out  => msg_data_outp_fifo,
761
      re_in     => msg_re_outp_fifo,
762
      empty_out => msg_empty_outp_fifo,
763
      one_d_out => msg_one_d_outp_fifo);
764
 
765
  fifo_outp_addr : fifo
766
    generic map (
767
      data_width_g => data_width_c,
768
      depth_g      => fifo_depth_c)
769
    port map (
770
      clk      => clk,
771
      rst_n    => rst_n,
772
      data_in  => addr_dut_fifo,
773
      we_in    => we_dut_fifo,
774
--      one_p_out => one_p_dut_fifo,
775
--      full_out  => full_fifo,
776
      data_out => addr_outp_fifo,
777
      re_in    => re_outp_fifo);
778
--      empty_out => empty_fifo_tb);
779
--      one_d_out => one_d_out);
780
 
781
  fifo_msg_outp_addr : fifo
782
    generic map (
783
      data_width_g => data_width_c,
784
      depth_g      => fifo_depth_c)
785
    port map (
786
      clk      => clk,
787
      rst_n    => rst_n,
788
      data_in  => msg_addr_dut_fifo,
789
      we_in    => msg_we_dut_fifo,
790
--      one_p_out => one_p_dut_fifo,
791
--      full_out  => full_fifo,
792
      data_out => msg_addr_outp_fifo,
793
      re_in    => msg_re_outp_fifo);
794
--      empty_out => empty_fifo_tb);
795
--      one_d_out => one_d_out);
796
 
797
 
798
  sdram_dq_d    <= sdram_dq    after 2 ns;
799
  sdram_addr_d  <= sdram_addr  after 2 ns;
800
  sdram_ba_d    <= sdram_ba    after 2 ns;
801
  sdram_cke_d   <= sdram_cke   after 2 ns;
802
  sdram_cs_n_d  <= sdram_cs_n  after 2 ns;
803
  sdram_cas_n_d <= sdram_cas_n after 2 ns;
804
  sdram_ras_n_d <= sdram_ras_n after 2 ns;
805
  sdram_we_n_d  <= sdram_we_n  after 2 ns;
806
  sdram_dqm_d   <= sdram_dqm   after 2 ns;
807
 
808
  mt48lc4m32b2_1 : mt48lc4m32b2
809
    generic map (
810
      addr_bits => 12,
811
      data_bits => 32,
812
      col_bits  => 8,
813
      mem_sizes => 1048575)
814
    port map (
815
      Dq    => sdram_dq_d,
816
      Addr  => sdram_addr_d,
817
      Ba    => sdram_ba_d,
818
      Clk   => clk,
819
      Cke   => sdram_cke_d,
820
      Cs_n  => sdram_cs_n_d,
821
      Ras_n => sdram_ras_n_d,
822
      Cas_n => sdram_cas_n_d,
823
      We_n  => sdram_we_n_d,
824
      Dqm   => sdram_dqm_d);
825
end behavioral;

powered by: WebSVN 2.1.0

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