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/] [vhd/] [sdram_toplevel_de2.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : sdram2hibi and sdram_controller top-level
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : sdram_top.vhd
6
-- Author     : 
7
-- Company    : 
8
-- Created    : 2005-10-13
9
-- Last update: 2012-04-11
10
-- Platform   : 
11
-- Standard   : VHDL'87
12
-------------------------------------------------------------------------------
13
-- Description:
14
-- 
15
-------------------------------------------------------------------------------
16
-- Copyright (c) 2005 
17
-------------------------------------------------------------------------------
18
-- Revisions  :
19
-- Date        Version  Author  Description
20
-- 2005-10-13  1.0      penttin5        Created
21
-- 2012-01-22  1.001    alhonen fixed names.  hibiv3.
22
-------------------------------------------------------------------------------
23
 
24
library ieee;
25
use ieee.std_logic_1164.all;
26
use ieee.std_logic_arith.all;
27
use ieee.std_logic_unsigned.all;
28
 
29
entity sdram_toplevel is
30
 
31
  generic (
32
    own_hibi_base_addr_g : integer := 0;
33
    hibi_data_width_g    : integer := 32;
34
    mem_data_width_g     : integer := 16;
35
    mem_addr_width_g     : integer := 22;
36
    comm_width_g         : integer := 5;
37
    input_fifo_depth_g   : integer := 10;
38
    num_of_read_ports_g  : integer := 4;
39
    num_of_write_ports_g : integer := 4;
40
    offset_width_g       : integer := 16;
41
    rq_fifo_depth_g      : integer := 3;
42
    op_arb_type_g        : integer := 0;  -- 1=fixed prior
43
    port_arb_type_g      : integer := 0;
44
    blk_rd_prior_g       : integer := 0;  -- rd has the highest prior
45
    blk_wr_prior_g       : integer := 1;
46
    single_op_prior_g    : integer := 2;
47
    block_overlap_g      : integer := 0;
48
    clk_freq_mhz_g       : integer := 50;  -- clock frequency in MHz
49
    block_read_length_g  : integer := 30
50
    );
51
 
52
  port (
53
    clk           : in  std_logic;
54
    rst_n         : in  std_logic;
55
    hibi_addr_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
56
    hibi_data_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
57
    hibi_comm_in  : in  std_logic_vector(comm_width_g - 1 downto 0);
58
    hibi_empty_in : in  std_logic;
59
    hibi_re_out   : out std_logic;
60
 
61
    hibi_addr_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
62
    hibi_data_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
63
    hibi_comm_out : out std_logic_vector(comm_width_g - 1 downto 0);
64
    hibi_full_in  : in  std_logic;
65
    hibi_we_out   : out std_logic;      -- this is asynchronous
66
 
67
    hibi_msg_addr_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
68
    hibi_msg_data_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
69
    hibi_msg_comm_in  : in  std_logic_vector(comm_width_g - 1 downto 0);
70
    hibi_msg_empty_in : in  std_logic;
71
    hibi_msg_re_out   : out std_logic;
72
 
73
    hibi_msg_data_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
74
    hibi_msg_addr_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
75
    hibi_msg_comm_out : out std_logic_vector(comm_width_g - 1 downto 0);
76
    hibi_msg_full_in  : in  std_logic;
77
    hibi_msg_we_out   : out std_logic;
78
 
79
    sdram_data_inout  : inout std_logic_vector(15 downto 0);
80
    sdram_cke_out     : out   std_logic;
81
    sdram_cs_n_out    : out   std_logic;
82
    sdram_we_n_out    : out   std_logic;
83
    sdram_ras_n_out   : out   std_logic;
84
    sdram_cas_n_out   : out   std_logic;
85
    sdram_dqm_out     : out   std_logic_vector(1 downto 0);
86
    sdram_ba_out      : out   std_logic_vector(1 downto 0);
87
    sdram_address_out : out   std_logic_vector(11 downto 0)
88
    );
89
 
90
end sdram_toplevel;
91
 
92
architecture structural of sdram_toplevel is
93
 
94
  component sdram2hibi
95
    generic (
96
    own_hibi_base_addr_g : integer := 0;
97
    hibi_data_width_g    : integer := 32;
98
    mem_data_width_g     : integer := 16;
99
    mem_addr_width_g     : integer := 22;
100
    comm_width_g         : integer := 5;
101
    input_fifo_depth_g   : integer := 5;
102
    num_of_read_ports_g  : integer := 4;
103
    num_of_write_ports_g : integer := 4;
104
    offset_width_g       : integer := 16;
105
    rq_fifo_depth_g      : integer := 3;
106
    op_arb_type_g        : integer := 1;  -- fixed prior
107
    port_arb_type_g      : integer := 0;
108
    blk_rd_prior_g       : integer := 0;  -- rd has the highest prior
109
    blk_wr_prior_g       : integer := 1;
110
    single_op_prior_g    : integer := 2;
111
    block_overlap_g      : integer := 0
112
      );
113
 
114
    port (
115
      clk   : in std_logic;
116
      rst_n : in std_logic;
117
 
118
      hibi_addr_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
119
      hibi_data_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
120
      hibi_comm_in  : in  std_logic_vector(comm_width_g - 1 downto 0);
121
      hibi_empty_in : in  std_logic;
122
      hibi_re_out   : out std_logic;
123
 
124
      hibi_addr_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
125
      hibi_data_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
126
      hibi_comm_out : out std_logic_vector(comm_width_g - 1 downto 0);
127
      hibi_full_in  : in  std_logic;
128
      hibi_we_out   : out std_logic;    -- this is asynchronous
129
 
130
      hibi_msg_addr_in  : in  std_logic_vector(hibi_data_width_g - 1
131
                                               downto 0);
132
      hibi_msg_data_in  : in  std_logic_vector(hibi_data_width_g - 1
133
                                               downto 0);
134
      hibi_msg_comm_in  : in  std_logic_vector(comm_width_g - 1 downto 0);
135
      hibi_msg_empty_in : in  std_logic;
136
      hibi_msg_re_out   : out std_logic;
137
 
138
      hibi_msg_data_out : out std_logic_vector(hibi_data_width_g - 1
139
                                               downto 0);
140
      hibi_msg_addr_out : out std_logic_vector(hibi_data_width_g - 1
141
                                               downto 0);
142
      hibi_msg_comm_out : out std_logic_vector(comm_width_g - 1 downto 0);
143
      hibi_msg_full_in  : in  std_logic;
144
      hibi_msg_we_out   : out std_logic;
145
 
146
      sdram_ctrl_write_on_in     : in  std_logic;
147
      sdram_ctrl_comm_out        : out std_logic_vector(1 downto 0);
148
      sdram_ctrl_addr_out        : out std_logic_vector(21 downto 0);
149
      sdram_ctrl_data_amount_out : out std_logic_vector(mem_addr_width_g - 1
150
                                                        downto 0);
151
      sdram_ctrl_input_one_d_out : out std_logic;
152
      sdram_ctrl_input_empty_out : out std_logic;
153
      sdram_ctrl_output_full_out : out std_logic;
154
      sdram_ctrl_busy_in         : in  std_logic;
155
      sdram_ctrl_re_in           : in  std_logic;
156
      sdram_ctrl_we_in           : in  std_logic;
157
 
158
      -- this is asynchronous but it is read to register in sdram_controller
159
      sdram_ctrl_data_out        : out std_logic_vector(mem_data_width_g-1 downto 0);
160
      sdram_ctrl_data_in         : in  std_logic_vector(mem_data_width_g-1 downto 0);
161
      -- byte select is not implemented!!!
162
      sdram_ctrl_byte_select_out : out std_logic_vector(mem_data_width_g/8-1 downto 0)
163
      );
164
 
165
  end component;
166
 
167
  component wra_16sdram_32hibi
168
    generic (
169
      mem_addr_width_g : integer);
170
    port (
171
      clk                       : in  std_logic;
172
      rst_n                     : in  std_logic;
173
      sdram2hibi_write_on_out   : out std_logic;
174
      sdram2hibi_comm_in        : in  std_logic_vector(1 downto 0);
175
      sdram2hibi_addr_in        : in  std_logic_vector(21 downto 0);
176
      sdram2hibi_data_amount_in : in  std_logic_vector(mem_addr_width_g-1 downto 0);
177
      sdram2hibi_input_one_d_in : in  std_logic;
178
      sdram2hibi_input_empty_in : in  std_logic;
179
      sdram2hibi_output_full_in : in  std_logic;
180
      sdram2hibi_busy_out       : out std_logic;
181
      sdram2hibi_re_out         : out std_logic;
182
      sdram2hibi_we_out         : out std_logic;
183
      sdram2hibi_data_in        : in  std_logic_vector(31 downto 0);
184
      sdram2hibi_data_out       : out std_logic_vector(31 downto 0);
185
      ctrl_command_out          : out std_logic_vector(1 downto 0);
186
      ctrl_address_out          : out std_logic_vector(21 downto 0);
187
      ctrl_data_amount_out      : out std_logic_vector(mem_addr_width_g-1 downto 0);
188
      ctrl_byte_select_out      : out std_logic_vector(1 downto 0);
189
      ctrl_input_empty_out      : out std_logic;
190
      ctrl_input_one_d_out      : out std_logic;
191
      ctrl_output_full_out      : out std_logic;
192
      ctrl_data_out             : out std_logic_vector(15 downto 0);
193
      ctrl_write_on_in          : in  std_logic;
194
      ctrl_busy_in              : in  std_logic;
195
      ctrl_output_we_in         : in  std_logic;
196
      ctrl_input_re_in          : in  std_logic;
197
      ctrl_data_in              : in  std_logic_vector(15 downto 0));
198
  end component;
199
 
200
  signal   ctrl_command_out          :  std_logic_vector(1 downto 0);
201
  signal   ctrl_address_out          :  std_logic_vector(21 downto 0);
202
  signal   ctrl_data_amount_out      :  std_logic_vector(mem_addr_width_g-1 downto 0);
203
  signal   ctrl_byte_select_out      :  std_logic_vector(1 downto 0);
204
  signal   ctrl_input_empty_out      :  std_logic;
205
  signal   ctrl_input_one_d_out      :  std_logic;
206
  signal   ctrl_output_full_out      :  std_logic;
207
  signal   ctrl_data_out             :  std_logic_vector(15 downto 0);
208
  signal   ctrl_write_on_in          :  std_logic;
209
  signal   ctrl_busy_in              :  std_logic;
210
  signal   ctrl_output_we_in         :  std_logic;
211
  signal   ctrl_input_re_in          :  std_logic;
212
  signal   ctrl_data_in              :  std_logic_vector(15 downto 0);
213
 
214
 
215
  component sdram_controller
216
    generic (
217
      clk_freq_mhz_g      : integer := 143;  -- clock frequency in MHz
218
      mem_addr_width_g    : integer := 22;
219
      block_read_length_g : integer := 10
220
      );
221
 
222
    port (
223
      clk   : in std_logic;
224
      rst_n : in std_logic;
225
 
226
      command_in             : in    std_logic_vector(1 downto 0);
227
      address_in             : in    std_logic_vector(21 downto 0);
228
      data_amount_in         : in    std_logic_vector(mem_addr_width_g - 1
229
                                                      downto 0);
230
      byte_select_in         : in    std_logic_vector(1 downto 0);
231
      input_empty_in         : in    std_logic;
232
      input_one_d_in         : in    std_logic;
233
      output_full_in         : in    std_logic;
234
      data_in                : in    std_logic_vector(15 downto 0);
235
      write_on_out           : out   std_logic;
236
      busy_out               : out   std_logic;
237
      output_we_out          : out   std_logic;  -- this is asynchronous
238
      input_re_out           : out   std_logic;
239
      data_out               : out   std_logic_vector(15 downto 0);
240
      sdram_data_inout       : inout std_logic_vector(15 downto 0);
241
      sdram_cke_out          : out   std_logic;
242
      sdram_cs_n_out         : out   std_logic;
243
      sdram_we_n_out         : out   std_logic;
244
      sdram_ras_n_out        : out   std_logic;
245
      sdram_cas_n_out        : out   std_logic;
246
      sdram_dqm_out          : out   std_logic_vector(1 downto 0);
247
      sdram_ba_out           : out   std_logic_vector(1 downto 0);
248
      sdram_address_out      : out   std_logic_vector(11 downto 0)
249
      );
250
  end component;
251
 
252
  signal write_on_ctrl_sdram2hibi : std_logic;
253
  signal comm_sdram2hibi_ctrl : std_logic_vector(1 downto 0);
254
  signal addr_sdram2hibi_ctrl : std_logic_vector(21 downto 0);
255
  signal amount_sdram2hibi_ctrl : std_logic_vector(mem_addr_width_g - 1
256
                                                   downto 0);
257
  signal one_d_sdram2hibi_ctrl       : std_logic;
258
  signal empty_sdram2hibi_ctrl       : std_logic;
259
  signal full_sdram2hibi_ctrl        : std_logic;
260
  signal busy_ctrl_sdram2hibi        : std_logic;
261
  signal re_ctrl_sdram2hibi          : std_logic;
262
  signal we_ctrl_sdram2hibi          : std_logic;
263
  signal data_sdram2hibi_ctrl        : std_logic_vector(31 downto 0);
264
  signal data_ctrl_sdram2hibi        : std_logic_vector(31 downto 0);
265
  signal byte_select_sdram2hibi_ctrl : std_logic_vector(3 downto 0);
266
 
267
begin  -- structural
268
 
269
    -- The sdram2hibi needs to know its own base hibi address.
270
  assert own_hibi_base_addr_g /= 0 report "Please set own_hibi_base_addr_g" severity failure;
271
 
272
  sdram2hibi_1 : sdram2hibi
273
    generic map (
274
      own_hibi_base_addr_g => own_hibi_base_addr_g,
275
      hibi_data_width_g    => hibi_data_width_g,
276
      mem_data_width_g     => 32,
277
      mem_addr_width_g     => mem_addr_width_g,
278
      comm_width_g         => comm_width_g,
279
      input_fifo_depth_g   => input_fifo_depth_g,
280
      num_of_read_ports_g  => num_of_read_ports_g,
281
      num_of_write_ports_g => num_of_write_ports_g,
282
      offset_width_g       => offset_width_g,
283
      rq_fifo_depth_g      => rq_fifo_depth_g,
284
      op_arb_type_g        => op_arb_type_g,
285
      port_arb_type_g      => port_arb_type_g,
286
      blk_rd_prior_g       => blk_rd_prior_g,
287
      blk_wr_prior_g       => blk_wr_prior_g,
288
      single_op_prior_g    => single_op_prior_g,
289
      block_overlap_g      => block_overlap_g
290
      )
291
    port map (
292
      clk           => clk,
293
      rst_n         => rst_n,
294
      hibi_addr_in  => hibi_addr_in,
295
      hibi_data_in  => hibi_data_in,
296
      hibi_comm_in  => hibi_comm_in,
297
      hibi_empty_in => hibi_empty_in,
298
      hibi_re_out   => hibi_re_out,
299
 
300
      hibi_addr_out => hibi_addr_out,
301
      hibi_data_out => hibi_data_out,
302
      hibi_comm_out => hibi_comm_out,
303
      hibi_full_in  => hibi_full_in,
304
      hibi_we_out   => hibi_we_out,
305
 
306
      hibi_msg_addr_in  => hibi_msg_addr_in,
307
      hibi_msg_data_in  => hibi_msg_data_in,
308
      hibi_msg_comm_in  => hibi_msg_comm_in,
309
      hibi_msg_empty_in => hibi_msg_empty_in,
310
      hibi_msg_re_out   => hibi_msg_re_out,
311
 
312
      hibi_msg_data_out => hibi_msg_data_out,
313
      hibi_msg_addr_out => hibi_msg_addr_out,
314
      hibi_msg_comm_out => hibi_msg_comm_out,
315
      hibi_msg_full_in  => hibi_msg_full_in,
316
      hibi_msg_we_out   => hibi_msg_we_out,
317
 
318
      sdram_ctrl_write_on_in     => write_on_ctrl_sdram2hibi,
319
      sdram_ctrl_comm_out        => comm_sdram2hibi_ctrl,
320
      sdram_ctrl_addr_out        => addr_sdram2hibi_ctrl,
321
      sdram_ctrl_data_amount_out => amount_sdram2hibi_ctrl,
322
      sdram_ctrl_input_one_d_out => one_d_sdram2hibi_ctrl,
323
      sdram_ctrl_input_empty_out => empty_sdram2hibi_ctrl,
324
      sdram_ctrl_output_full_out => full_sdram2hibi_ctrl,
325
      sdram_ctrl_busy_in         => busy_ctrl_sdram2hibi,
326
      sdram_ctrl_re_in           => re_ctrl_sdram2hibi,
327
      sdram_ctrl_we_in           => we_ctrl_sdram2hibi,
328
      sdram_ctrl_data_out        => data_sdram2hibi_ctrl,
329
      sdram_ctrl_data_in         => data_ctrl_sdram2hibi,
330
 
331
      --not implemented!!!
332
      sdram_ctrl_byte_select_out => byte_select_sdram2hibi_ctrl
333
      );
334
 
335
  wra_16sdram_32hibi_1: wra_16sdram_32hibi
336
    generic map (
337
      mem_addr_width_g => mem_addr_width_g)
338
    port map (
339
      clk                       => clk,
340
      rst_n                     => rst_n,
341
      sdram2hibi_write_on_out   => write_on_ctrl_sdram2hibi,
342
      sdram2hibi_comm_in        => comm_sdram2hibi_ctrl,
343
      sdram2hibi_addr_in        => addr_sdram2hibi_ctrl,
344
      sdram2hibi_data_amount_in => amount_sdram2hibi_ctrl,
345
      sdram2hibi_input_one_d_in => one_d_sdram2hibi_ctrl,
346
      sdram2hibi_input_empty_in => empty_sdram2hibi_ctrl,
347
      sdram2hibi_output_full_in => full_sdram2hibi_ctrl,
348
      sdram2hibi_busy_out       => busy_ctrl_sdram2hibi,
349
      sdram2hibi_re_out         => re_ctrl_sdram2hibi,
350
      sdram2hibi_we_out         => we_ctrl_sdram2hibi,
351
      sdram2hibi_data_in        => data_sdram2hibi_ctrl,
352
      sdram2hibi_data_out       => data_ctrl_sdram2hibi,
353
      ctrl_command_out          => ctrl_command_out,
354
      ctrl_address_out          => ctrl_address_out,
355
      ctrl_data_amount_out      => ctrl_data_amount_out,
356
      ctrl_byte_select_out      => ctrl_byte_select_out,
357
      ctrl_input_empty_out      => ctrl_input_empty_out,
358
      ctrl_input_one_d_out      => ctrl_input_one_d_out,
359
      ctrl_output_full_out      => ctrl_output_full_out,
360
      ctrl_data_out             => ctrl_data_out,
361
      ctrl_write_on_in          => ctrl_write_on_in,
362
      ctrl_busy_in              => ctrl_busy_in,
363
      ctrl_output_we_in         => ctrl_output_we_in,
364
      ctrl_input_re_in          => ctrl_input_re_in,
365
      ctrl_data_in              => ctrl_data_in);
366
 
367
 
368
  sdram_controller_1 : sdram_controller
369
    generic map (
370
      clk_freq_mhz_g      => clk_freq_mhz_g,
371
      mem_addr_width_g    => mem_addr_width_g,
372
      block_read_length_g => block_read_length_g
373
      )
374
    port map (
375
      clk                    => clk,
376
      rst_n                  => rst_n,
377
      command_in             => ctrl_command_out,
378
      address_in             => ctrl_address_out,
379
      data_amount_in         => ctrl_data_amount_out,
380
      byte_select_in         => ctrl_byte_select_out,
381
      input_empty_in         => ctrl_input_empty_out,
382
      input_one_d_in         => ctrl_input_one_d_out,
383
      output_full_in         => ctrl_output_full_out,
384
      data_in                => ctrl_data_out,
385
      write_on_out           => ctrl_write_on_in,
386
      busy_out               => ctrl_busy_in,
387
      output_we_out          => ctrl_output_we_in,
388
      input_re_out           => ctrl_input_re_in,
389
      data_out               => ctrl_data_in,
390
      sdram_data_inout       => sdram_data_inout,
391
      sdram_cke_out          => sdram_cke_out,
392
      sdram_cs_n_out         => sdram_cs_n_out,
393
      sdram_we_n_out         => sdram_we_n_out,
394
      sdram_ras_n_out        => sdram_ras_n_out,
395
      sdram_cas_n_out        => sdram_cas_n_out,
396
      sdram_dqm_out          => sdram_dqm_out,
397
      sdram_ba_out           => sdram_ba_out,
398
      sdram_address_out      => sdram_address_out
399
      );
400
 
401
end structural;

powered by: WebSVN 2.1.0

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