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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : sdram2hibiv8
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : sdram2hibiv8.vhd
6
-- Author     : 
7
-- Company    : 
8
-- Created    : 2005-07-05
9
-- Last update: 2012-04-11
10
-- Platform   : 
11
-- Standard   : VHDL'87
12
-------------------------------------------------------------------------------
13
-- Description:
14
--              doesn't change read port until read is finshed.
15
--              Read/write overlap blocking.
16
--
17
--              rq_fifo_depth > 0 - blocking requests
18
--                            = 0 - non-blocking requests
19
--
20
--              Arbitter types as in Dally&Towles: Principles and Practices
21
--              of Interconnection Networks p.352-355
22
--              x_arb_type 0 - round robin
23
--                         1 - fixed priority
24
--                         2 - variable priority
25
--
26
--              x_prior_g  0 - highest
27
--
28
--              block_overlap_g 0 - checks only if the first row overlaps
29
--                              1 - checks whole block for overlap
30
--
31
-------------------------------------------------------------------------------
32
-- Copyright (c) 2005 
33
-------------------------------------------------------------------------------
34
-- Revisions  :
35
-- Date        Version  Author          Description
36
-- 2005-07-05  1.0      penttin5        Created
37
--             1.1      penttin5        Non-blocking when rq_fifo_depth_g = 0
38
--                                      Blocking when rq_fifo_depth_g > 0
39
--             1.2      penttin5        Rewrote major parts of VHDL
40
-- 28.06.2007           penttin5        in-order reads
41
-- 2012-01-27  1.3      alhonena        hibiv3
42
-- 2012-03-24  1.4      alhonena        This was completely broken. It freezed
43
--                                      in a very peculiar way if the hibi base
44
--                                      address was any smaller than 22 bits.
45
--                                      A completely undocumented feature.
46
--                                      Instead of just documenting this
47
--                                      unwanted feature, I fixed it.
48
--                                      However, please test thoroughly,
49
--                                      especially if you use single ops.
50
--                                      Now, the single op address is calculated
51
--                                      by subtracting the hibi base addr from
52
--                                      hibi addr. For this reason, I have added
53
--                                      own_hibi_base_addr_g which must be correct.
54
--                                      Of course, if you want to use single ops
55
--                                      AND access as much memory space as
56
--                                      possible, you still need 22-bit hibi
57
--                                      address space.
58
--                                      TODO: Fix the "single op" specification
59
--                                      and implementation: now the first few
60
--                                      bytes of memory cannot be accessed by
61
--                                      using "single op"s.
62
-------------------------------------------------------------------------------
63
 
64
library ieee;
65
use ieee.std_logic_1164.all;
66
use ieee.numeric_std.all;
67
 
68
library work;
69
use work.hibiv3_pkg.all;
70
 
71
entity sdram2hibi is
72
 
73
  generic (
74
    own_hibi_base_addr_g : integer := 0;
75
    hibi_data_width_g    : integer := 32;
76
    mem_data_width_g     : integer := 32;
77
    mem_addr_width_g     : integer := 22;
78
    comm_width_g         : integer := 3;
79
    input_fifo_depth_g   : integer := 5;
80
    num_of_read_ports_g  : integer := 4;
81
    num_of_write_ports_g : integer := 4;
82
    offset_width_g       : integer := 16;
83
    rq_fifo_depth_g      : integer := 0;
84
    op_arb_type_g        : integer := 1;  -- fixed prior
85
    port_arb_type_g      : integer := 0;
86
    blk_rd_prior_g       : integer := 0;  -- rd has the highest prior
87
    blk_wr_prior_g       : integer := 1;
88
    single_op_prior_g    : integer := 2;
89
    amountw_g            : integer := 22;
90
    block_overlap_g      : integer := 0
91
    );
92
 
93
  port (
94
    clk   : in std_logic;
95
    rst_n : in std_logic;
96
 
97
    hibi_addr_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
98
    hibi_data_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
99
    hibi_comm_in  : in  std_logic_vector(comm_width_g - 1 downto 0);
100
    hibi_empty_in : in  std_logic;
101
    hibi_re_out   : out std_logic;
102
 
103
    hibi_addr_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
104
    hibi_data_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
105
    hibi_comm_out : out std_logic_vector(comm_width_g - 1 downto 0);
106
    hibi_full_in  : in  std_logic;
107
    hibi_we_out   : out std_logic;      -- this is asynchronous
108
 
109
    hibi_msg_addr_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
110
    hibi_msg_data_in  : in  std_logic_vector(hibi_data_width_g - 1 downto 0);
111
    hibi_msg_comm_in  : in  std_logic_vector(comm_width_g - 1 downto 0);
112
    hibi_msg_empty_in : in  std_logic;
113
    hibi_msg_re_out   : out std_logic;
114
 
115
    hibi_msg_data_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
116
    hibi_msg_addr_out : out std_logic_vector(hibi_data_width_g - 1 downto 0);
117
    hibi_msg_comm_out : out std_logic_vector(comm_width_g - 1 downto 0);
118
    hibi_msg_full_in  : in  std_logic;
119
    hibi_msg_we_out   : out std_logic;
120
 
121
    sdram_ctrl_write_on_in     : in  std_logic;
122
    sdram_ctrl_comm_out        : out std_logic_vector(1 downto 0);
123
    sdram_ctrl_addr_out        : out std_logic_vector(21 downto 0);
124
    sdram_ctrl_data_amount_out : out std_logic_vector(mem_addr_width_g - 1
125
                                                      downto 0);
126
    sdram_ctrl_input_one_d_out : out std_logic;
127
    sdram_ctrl_input_empty_out : out std_logic;
128
    sdram_ctrl_output_full_out : out std_logic;
129
    sdram_ctrl_busy_in         : in  std_logic;
130
    sdram_ctrl_re_in           : in  std_logic;
131
    sdram_ctrl_we_in           : in  std_logic;
132
 
133
    -- this is asynchronous but it is read to register in sdram_controller
134
    sdram_ctrl_data_out        : out std_logic_vector(31 downto 0);
135
    sdram_ctrl_data_in         : in  std_logic_vector(31 downto 0);
136
    -- byte select is not implemented!!!
137
    sdram_ctrl_byte_select_out : out std_logic_vector(3 downto 0)
138
    );
139
 
140
end sdram2hibi;
141
 
142
architecture rtl of sdram2hibi is
143
 
144
  function maximum (L : integer; R : integer) return integer is
145
  begin
146
    if L > R then
147
      return L;
148
    else
149
      return R;
150
    end if;
151
  end;
152
 
153
  function log2_ceil(N : natural) return positive is
154
  begin
155
    if N < 2 then
156
      return 1;
157
    else
158
      return 1 + log2_ceil(N/2);
159
    end if;
160
  end;
161
 
162
  component sdram_wr_port
163
    generic (
164
      fifo_depth_g    : integer;
165
      amountw_g       : integer;
166
      hibi_dataw_g    : integer;
167
      block_overlap_g : integer;
168
      offsetw_g       : integer;
169
      mem_dataw_g     : integer;
170
      mem_addrw_g     : integer);
171
    port (
172
      clk            : in  std_logic;
173
      rst_n          : in  std_logic;
174
      conf_we_in     : in  std_logic;
175
      conf_data_in   : in  std_logic_vector(hibi_dataw_g - 1 downto 0);
176
      write_in       : in  std_logic;
177
      reserve_in     : in  std_logic;
178
      valid_out      : out std_logic;
179
      reserved_out   : out std_logic;
180
      end_addr_out   : out std_logic_vector(mem_addrw_g - 1 downto 0);
181
      dst_addr_out   : out std_logic_vector(mem_addrw_g - 1 downto 0);
182
      amount_out     : out std_logic_vector(amountw_g - 1 downto 0);
183
      fifo_we_in     : in  std_logic;
184
      fifo_re_in     : in  std_logic;
185
      fifo_data_in   : in  std_logic_vector(hibi_dataw_g - 1 downto 0);
186
      fifo_full_out  : out std_logic;
187
      fifo_empty_out : out std_logic;
188
      fifo_one_p_out : out std_logic;
189
      fifo_one_d_out : out std_logic;
190
      fifo_data_out  : out std_logic_vector(hibi_dataw_g - 1 downto 0);
191
      error_out      : out std_logic);
192
  end component;
193
 
194
  component sdram_rd_port
195
    generic (
196
      amountw_g       : integer;
197
      hibi_dataw_g    : integer;
198
      block_overlap_g : integer;
199
      offsetw_g       : integer;
200
      mem_dataw_g     : integer;
201
      mem_addrw_g     : integer);
202
    port (
203
      clk          : in  std_logic;
204
      rst_n        : in  std_logic;
205
      conf_we_in   : in  std_logic;
206
      conf_data_in : in  std_logic_vector(hibi_dataw_g - 1 downto 0);
207
      read_in      : in  std_logic;
208
      reserve_in   : in  std_logic;
209
      valid_out    : out std_logic;
210
      reserved_out : out std_logic;
211
      end_addr_out : out std_logic_vector(mem_addrw_g - 1 downto 0);
212
      src_addr_out : out std_logic_vector(mem_addrw_g - 1 downto 0);
213
      amount_out   : out std_logic_vector(amountw_g - 1 downto 0);
214
      ret_addr_out : out std_logic_vector(hibi_dataw_g - 1 downto 0);
215
      finish_out   : out std_logic;
216
      error_out    : out std_logic);
217
  end component;
218
 
219
  component fifo
220
 
221
    generic (
222
      data_width_g : integer := 0;
223
      depth_g      : integer := 0
224
      );
225
 
226
    port (
227
      clk       : in  std_logic;
228
      rst_n     : in  std_logic;
229
      data_in   : in  std_logic_vector(data_width_g - 1 downto 0);
230
      we_in     : in  std_logic;
231
      one_p_out : out std_logic;
232
      full_out  : out std_logic;
233
      data_out  : out std_logic_vector(data_width_g - 1 downto 0);
234
      re_in     : in  std_logic;
235
      empty_out : out std_logic;
236
      one_d_out : out std_logic
237
      );
238
  end component;
239
 
240
  component sdram_arbiter
241
 
242
    generic (
243
      arb_width_g : integer;
244
      arb_type_g  : integer := 0
245
      );
246
    port(
247
      clk       : in  std_logic;
248
      rst_n     : in  std_logic;
249
      req_in    : in  std_logic_vector(arb_width_g - 1 downto 0);
250
      hold_in   : in  std_logic_vector(arb_width_g - 1 downto 0);
251
      grant_out : out std_logic_vector(arb_width_g - 1 downto 0)
252
      );
253
  end component;
254
 
255
  -- How many bits do we need to compare on hibi_msg_addr_in
256
  -- to detect port request or config?
257
  -- (addrs 0 and 1 for port requests
258
  --  addrs 2...2+num_of_read_ports_g-1 for read port configs,
259
  --  addrs 2+num_of_read_ports_g...2+num_of_read_ports_g+num_of_write_ports_g-1
260
  --        for write port configs
261
  -- So num of bits is log2(2 + num_of_read_ports_g + num_of_write_ports_g)
262
  constant msg_addr_compw_c : integer
263
    := log2_ceil(2 + num_of_read_ports_g + num_of_write_ports_g);
264
 
265
  signal sdram_write : std_logic_vector(num_of_write_ports_g - 1 downto 0);
266
  signal sdram_read  : std_logic_vector(num_of_read_ports_g - 1 downto 0);
267
 
268
  -- state machine for process from_ports_to_controller
269
  type state_vector_type is (idle, wait_for_block_read_start,
270
                             wait_for_block_write_start,
271
                             wait_for_single_op_start);
272
  signal state_r : state_vector_type;
273
 
274
  signal conf_rd_r : std_logic_vector(num_of_read_ports_g - 1 downto 0);
275
  signal conf_wr_r : std_logic_vector(num_of_write_ports_g - 1 downto 0);
276
 
277
  -- Rq and conf detection signals
278
  signal rd_port_rq   : std_logic;
279
  signal wr_port_rq   : std_logic;
280
  signal rd_port_conf : std_logic;
281
  signal wr_port_conf : std_logic;
282
 
283
  -- Types definitions for write port signals
284
  type w_mem_addr_arr is array (num_of_write_ports_g - 1 downto 0)
285
    of std_logic_vector(mem_addr_width_g - 1 downto 0);
286
 
287
  type w_data_arr is array (num_of_write_ports_g downto 0)
288
    of std_logic_vector(hibi_data_width_g - 1 downto 0);
289
 
290
  type w_amount_arr is array (num_of_write_ports_g - 1 downto 0)
291
    of std_logic_vector(amountw_g - 1 downto 0);
292
 
293
  type w_end_addr_arr is array (num_of_write_ports_g - 1 downto 0)
294
    of std_logic_vector(mem_addr_width_g - 1 downto 0);
295
 
296
  -- Write port signals
297
  signal w_reserve    : std_logic_vector(num_of_write_ports_g - 1 downto 0);
298
  signal w_reserved_r : std_logic_vector(num_of_write_ports_g - 1 downto 0);
299
  signal w_valid_r    : std_logic_vector(num_of_write_ports_g - 1 downto 0);
300
  signal w_dst_addr_r : w_mem_addr_arr;
301
  signal w_amount_r   : w_amount_arr;
302
  signal w_we_r       : std_logic_vector(num_of_write_ports_g - 1 downto 0);
303
  signal w_re_r       : std_logic_vector(num_of_write_ports_g - 1 downto 0);
304
  signal w_empty      : std_logic_vector(num_of_write_ports_g downto 0);
305
  signal w_full       : std_logic_vector(num_of_write_ports_g - 1 downto 0);
306
  signal w_one_p_left : std_logic_vector(num_of_write_ports_g - 1 downto 0);
307
  signal w_one_d_left : std_logic_vector(num_of_write_ports_g downto 0);
308
  signal w_data_out   : w_data_arr;
309
  signal w_end_addr_r : w_end_addr_arr;
310
 
311
  -- Read port signal type definitions
312
  type r_mem_addr_arr is array (num_of_read_ports_g - 1 downto 0)
313
    of std_logic_vector(mem_addr_width_g - 1 downto 0);
314
  type r_amount_arr is array (num_of_read_ports_g - 1 downto 0)
315
    of std_logic_vector(amountw_g - 1 downto 0);
316
  type r_data_arr is array (num_of_read_ports_g - 1 downto 0)
317
    of std_logic_vector(hibi_data_width_g - 1 downto 0);
318
  type r_overlap_vec_arr is array (num_of_read_ports_g - 1 downto 0)
319
    of std_logic_vector(num_of_write_ports_g - 1 downto 0);
320
 
321
  -- Read port signals
322
  signal r_reserved_r    : std_logic_vector(num_of_read_ports_g - 1 downto 0);
323
  signal r_end_addr_r    : r_mem_addr_arr;
324
  signal r_valid_r       : std_logic_vector(num_of_read_ports_g - 1 downto 0);
325
  signal r_src_addr_r    : r_mem_addr_arr;
326
  signal r_amount_r      : r_amount_arr;
327
  signal r_ret_addr_r    : r_data_arr;
328
  signal r_overlap_vec_r : r_overlap_vec_arr;
329
  signal r_overlap       : std_logic_vector(num_of_read_ports_g - 1 downto 0);
330
  signal r_reserve       : std_logic_vector(num_of_read_ports_g - 1 downto 0);
331
  signal r_finish_r      : std_logic_vector(num_of_read_ports_g - 1 downto 0);
332
 
333
  -- 21.05.07 HP
334
  signal data_to_fifos_r : std_logic_vector(hibi_data_width_g - 1 downto 0);
335
  signal prev_r_valid_r  : std_logic_vector(num_of_read_ports_g - 1 downto 0);
336
  signal conf_data_r     : std_logic_vector(hibi_data_width_g - 1 downto 0);
337
 
338
  -- Arbiter signals
339
  signal next_op             : std_logic_vector(2 downto 0);
340
  signal next_op_req         : std_logic_vector(2 downto 0);
341
  signal next_op_hold        : std_logic_vector(2 downto 0);
342
  signal r_port_req          : std_logic_vector(num_of_read_ports_g - 1 downto 0);
343
  signal r_port_hold         : std_logic_vector(num_of_read_ports_g - 1 downto 0);
344
  signal w_port_req          : std_logic_vector(num_of_write_ports_g - 1 downto 0);
345
  signal w_port_hold         : std_logic_vector(num_of_write_ports_g - 1 downto 0);
346
  signal next_rd_port        : std_logic_vector(num_of_read_ports_g - 1 downto 0);
347
  signal next_wr_port        : std_logic_vector(num_of_write_ports_g - 1 downto 0);
348
  signal rd_hold_mask        : std_logic;
349
  signal wr_hold_mask        : std_logic;
350
  signal single_op_hold_mask : std_logic;
351
 
352
  -- 17.10.06 HP
353
 
354
  signal free_r_port   : std_logic;
355
  signal free_w_port   : std_logic;
356
  signal free_r_num_r    : integer range num_of_read_ports_g - 1 downto 0;
357
  signal free_w_num    : integer range num_of_write_ports_g - 1 downto 0;
358
  signal free_r_offset : integer
359
    range 2 + num_of_read_ports_g - 1 downto 0;
360
  signal free_w_offset : integer
361
    range 2 + num_of_read_ports_g + num_of_write_ports_g - 1 downto 0;
362
 
363
  -- signals for single operations port
364
  signal single_op_in : std_logic_vector(2 + 2*(hibi_data_width_g) - 1
365
                                         downto 0);
366
  signal single_op_comm_in_r : std_logic_vector(1 downto 0);
367
  signal single_op_addr_in_r : std_logic_vector(hibi_data_width_g - 1
368
                                                downto 0);
369
  signal single_op_ret_addr_out : std_logic_vector(hibi_data_width_g - 1 downto 0);
370
  signal single_op_we_r         : std_logic;
371
  signal single_op_re_r         : std_logic;
372
  signal single_op_empty        : std_logic;
373
  signal single_op_full         : std_logic;
374
  signal single_op_out : std_logic_vector(2 + 2*(hibi_data_width_g) - 1
375
                                          downto 0);
376
  signal single_op_data_out_r : std_logic_vector(31 downto 0);
377
  signal single_op_one_p_left : std_logic;
378
  signal single_op_one_d_left : std_logic;
379
  signal single_op_comm_out   : std_logic_vector(1 downto 0);
380
  signal single_op_addr_out : std_logic_vector(mem_addr_width_g - 1
381
                                               downto 0);
382
  signal single_op_data_out : std_logic_vector(31 downto 0);
383
  signal single_op_on_r     : std_logic;
384
 
385
  signal curr_wr_port_r : integer range num_of_write_ports_g downto 0;
386
  signal curr_rd_port_r : integer range num_of_read_ports_g - 1 downto 0;
387
 
388
  signal hibi_msg_we_r   : std_logic;
389
  signal hibi_msg_data_r : std_logic_vector(hibi_data_width_g - 1 downto 0);
390
  signal hibi_msg_addr_r : std_logic_vector(hibi_data_width_g - 1 downto 0);
391
 
392
  -- Read request fifo signals
393
  signal rd_rq_in_r  : std_logic_vector(hibi_data_width_g - 1 downto 0);
394
  signal rd_rq_we_r  : std_logic;
395
  signal rd_rq_full  : std_logic;
396
  signal rd_rq       : std_logic_vector(hibi_data_width_g - 1 downto 0);
397
  signal rd_rq_re    : std_logic;
398
  signal rd_rq_empty : std_logic;
399
 
400
  -- Write request fifo signals
401
  signal wr_rq_in_r  : std_logic_vector(hibi_data_width_g - 1 downto 0);
402
  signal wr_rq_we_r  : std_logic;
403
  signal wr_rq_full  : std_logic;
404
  signal wr_rq       : std_logic_vector(hibi_data_width_g - 1 downto 0);
405
  signal wr_rq_re    : std_logic;
406
  signal wr_rq_empty : std_logic;
407
 
408
  -- Zero response fifo signals
409
  signal zero_in_r  : std_logic_vector(hibi_data_width_g - 1 downto 0);
410
  signal zero_out_r : std_logic_vector(hibi_data_width_g - 1 downto 0);
411
  signal zero_we_r  : std_logic;
412
  signal zero_full  : std_logic;
413
  signal zero_re    : std_logic;
414
  signal zero_empty : std_logic;
415
 
416
begin  -- rtl
417
 
418
 
419
  -- The sdram2hibi needs to know its own base hibi address.
420
  assert own_hibi_base_addr_g /= 0 report "Please set own_hibi_base_addr_g" severity failure;
421
 
422
-------------------------------------------------------------------------------
423
-- Drive outputs
424
-------------------------------------------------------------------------------
425
  sdram_ctrl_byte_select_out <= (others => '0');  -- byteenable not implemented
426
  sdram_ctrl_output_full_out <= hibi_full_in;
427
 
428
  hibi_msg_we_out   <= hibi_msg_we_r;
429
  hibi_msg_data_out <= hibi_msg_data_r;
430
  hibi_msg_addr_out <= hibi_msg_addr_r;
431
  hibi_msg_comm_out <= MSG_WR_c;
432
  hibi_comm_out     <= DATA_WR_c;
433
  hibi_data_out     <= sdram_ctrl_data_in;
434
  hibi_we_out       <= sdram_ctrl_we_in;
435
 
436
  -- combine comm, data, and addr to one signal
437
  single_op_in <= single_op_comm_in_r & single_op_addr_in_r &
438
                  data_to_fifos_r;
439
 
440
  -- divide single operation fifo output to comm, addr and data
441
  single_op_comm_out <= single_op_out
442
                        (single_op_out'length - 1
443
                         downto single_op_out'length - 2);
444
  single_op_ret_addr_out <= single_op_out
445
                            (single_op_out'length - 2 - 1 downto
446
                             hibi_data_width_g);
447
  single_op_addr_out <= single_op_out(hibi_data_width_g + mem_addr_width_g - 1
448
                                      downto hibi_data_width_g);
449
  single_op_data_out <= single_op_out(hibi_data_width_g - 1 downto 0);
450
 
451
 
452
-------------------------------------------------------------------------------
453
-- or_reduce read ports overlap vector
454
-------------------------------------------------------------------------------
455
  gen_r_overlap : process (r_overlap_vec_r)
456
  begin  -- process gen_r_overlap
457
    for rd_port in num_of_read_ports_g - 1 downto 0 loop
458
      if to_integer(unsigned(r_overlap_vec_r(rd_port))) /= 0 then
459
        r_overlap(rd_port) <= '1';
460
      else
461
        r_overlap(rd_port) <= '0';
462
      end if;
463
    end loop;  -- rd_port
464
  end process gen_r_overlap;
465
 
466
-------------------------------------------------------------------------------
467
-- generate request signals for read port arbitrator
468
-------------------------------------------------------------------------------
469
--  gen_r_port_req : for rd_port in num_of_read_ports_g - 1 downto 0 generate
470
--    r_port_req(rd_port) <= r_valid_r(rd_port) and not(r_overlap(rd_port));
471
--  end generate gen_r_port_req;
472
 
473
-------------------------------------------------------------------------------
474
-- generate hold signals for read port arbitrator
475
-------------------------------------------------------------------------------
476
--  gen_r_port_hold : for rd_port in num_of_read_ports_g - 1 downto 0 generate
477
--    r_port_hold(rd_port) <= r_port_req(rd_port) and not(rd_hold_mask);
478
--  end generate gen_r_port_hold;
479
 
480
-------------------------------------------------------------------------------
481
-- generate request signals for write port arbitrator
482
-------------------------------------------------------------------------------
483
  gen_w_port_req : for wr_port in num_of_write_ports_g - 1 downto 0 generate
484
    w_port_req(wr_port) <= w_valid_r(wr_port) and not(w_empty(wr_port));
485
  end generate gen_w_port_req;
486
 
487
-------------------------------------------------------------------------------
488
-- generate hold signals for write port arbitrator
489
-------------------------------------------------------------------------------
490
  gen_w_port_hold : for wr_port in num_of_write_ports_g - 1 downto 0 generate
491
    w_port_hold(wr_port) <= w_port_req(wr_port) and not(wr_hold_mask);
492
  end generate gen_w_port_hold;
493
 
494
-------------------------------------------------------------------------------
495
-- generate request signals for next operation arbtrator
496
-------------------------------------------------------------------------------
497
  gen_op_req : process (curr_rd_port_r, r_valid_r, r_overlap, w_port_req, single_op_empty)
498
--  gen_op_req : process (r_port_req, w_port_req, single_op_empty)
499
  begin  -- process gen_op_req
500
--    if to_integer(unsigned(r_port_req)) /= 0 then
501
    if r_valid_r(curr_rd_port_r) = '1' and r_overlap(curr_rd_port_r) = '0' then
502
      next_op_req(blk_rd_prior_g) <= '1';
503
    else
504
      next_op_req(blk_rd_prior_g) <= '0';
505
    end if;
506
 
507
    if to_integer(unsigned(w_port_req)) /= 0 then
508
      next_op_req(blk_wr_prior_g) <= '1';
509
    else
510
      next_op_req(blk_wr_prior_g) <= '0';
511
    end if;
512
 
513
    next_op_req(single_op_prior_g) <= not(single_op_empty);
514
  end process gen_op_req;
515
 
516
-------------------------------------------------------------------------------
517
-- generate hold signals for next operation arbitrator
518
-- that chooses the next operation(i.e. block read, block write, single op)
519
-------------------------------------------------------------------------------
520
  next_op_hold(blk_rd_prior_g) <= next_op_req(blk_rd_prior_g)
521
                                     and not(rd_hold_mask);
522
  next_op_hold(blk_wr_prior_g) <= next_op_req(blk_wr_prior_g)
523
                                     and not(wr_hold_mask);
524
  next_op_hold(single_op_prior_g) <= next_op_req(single_op_prior_g)
525
                                     and not(single_op_hold_mask);
526
 
527
-------------------------------------------------------------------------------
528
-- Multiplex correct signals to SDRAM controller
529
-- (empty, one_data_left, data)
530
-------------------------------------------------------------------------------
531
  -- when single op, write port outputs must have some value
532
  w_data_out(num_of_write_ports_g)   <= (others => '0');
533
  w_empty(num_of_write_ports_g)      <= '0';
534
  w_one_d_left(num_of_write_ports_g) <= '0';
535
 
536
  -- multiplex correct empty to SDRAM controller
537
  with single_op_on_r select
538
    sdram_ctrl_input_empty_out <=
539
    w_empty(curr_wr_port_r) when '0',
540
    '0' when others;
541
 
542
  -- multiplex the correct one_d_left to SDRAM controller
543
  with single_op_on_r select
544
    sdram_ctrl_input_one_d_out <=
545
    w_one_d_left(curr_wr_port_r) when '0',
546
    '0' when others;
547
 
548
  -- multiplex the correct data to SDRAM controller
549
  with single_op_on_r select
550
    sdram_ctrl_data_out <=
551
    single_op_data_out_r       when '1',
552
    w_data_out(curr_wr_port_r) when others;
553
 
554
-------------------------------------------------------------------------------
555
-- Generate hold signals for read port arbitter
556
-------------------------------------------------------------------------------
557
  gen_rd_hold_mask : process (r_finish_r)
558
    variable hold_v : std_logic;
559
  begin  -- process gen_rd_hold_mask
560
    hold_v := '0';
561
    for i in num_of_read_ports_g - 1 downto 0 loop
562
      hold_v := hold_v or r_finish_r(i);
563
    end loop;  -- i
564
    rd_hold_mask <= hold_v;
565
  end process gen_rd_hold_mask;
566
 
567
-------------------------------------------------------------------------------
568
-- Detect read and write port requests and configs from HIBI msg fifo
569
-------------------------------------------------------------------------------
570
  detect_rqs_and_confs: process (hibi_msg_addr_in, hibi_msg_empty_in)
571
    variable msg_addr_v : std_logic_vector(msg_addr_compw_c - 1 downto 0);
572
  begin  -- process detect_rqs_and_confs
573
 
574
    msg_addr_v := hibi_msg_addr_in(msg_addr_compw_c - 1 downto 0);
575
 
576
    if to_integer(unsigned(msg_addr_v)) = 0 and hibi_msg_empty_in = '0' then
577
      rd_port_rq   <= '1';
578
      wr_port_rq   <= '0';
579
      rd_port_conf <= '0';
580
      wr_port_conf <= '0';
581
    elsif to_integer(unsigned(msg_addr_v)) = 1 and hibi_msg_empty_in = '0' then
582
      rd_port_rq   <= '0';
583
      wr_port_rq   <= '1';
584
      rd_port_conf <= '0';
585
      wr_port_conf <= '0';
586
    elsif to_integer(unsigned(msg_addr_v)) > 1
587
      and to_integer(unsigned(msg_addr_v)) < 2 + num_of_read_ports_g
588
      and hibi_msg_empty_in = '0' then
589
      rd_port_rq   <= '0';
590
      wr_port_rq   <= '0';
591
      rd_port_conf <= '1';
592
      wr_port_conf <= '0';
593
    elsif to_integer(unsigned(msg_addr_v)) > 1 + num_of_read_ports_g
594
      and to_integer(unsigned(msg_addr_v)) <
595
      2 + num_of_read_ports_g + num_of_write_ports_g
596
      and hibi_msg_empty_in = '0' then
597
      rd_port_rq   <= '0';
598
      wr_port_rq   <= '0';
599
      rd_port_conf <= '0';
600
      wr_port_conf <= '1';
601
    else
602
      rd_port_rq   <= '0';
603
      wr_port_rq   <= '0';
604
      rd_port_conf <= '0';
605
      wr_port_conf <= '0';
606
    end if;
607
  end process detect_rqs_and_confs;
608
 
609
-------------------------------------------------------------------------------
610
-- BLOCKING
611
-- Read HIBI msg fifo
612
-- Only situations for not reading the fifo are:
613
--   1) read port request and both rd_rq and zero response fifos are full
614
--   2) write port request and both wr_rq and zero response fifos are full
615
-------------------------------------------------------------------------------
616
  gen_blocking_read_msgs: if rq_fifo_depth_g > 0 generate
617
    read_msgs : process (rd_port_rq, wr_port_rq,
618
                         rd_rq_full, wr_rq_full,
619
                         zero_full)
620
    begin  -- process read_msgs
621
 
622
      if rd_port_rq = '1'
623
        and rd_rq_full = '1' and zero_full = '1' then
624
 
625
        -- read port request that we can't put anywhere
626
        -- (i.e. rd_rq_fifo full and zero_fifo full
627
        hibi_msg_re_out <= '0';
628
 
629
      elsif wr_port_rq = '1'
630
        and wr_rq_full = '1' and zero_full = '1' then
631
 
632
        -- write port request that we can't put anywhere
633
        -- (i.e. wr_rq_fifo full and zero_fifo full
634
        hibi_msg_re_out <= '0';
635
 
636
      else
637
 
638
        -- either port request that we can serve or
639
        -- port configuration
640
        hibi_msg_re_out <= '1';
641
      end if;
642
 
643
    end process read_msgs;
644
  end generate gen_blocking_read_msgs;
645
-------------------------------------------------------------------------------
646
-- NON-BLOCKING
647
-- Read HIBI msg fifo
648
-- Only situations for not reading the fifo is when there's a port request
649
-- and HIBI msg fifo full
650
-- otherwise we send either port offset or zero offset or we configure port
651
-------------------------------------------------------------------------------
652
  gen_non_blocking_read_msgs: if rq_fifo_depth_g = 0 generate
653
    read_msgs : process (rd_port_rq, wr_port_rq, hibi_msg_full_in)
654
 
655
    begin  -- process read_msgs
656
 
657
      if (rd_port_rq = '1' or wr_port_rq = '1') and hibi_msg_full_in = '1' then
658
 
659
        -- hibi msg fifo full
660
        hibi_msg_re_out <= '0';
661
 
662
      else
663
 
664
        -- hibi msg fifo not full
665
        hibi_msg_re_out <= '1';
666
      end if;
667
 
668
    end process read_msgs;
669
  end generate gen_non_blocking_read_msgs;
670
 
671
-------------------------------------------------------------------------------
672
-- BLOCKING
673
-- Write port requests from HIBI msg fifo to
674
-- request fifos or zero response fifo
675
-------------------------------------------------------------------------------
676
  gen_blocking_write_rq_fifos: if rq_fifo_depth_g > 0 generate
677
    write_rq_fifos : process (clk, rst_n)
678
    begin  -- process write_rq_fifos
679
      if rst_n = '0' then                 -- asynchronous reset (active low)
680
        rd_rq_we_r   <= '0';
681
        wr_rq_we_r   <= '0';
682
        zero_we_r    <= '0';
683
        zero_in_r    <= (others => '0');
684
        rd_rq_in_r   <= (others => '0');
685
        wr_rq_in_r   <= (others => '0');
686
      elsif clk'event and clk = '1' then  -- rising clock edge
687
 
688
        if rd_rq_we_r = '1' and rd_rq_full = '1' then
689
 
690
          -- wait for previous read request fifo write
691
          rd_rq_we_r <= '1';
692
          rd_rq_in_r <= rd_rq_in_r;
693
 
694
        elsif rd_port_rq = '1' and rd_rq_full = '0' then
695
 
696
          -- read port request, write request to read request fifo
697
          rd_rq_we_r <= '1';
698
          rd_rq_in_r <= hibi_msg_data_in;
699
 
700
        else
701
          -- no read port requests or read port request fifo full
702
          rd_rq_we_r <= '0';
703
          rd_rq_in_r <= (others => '0');
704
        end if;
705
 
706
        if wr_rq_we_r = '1' and wr_rq_full = '1' then
707
 
708
          -- wait for previous write port request fifo write
709
          wr_rq_we_r <= '1';
710
          wr_rq_in_r <= wr_rq_in_r;
711
 
712
        elsif wr_port_rq = '1' and wr_rq_full = '0' then
713
 
714
          -- write port request, write to write request fifo
715
          wr_rq_we_r <= '1';
716
          wr_rq_in_r <= hibi_msg_data_in;
717
        else
718
 
719
          -- no write port requests or write request fifo full
720
          wr_rq_we_r <= '0';
721
          wr_rq_in_r <= (others => '0');
722
        end if;
723
 
724
        if zero_we_r = '1' and zero_full = '1' then
725
 
726
          -- wait for previous zero response write
727
          zero_we_r <= '1';
728
          zero_in_r <= zero_in_r;
729
 
730
        elsif ((rd_port_rq = '1' and rd_rq_full = '1')
731
               or (wr_port_rq = '1' and wr_rq_full = '1'))
732
          and zero_full = '0' then
733
 
734
          -- read or write port request and
735
          -- corresponding request fifo full
736
          -- write to zero response fifo
737
          zero_we_r <= '1';
738
          zero_in_r <= hibi_msg_data_in;
739
 
740
        else
741
 
742
          -- requests go to request fifo or
743
          -- zero response fifo full
744
          zero_we_r <= '0';
745
          zero_in_r <= (others => '0');
746
        end if;
747
 
748
      end if;
749
    end process write_rq_fifos;
750
  end generate gen_blocking_write_rq_fifos;
751
 
752
-------------------------------------------------------------------------------
753
-- BLOCKING
754
-- Read port requests from request fifos
755
-- type   : combinational
756
--
757
-- !!! NOTE !!!
758
-- Write response and read response must be in the same order as in
759
-- send_resps process(i.e. if write request sending is the 1st elsif then
760
-- wr rq fifo read should also be the 1st elsif in read_rq_fifos process
761
-------------------------------------------------------------------------------
762
  gen_blocking_read_rq_fifos: if rq_fifo_depth_g > 0 generate
763
    read_rq_fifos : process (rd_rq_empty, wr_rq_empty, zero_empty,
764
                             free_r_port, free_w_port,
765
                             hibi_msg_full_in)
766
      variable free_r_port_v : std_logic;
767
      variable free_w_port_v : std_logic;
768
    begin  -- process read_rq_fifos
769
 
770
      if wr_rq_empty = '0' and free_w_port = '1' and hibi_msg_full_in = '0' then
771
 
772
        -- Write port request from fifo
773
        -- Free write port available and HIBI msg fifo not full
774
        rd_rq_re <= '0';
775
        wr_rq_re <= '1';
776
        zero_re  <= '0';
777
 
778
      elsif rd_rq_empty = '0' and free_r_port = '1' and hibi_msg_full_in = '0' then
779
 
780
        -- Read port request from fifo
781
        -- Free read port available and HIBI msg fifo not full
782
        rd_rq_re <= '1';
783
        wr_rq_re <= '0';
784
        zero_re  <= '0';
785
 
786
      elsif zero_empty = '0' and hibi_msg_full_in = '0' then
787
 
788
        -- Read or write port request
789
        -- No ports available and and HIBI msg fifo not full
790
        rd_rq_re <= '0';
791
        wr_rq_re <= '0';
792
        zero_re  <= '1';
793
 
794
      else
795
        rd_rq_re <= '0';
796
        wr_rq_re <= '0';
797
        zero_re  <= '0';
798
      end if;
799
    end process read_rq_fifos;
800
  end generate gen_blocking_read_rq_fifos;
801
 
802
-------------------------------------------------------------------------------
803
-- BLOCKING
804
-- Send responses to port requests
805
-- Options are:
806
--  1) Free read port offset to request from rd_rq_fifo
807
--  2) Free write port offset to request from wr_rq_fifo
808
--  3) Zero response to request from zero fifo
809
--
810
-- !!! NOTE !!!
811
-- Write response and read response must be in the same order as in
812
-- read_rq_fifos process(i.e. if write request sending is the 1st elsif then
813
-- wr rq fifo read should also be the 1st elsif in read_rq_fifos process
814
-------------------------------------------------------------------------------
815
  gen_blocking_send_resps: if rq_fifo_depth_g > 0 generate
816
    send_resps : process (clk, rst_n)
817
    begin  -- process send_resps
818
      if rst_n = '0' then                 -- asynchronous reset (active low)
819
        hibi_msg_we_r   <= '0';
820
        hibi_msg_addr_r <= (others => '0');
821
        hibi_msg_data_r <= (others => '0');
822
      elsif clk'event and clk = '1' then  -- rising clock edge
823
 
824
        if hibi_msg_we_r = '1' and hibi_msg_full_in = '1' then
825
 
826
          -- wait for previous write
827
          hibi_msg_we_r   <= '1';
828
          hibi_msg_addr_r <= hibi_msg_addr_r;
829
          hibi_msg_data_r <= hibi_msg_data_r;
830
 
831
        elsif wr_rq_empty = '0' and free_w_port = '1' and hibi_msg_full_in = '0' then
832
 
833
          -- free write port and write request in fifo and
834
          -- HIBI msg fifo not full, send write port offset
835
          hibi_msg_we_r   <= '1';
836
          hibi_msg_addr_r <= wr_rq;
837
          hibi_msg_data_r <= std_logic_vector(
838
            to_unsigned(free_w_offset, hibi_msg_data_r'length));
839
 
840
        elsif rd_rq_empty = '0' and free_r_port = '1' and hibi_msg_full_in = '0' then
841
          -- free read port and read request in fifo and
842
          -- HIBI msg fifo not full, send read port offset
843
          hibi_msg_we_r   <= '1';
844
          hibi_msg_addr_r <= rd_rq;
845
          hibi_msg_data_r <=std_logic_vector(
846
            to_unsigned(free_r_offset, hibi_msg_data_r'length));
847
 
848
        elsif zero_empty = '0' and hibi_msg_full_in = '0' then
849
          -- no free ports and HIBI msg fifo not full,
850
          -- send zero response
851
          hibi_msg_we_r   <= '1';
852
          hibi_msg_addr_r <= zero_out_r;
853
          hibi_msg_data_r <= (others => '0');
854
 
855
        else
856
          hibi_msg_we_r   <= '0';
857
          hibi_msg_addr_r <= (others => '0');
858
          hibi_msg_data_r <= (others => '0');
859
        end if;
860
      end if;
861
    end process send_resps;
862
  end generate gen_blocking_send_resps;
863
-------------------------------------------------------------------------------
864
-- NON-BLOCKING
865
-- Send responses to port requests
866
-- Options are:
867
--  1) Free read port offset to request from HIBI msg fifo
868
--  2) Free write port offset to request from HIBI msg fifo
869
--  3) Zero response to request from HIBI msg fifo
870
-------------------------------------------------------------------------------
871
  gen_non_blocking_send_resps: if rq_fifo_depth_g = 0 generate
872
    send_resps : process (clk, rst_n)
873
    begin  -- process send_resps
874
      if rst_n = '0' then                 -- asynchronous reset (active low)
875
        hibi_msg_we_r   <= '0';
876
        hibi_msg_addr_r <= (others => '0');
877
        hibi_msg_data_r <= (others => '0');
878
      elsif clk'event and clk = '1' then  -- rising clock edge
879
 
880
        if hibi_msg_we_r = '1' and hibi_msg_full_in = '1' then
881
          -- wait for previous write
882
          hibi_msg_we_r   <= '1';
883
          hibi_msg_addr_r <= hibi_msg_addr_r;
884
          hibi_msg_data_r <= hibi_msg_data_r;
885
 
886
        elsif wr_port_rq = '1' and free_w_port = '1'
887
          and hibi_msg_full_in = '0' then
888
          -- write port request and free write port available
889
          -- send free write port offset
890
          hibi_msg_we_r   <= '1';
891
          hibi_msg_addr_r <= hibi_msg_data_in;
892
          hibi_msg_data_r <= std_logic_vector(
893
            to_unsigned(free_w_offset, hibi_msg_data_r'length));
894
 
895
        elsif rd_port_rq = '1' and free_r_port = '1'
896
          and hibi_msg_full_in = '0' then
897
          -- read port request and free read port available
898
          -- send free read port offset
899
          hibi_msg_we_r   <= '1';
900
          hibi_msg_addr_r <= hibi_msg_data_in;
901
          hibi_msg_data_r <= std_logic_vector(
902
            to_unsigned(free_r_offset, hibi_msg_data_r'length));
903
 
904
        elsif wr_port_rq = '1' and free_w_port = '0'
905
          and hibi_msg_full_in = '0' then
906
          -- write port request and
907
          -- no free write ports, send zero offset
908
          hibi_msg_we_r   <= '1';
909
          hibi_msg_addr_r <= hibi_msg_data_in;
910
          hibi_msg_data_r <= (others => '0');
911
 
912
        elsif rd_port_rq = '1' and free_r_port = '0'
913
          and hibi_msg_full_in = '0' then
914
          -- read port request and
915
          -- no free read ports, send zero offset
916
          hibi_msg_we_r   <= '1';
917
          hibi_msg_addr_r <= hibi_msg_data_in;
918
          hibi_msg_data_r <= (others => '0');
919
 
920
        else
921
          hibi_msg_we_r   <= '0';
922
          hibi_msg_addr_r <= (others => '0');
923
          hibi_msg_data_r <= (others => '0');
924
        end if;
925
      end if;
926
    end process send_resps;
927
  end generate gen_non_blocking_send_resps;
928
 
929
-------------------------------------------------------------------------------
930
-- BLOCKING
931
-- Reserve ports when we send port offset
932
-------------------------------------------------------------------------------
933
  gen_blocking_reserve_ports: if rq_fifo_depth_g > 0 generate
934
    reserve_ports : process (rd_rq_re, wr_rq_re,
935
                             free_r_num_r, free_w_num)
936
    begin
937
      -- defaults
938
      r_reserve <= (others => '0');
939
      w_reserve <= (others => '0');
940
 
941
      if rd_rq_re = '1' then
942
        -- we send and reserve read port offset
943
        -- when we read from rd_rq fifo
944
        r_reserve(free_r_num_r) <= '1';
945
      elsif wr_rq_re = '1' then
946
        -- we send and reserve write port offset
947
        -- when we read from wr_rq fifo
948
        w_reserve(free_w_num) <= '1';
949
      end if;
950
    end process reserve_ports;
951
  end generate gen_blocking_reserve_ports;
952
-------------------------------------------------------------------------------
953
-- NON-BLOCKING
954
-- Reserve ports when we send port offset
955
-------------------------------------------------------------------------------
956
  gen_non_blocking_reserve_ports: if rq_fifo_depth_g = 0 generate
957
    reserve_ports : process (rd_port_rq, wr_port_rq,
958
                             free_r_port, free_w_port,
959
                             free_r_num_r, free_w_num,
960
                             hibi_msg_full_in)
961
    begin
962
      -- defaults
963
      r_reserve <= (others => '0');
964
      w_reserve <= (others => '0');
965
 
966
      if rd_port_rq = '1' and free_r_port = '1'
967
        and hibi_msg_full_in = '0' then
968
        -- we send and reserve read port offset
969
        -- when we read from rd_rq fifo
970
        r_reserve(free_r_num_r) <= '1';
971
      elsif wr_port_rq = '1' and free_w_port = '1'
972
        and hibi_msg_full_in = '0' then
973
        -- we send and reserve write port offset
974
        -- when we read from wr_rq fifo
975
        w_reserve(free_w_num) <= '1';
976
      end if;
977
    end process reserve_ports;
978
  end generate gen_non_blocking_reserve_ports;
979
 
980
-------------------------------------------------------------------------------
981
-- Update free read port pointer
982
-------------------------------------------------------------------------------
983
  update_free_r_num: process (clk, rst_n)
984
  begin  -- process update_free_r_num
985
    if rst_n = '0' then                 -- asynchronous reset (active low)
986
      free_r_num_r <= 0;
987
    elsif clk'event and clk = '1' then  -- rising clock edge
988
      if to_integer(unsigned(r_reserve)) /= 0 then
989
 
990
        if free_r_num_r = num_of_read_ports_g - 1 then
991
          free_r_num_r <= 0;
992
        else
993
          free_r_num_r <= free_r_num_r + 1;
994
        end if;
995
      end if;
996
    else
997
      free_r_num_r <= free_r_num_r;
998
    end if;
999
  end process update_free_r_num;
1000
  free_r_offset <= 2 + free_r_num_r;
1001
  free_r_port   <= not(r_reserved_r(free_r_num_r));
1002
 
1003
-------------------------------------------------------------------------------
1004
-- Read configurations from HIBI msg fifo and send them to ports
1005
-------------------------------------------------------------------------------
1006
  send_configs_to_ports : process (clk, rst_n)
1007
    variable msg_addr_v : std_logic_vector(msg_addr_compw_c - 1 downto 0);
1008
  begin  -- process send_configs_to_ports
1009
    if rst_n = '0' then                 -- asynchronous reset (active low)
1010
      conf_wr_r   <= (others => '0');
1011
      conf_rd_r   <= (others => '0');
1012
      conf_data_r <= (others => '0');
1013
      msg_addr_v  := (others => '0');
1014
    elsif clk'event and clk = '1' then  -- rising clock edge
1015
 
1016
      -- read conf_data_r
1017
      conf_data_r <= hibi_msg_data_in;
1018
 
1019
      -- we don't need to compare all bits
1020
      -- only addresses 0..2+num_of_read_ports_g+num_of_write_ports_g
1021
      -- are of interest
1022
      msg_addr_v := hibi_msg_addr_in(msg_addr_compw_c - 1 downto 0);
1023
 
1024
      if wr_port_conf = '1' then
1025
 
1026
        -- Write port configuration from HIBI msg fifo
1027
        conf_rd_r <= (others => '0');   -- not a read config
1028
        for i in num_of_write_ports_g - 1 downto 0 loop
1029
          -- which port is configured?
1030
          if to_integer(unsigned(msg_addr_v))
1031
            - 2 - num_of_read_ports_g = i then
1032
            conf_wr_r(i) <= '1';
1033
          else
1034
            conf_wr_r(i) <= '0';
1035
          end if;
1036
        end loop;  -- i
1037
 
1038
      elsif rd_port_conf = '1' then
1039
 
1040
        -- Read port configuration from HIBI msg fifo
1041
        conf_wr_r <= (others => '0');   -- not a write config
1042
        for i in num_of_read_ports_g - 1 downto 0 loop
1043
          -- which port is configured?
1044
          if to_integer(unsigned(msg_addr_v)) - 2 = i then
1045
            conf_rd_r(i) <= '1';
1046
          else
1047
            conf_rd_r(i) <= '0';
1048
          end if;
1049
        end loop;  -- i
1050
      else
1051
        -- no configs
1052
        conf_rd_r <= (others => '0');
1053
        conf_wr_r <= (others => '0');
1054
      end if;
1055
    end if;
1056
  end process send_configs_to_ports;
1057
 
1058
-------------------------------------------------------------------------------
1059
-- Detect read and write port overlaps and
1060
-- block overlapping reads
1061
-------------------------------------------------------------------------------
1062
  detect_overlaps : process (clk, rst_n)
1063
  begin  -- process detect_overlaps
1064
    if rst_n = '0' then                 -- asynchronous reset (active low)
1065
      r_overlap_vec_r <= (others => (others => '0'));
1066
      prev_r_valid_r  <= (others => '0');
1067
    elsif clk'event and clk = '1' then  -- rising clock edge
1068
 
1069
      -- detect rising edge of valid read port signals
1070
      prev_r_valid_r <= r_valid_r;
1071
 
1072
      for r in num_of_read_ports_g - 1 downto 0 loop
1073
        -- read port is being reserved,
1074
        -- default overlap for all write ports until
1075
        -- we have calculated the actual overlap
1076
        if r_reserve(r) = '1' then
1077
          r_overlap_vec_r(r) <= (others => '1');
1078
        end if;
1079
      end loop;  -- r
1080
 
1081
      for r in num_of_read_ports_g - 1 downto 0 loop
1082
 
1083
        if prev_r_valid_r(r) = '0' and r_valid_r(r) = '1' then
1084
 
1085
          -- read port configured, calculate actual overlaps
1086
          for w in num_of_write_ports_g - 1 downto 0 loop
1087
 
1088
            if w_valid_r(w) = '1' then
1089
 
1090
              -- overlap can happen only with valid write ports
1091
              --   - no overlap if read start addr > write end addr or
1092
              --                   read end addr < write start addr
1093
              if unsigned(r_src_addr_r(r)) > unsigned(w_end_addr_r(w)) or
1094
                unsigned(r_end_addr_r(r)) < unsigned(w_dst_addr_r(w)) then
1095
                r_overlap_vec_r(r)(w) <= '0';
1096
              else
1097
                r_overlap_vec_r(r)(w) <= '1';
1098
              end if;
1099
            else
1100
              r_overlap_vec_r(r)(w) <= '0';
1101
            end if;
1102
          end loop;  -- w
1103
        end if;
1104
      end loop;  -- r
1105
 
1106
      -- if write port finishes, clear overlap
1107
      for w in num_of_write_ports_g - 1 downto 0 loop
1108
        if w_valid_r(w) = '0' then
1109
          for r in num_of_read_ports_g - 1 downto 0 loop
1110
            r_overlap_vec_r(r)(w) <= '0';
1111
          end loop;  -- r
1112
        end if;
1113
      end loop;  -- w
1114
 
1115
    end if;
1116
  end process detect_overlaps;
1117
 
1118
-------------------------------------------------------------------------------
1119
-- Find free read and write ports
1120
-------------------------------------------------------------------------------
1121
  -- Find free read ports
1122
--  find_free_r_port : process (r_reserved_r)
1123
--  begin  -- process find_free_r_port
1124
--
1125
--    free_r_port   <= '0';
1126
--    free_r_num    <= 0;
1127
--    free_r_offset <= 0;
1128
--    for i in num_of_read_ports_g - 1 downto 0 loop
1129
--      if r_reserved_r(i) = '0' then
1130
--        -- if port is not reserved, it is free
1131
--        free_r_port   <= '1';
1132
--        free_r_num    <= i;
1133
--        free_r_offset <= 2 + i;
1134
--      end if;
1135
--    end loop;  -- i
1136
--
1137
--  end process find_free_r_port;
1138
 
1139
  -- Find free write ports
1140
  find_free_w_port : process (w_reserved_r)
1141
  begin  -- process find_free_w_port
1142
 
1143
    free_w_port   <= '0';
1144
    free_w_num    <= 0;
1145
    free_w_offset <= 0;
1146
 
1147
    for i in num_of_write_ports_g - 1 downto 0 loop
1148
      if w_reserved_r(i) = '0' then
1149
        -- if port is not reserved, it is free
1150
        free_w_port   <= '1';
1151
        free_w_num    <= i;
1152
        free_w_offset <= 2 + num_of_read_ports_g + i;
1153
      end if;
1154
    end loop;  -- i
1155
 
1156
  end process find_free_w_port;
1157
 
1158
-----------------------------------------------------------------------------
1159
-- Read HIBI and put data into ports
1160
-----------------------------------------------------------------------------
1161
 
1162
  -- Read HIBI fifo
1163
  -- Read always except when previous write is pending
1164
  read_hibi : process (w_full, w_we_r, single_op_full, single_op_we_r)
1165
  begin  -- process read_hibi
1166
 
1167
    if single_op_full = '1' and single_op_we_r = '1' then
1168
      -- wait for single op write
1169
      hibi_re_out <= '0';
1170
    elsif to_integer(unsigned(w_full and w_we_r)) /= 0 then
1171
      -- wait for write port write
1172
      hibi_re_out <= '0';
1173
    else
1174
      hibi_re_out <= '1';
1175
    end if;
1176
  end process read_hibi;
1177
 
1178
  -- Write HIBI data to single op fifo or write port input fifos
1179
  sort_data_to_ports : process (clk, rst_n)
1180
    variable port_write_v : std_logic;
1181
  begin  -- process sort_data_to_ports
1182
    if rst_n = '0' then                 -- asynchronous reset (active low)
1183
      single_op_comm_in_r <= (others => '0');
1184
      single_op_we_r      <= '0';
1185
      w_we_r              <= (others => '0');
1186
      data_to_fifos_r     <= (others => '0');
1187
      single_op_addr_in_r <= (others => '0');
1188
    elsif clk'event and clk = '1' then  -- rising clock edge
1189
 
1190
      if single_op_we_r = '1' and single_op_full = '1' then
1191
 
1192
        -- wait for previous single op write
1193
        single_op_we_r      <= single_op_we_r;
1194
        w_we_r              <= (others => '0');
1195
        data_to_fifos_r     <= data_to_fifos_r;
1196
        single_op_addr_in_r <= single_op_addr_in_r;
1197
        single_op_comm_in_r <= single_op_comm_in_r;
1198
 
1199
      elsif to_integer(unsigned(w_full and w_we_r)) /= 0 then
1200
 
1201
        -- wait for previous write port fifo write
1202
        single_op_we_r      <= '0';
1203
        w_we_r              <= w_we_r;
1204
        data_to_fifos_r     <= data_to_fifos_r;
1205
        single_op_addr_in_r <= single_op_addr_in_r;
1206
        single_op_comm_in_r <= single_op_comm_in_r;
1207
 
1208
      elsif hibi_empty_in = '0' then
1209
 
1210
        -- data from HIBI fifo
1211
 
1212
   -- Original broken code before fixing on 2012 by A.Alhonen
1213
   -- Please test the new one thoroughly and remove the commented code
1214
   -- if the new is really ok.
1215
--        single_op_addr_in_r <= hibi_addr_in;
1216
        single_op_addr_in_r <= std_logic_vector(unsigned(hibi_addr_in) -
1217
                               to_unsigned(own_hibi_base_addr_g, hibi_data_width_g));
1218
 
1219
        data_to_fifos_r     <= hibi_data_in;
1220
 
1221
        if hibi_comm_in = DATA_WR_c then
1222
 
1223
          -- write comm from HIBI
1224
          single_op_comm_in_r <= "10";  -- write
1225
          port_write_v        := '0';
1226
          for i in num_of_write_ports_g - 1 downto 0 loop
1227
            -- is this a port write?
1228
 
1229
   -- Original broken code before fixing on 2012 by A.Alhonen
1230
   -- Please test the new one thoroughly and remove the commented code
1231
   -- if the new is really ok.
1232
--            if to_integer(unsigned(
1233
--              hibi_addr_in(mem_addr_width_g - 1
1234
--                           downto 0))) - 2 - num_of_read_ports_g = i then
1235
 
1236
            if to_integer(unsigned(hibi_addr_in)) - own_hibi_base_addr_g
1237
              - 2 - num_of_read_ports_g = i then
1238
              -- yes it is, write to write port fifo
1239
              port_write_v := '1';
1240
              w_we_r(i)    <= '1';
1241
            else
1242
              w_we_r(i) <= '0';
1243
            end if;
1244
          end loop;  -- i
1245
 
1246
          if port_write_v = '0' then
1247
            -- single op write, write to single op fifo
1248
            single_op_we_r      <= '1';
1249
            single_op_comm_in_r <= "10";  -- write
1250
          else
1251
            single_op_we_r      <= '0';
1252
            single_op_comm_in_r <= single_op_comm_in_r;
1253
          end if;
1254
 
1255
        else
1256
          -- read comm from HIBI
1257
          -- single read
1258
          w_we_r              <= (others => '0'); -- not write
1259
          single_op_comm_in_r <= "01";            -- read
1260
          single_op_we_r      <= '1';
1261
        end if;
1262
 
1263
      else
1264
 
1265
        -- HIBI empty, do nothing
1266
        single_op_we_r      <= '0';
1267
        w_we_r              <= (others => '0');
1268
        single_op_comm_in_r <= single_op_comm_in_r;
1269
        data_to_fifos_r     <= hibi_data_in;
1270
 
1271
      end if;
1272
    end if;
1273
  end process sort_data_to_ports;
1274
 
1275
 
1276
-------------------------------------------------------------------------------
1277
-- Update curr read port ptr
1278
-------------------------------------------------------------------------------
1279
  update_curr_rd_port: process (clk, rst_n)
1280
  begin  -- process update_curr_rd_port
1281
    if rst_n = '0' then                 -- asynchronous reset (active low)
1282
      curr_rd_port_r <= 0;
1283
    elsif clk'event and clk = '1' then  -- rising clock edge
1284
      if to_integer(unsigned(r_finish_r)) /= 0 then
1285
        if curr_rd_port_r = num_of_read_ports_g - 1 then
1286
          curr_rd_port_r <= 0;
1287
        else
1288
          curr_rd_port_r <= curr_rd_port_r + 1;
1289
        end if;
1290
      else
1291
        curr_rd_port_r <= curr_rd_port_r;
1292
      end if;
1293
    end if;
1294
  end process update_curr_rd_port;
1295
-------------------------------------------------------------------------------
1296
-- Assigns commands from read/write ports or from single
1297
-- operation port to sdram_controller.
1298
-- This only tries one operation per cycle. So if next operation
1299
-- is read and there's no valid read operations in the read
1300
-- ports, one cycle is wasted. This could be optimized.
1301
-------------------------------------------------------------------------------
1302
  from_ports_to_controller : process (clk, rst_n)
1303
  begin  -- process from_ports_to_controller
1304
 
1305
    if rst_n = '0' then                 -- asynchronous reset (active low)
1306
 
1307
      sdram_ctrl_comm_out        <= "00";
1308
      sdram_ctrl_addr_out        <= (others => '0');
1309
      sdram_ctrl_data_amount_out <= (others => '0');
1310
--      curr_rd_port_r             <= 0;
1311
--      curr_wr_port_r             <= 0;
1312
      hibi_addr_out              <= (others => '0');
1313
      single_op_re_r             <= '0';
1314
      single_op_on_r             <= '0';
1315
      single_op_data_out_r       <= (others => '0');
1316
      state_r                    <= idle;
1317
      wr_hold_mask               <= '0';
1318
      single_op_hold_mask        <= '0';
1319
 
1320
    elsif clk'event and clk = '1' then  -- rising clock edge
1321
 
1322
      case state_r is
1323
 
1324
        when idle =>
1325
 
1326
          wr_hold_mask        <= '0';
1327
          single_op_hold_mask <= '0';
1328
 
1329
          single_op_re_r <= '0';
1330
 
1331
          if sdram_ctrl_busy_in = '0' then
1332
 
1333
            -- SDRAM controller is ready for new operation
1334
            if next_op(blk_rd_prior_g) = '1' then
1335
 
1336
              -- Start block read
1337
              single_op_on_r <= '0';
1338
 
1339
              -- set curr_wr_port_r to 'illegal' value
1340
              curr_wr_port_r <= num_of_write_ports_g;
1341
 
1342
--              for i in num_of_read_ports_g - 1 downto 0 loop
1343
--                -- which read port's turn?
1344
--                if next_rd_port(i) = '1' then
1345
--                  curr_rd_port_r             <= i;
1346
--                  sdram_ctrl_addr_out        <= r_src_addr_r(i);
1347
--                  sdram_ctrl_data_amount_out <= r_amount_r(i);
1348
--                  hibi_addr_out              <= r_ret_addr_r(i);
1349
--                end if;
1350
--              end loop;  -- rd_port
1351
              sdram_ctrl_addr_out        <= r_src_addr_r(curr_rd_port_r);
1352
              sdram_ctrl_data_amount_out <= r_amount_r(curr_rd_port_r);
1353
              hibi_addr_out              <= r_ret_addr_r(curr_rd_port_r);
1354
 
1355
              -- 17.10.06 HP
1356
              sdram_ctrl_comm_out <= "01";  -- read comm to sdram_controller
1357
              state_r             <= wait_for_block_read_start;
1358
 
1359
            elsif next_op(blk_wr_prior_g) = '1' then
1360
 
1361
              -- Start block write
1362
              single_op_on_r <= '0';
1363
 
1364
              -- set curr_rd_port_r to 'illegal' value
1365
--              curr_rd_port_r <= num_of_read_ports_g;
1366
 
1367
              for i in num_of_write_ports_g - 1 downto 0 loop
1368
                -- which write ports turn?
1369
                if next_wr_port(i) = '1' then
1370
                  curr_wr_port_r             <= i;
1371
                  sdram_ctrl_addr_out        <= w_dst_addr_r(i);
1372
                  sdram_ctrl_data_amount_out <= w_amount_r(i);
1373
                end if;
1374
              end loop;  -- wr_port
1375
 
1376
              sdram_ctrl_comm_out <= "10";  -- write comm to sdram_controller
1377
              state_r             <= wait_for_block_write_start;
1378
 
1379
            elsif next_op(single_op_prior_g) = '1' then
1380
 
1381
              -- start single operation
1382
              single_op_on_r <= '1';
1383
 
1384
              -- set curr_rd_port_r and curr_wr_port_r to 'illegal' values
1385
--              curr_rd_port_r <= num_of_read_ports_g;
1386
              curr_wr_port_r <= num_of_write_ports_g;
1387
 
1388
              single_op_data_out_r <= single_op_data_out;
1389
              sdram_ctrl_addr_out  <= single_op_addr_out;
1390
              sdram_ctrl_data_amount_out <= std_logic_vector(
1391
                to_unsigned(1, sdram_ctrl_data_amount_out'length));
1392
              hibi_addr_out <= single_op_data_out;
1393
 
1394
              if single_op_comm_out = "10" or hibi_full_in = '0' then
1395
 
1396
                -- write operation or hibi not full,
1397
                -- start operation
1398
                sdram_ctrl_comm_out <= single_op_comm_out;
1399
 
1400
              else
1401
                -- read operation and hibi full,
1402
                -- don't start yet
1403
                sdram_ctrl_comm_out <= "00";
1404
              end if;
1405
 
1406
              state_r <= wait_for_single_op_start;
1407
 
1408
            else
1409
 
1410
              -- no valid ports or output fifo full
1411
              -- do nothing
1412
 
1413
              single_op_on_r      <= '0';
1414
              sdram_ctrl_comm_out <= "00";  -- nop
1415
 
1416
              state_r <= idle;
1417
 
1418
            end if;
1419
 
1420
          else
1421
 
1422
            -- sdram controller busy, do nothing
1423
--            curr_rd_port_r      <= curr_rd_port_r;
1424
            curr_wr_port_r      <= curr_wr_port_r;
1425
            single_op_on_r      <= single_op_on_r;
1426
            sdram_ctrl_comm_out <= "00";  -- nop
1427
            state_r             <= idle;
1428
          end if;
1429
 
1430
        when wait_for_block_read_start =>
1431
 
1432
          -- keep read parameters on lines until controller gets to work
1433
          -- (sdram_ctrl_busy_in goes up)
1434
          single_op_on_r             <= '0';
1435
          sdram_ctrl_addr_out        <= r_src_addr_r(curr_rd_port_r);
1436
          sdram_ctrl_data_amount_out <= r_amount_r(curr_rd_port_r);
1437
          hibi_addr_out              <= r_ret_addr_r(curr_rd_port_r);
1438
 
1439
          if sdram_ctrl_busy_in = '0' then
1440
            sdram_ctrl_comm_out <= "01";
1441
            state_r             <= wait_for_block_read_start;
1442
          else
1443
            -- operation started, go to idle
1444
            sdram_ctrl_comm_out <= "00";
1445
            state_r             <= idle;
1446
          end if;
1447
 
1448
        when wait_for_block_write_start =>
1449
 
1450
          -- keep write parameters on lines until controller gets to work
1451
          -- (sdram_ctrl_busy_in goes up)
1452
          single_op_on_r             <= '0';
1453
          sdram_ctrl_addr_out        <= w_dst_addr_r(curr_wr_port_r);
1454
          sdram_ctrl_data_amount_out <= w_amount_r(curr_wr_port_r);
1455
 
1456
          if sdram_ctrl_busy_in = '0' then
1457
            sdram_ctrl_comm_out <= "10";
1458
            state_r             <= wait_for_block_write_start;
1459
          else
1460
            -- operation started, go to idle
1461
            sdram_ctrl_comm_out <= "00";
1462
            wr_hold_mask        <= '1';
1463
            state_r             <= idle;
1464
          end if;
1465
 
1466
        when wait_for_single_op_start =>
1467
 
1468
          single_op_on_r      <= '1';
1469
          hibi_addr_out       <= single_op_data_out;
1470
          sdram_ctrl_addr_out <= single_op_addr_out;
1471
          sdram_ctrl_data_amount_out <= std_logic_vector(
1472
            to_unsigned(1, sdram_ctrl_data_amount_out'length));
1473
 
1474
          if sdram_ctrl_busy_in = '0' then
1475
 
1476
            single_op_re_r <= '0';
1477
 
1478
            -- if hibi_data_out full and single_op_comm is read then we
1479
            -- must wait until hibi is not full
1480
            if single_op_comm_out = "10" or hibi_full_in = '0' then
1481
              sdram_ctrl_comm_out <= single_op_comm_out;
1482
            else
1483
              sdram_ctrl_comm_out <= "00";
1484
            end if;
1485
 
1486
            state_r <= wait_for_single_op_start;
1487
 
1488
          else
1489
            -- operation started, go to idle
1490
            sdram_ctrl_comm_out <= "00";
1491
            single_op_re_r      <= '1';
1492
            single_op_hold_mask <= '1';
1493
            state_r             <= idle;
1494
          end if;
1495
 
1496
        when others =>
1497
          null;
1498
 
1499
      end case;
1500
 
1501
    end if;
1502
 
1503
  end process from_ports_to_controller;
1504
 
1505
  -- purpose: demux sdram controller signals to
1506
  --          read ports
1507
  rd_demux : process (curr_rd_port_r, sdram_ctrl_we_in, single_op_on_r)
1508
  begin  -- process rd_demux
1509
 
1510
    for r in num_of_read_ports_g - 1 downto 0 loop
1511
      if curr_rd_port_r = r and single_op_on_r = '0' then
1512
        sdram_read(r) <= sdram_ctrl_we_in;
1513
      else
1514
        sdram_read(r) <= '0';
1515
      end if;
1516
    end loop;  -- r
1517
 
1518
  end process rd_demux;
1519
 
1520
  -- purpose: demux sdram controller signals to
1521
  --          write ports
1522
  wr_demuxes : process (curr_wr_port_r, sdram_ctrl_re_in,
1523
                        sdram_ctrl_write_on_in)
1524
  begin  -- process wr_demuxes
1525
 
1526
    for w in num_of_write_ports_g - 1 downto 0 loop
1527
      if curr_wr_port_r = w then
1528
        w_re_r(w)      <= sdram_ctrl_re_in;
1529
        sdram_write(w) <= sdram_ctrl_write_on_in;
1530
      else
1531
        w_re_r(w)      <= '0';
1532
        sdram_write(w) <= '0';
1533
      end if;
1534
    end loop;  -- w
1535
 
1536
  end process wr_demuxes;
1537
 
1538
  arbiter_op : sdram_arbiter
1539
    generic map (
1540
      arb_width_g => 3,
1541
      arb_type_g  => op_arb_type_g)
1542
    port map (
1543
      clk       => clk,
1544
      rst_n     => rst_n,
1545
      req_in    => next_op_req,
1546
      hold_in   => next_op_hold,
1547
      grant_out => next_op);
1548
 
1549
  arbiter_rd : sdram_arbiter
1550
    generic map (
1551
      arb_width_g => num_of_read_ports_g,
1552
      arb_type_g  => port_arb_type_g)
1553
    port map (
1554
      clk       => clk,
1555
      rst_n     => rst_n,
1556
      req_in    => r_port_req,
1557
      hold_in   => r_port_hold,
1558
      grant_out => next_rd_port);
1559
 
1560
  arbiter_wr : sdram_arbiter
1561
    generic map (
1562
      arb_width_g => num_of_write_ports_g,
1563
      arb_type_g  => port_arb_type_g)
1564
    port map (
1565
      clk       => clk,
1566
      rst_n     => rst_n,
1567
      req_in    => w_port_req,
1568
      hold_in   => w_port_hold,
1569
      grant_out => next_wr_port);
1570
 
1571
  gen_write_ports : for i in num_of_write_ports_g - 1 downto 0 generate
1572
    wr_port_1 : sdram_wr_port
1573
      generic map (
1574
        fifo_depth_g    => input_fifo_depth_g,
1575
        amountw_g       => amountw_g,
1576
        hibi_dataw_g    => hibi_data_width_g,
1577
        block_overlap_g => block_overlap_g,
1578
        offsetw_g       => offset_width_g,
1579
        mem_dataw_g     => mem_data_width_g,
1580
        mem_addrw_g     => mem_addr_width_g)
1581
      port map (
1582
        clk            => clk,
1583
        rst_n          => rst_n,
1584
        conf_we_in     => conf_wr_r(i),
1585
        conf_data_in   => conf_data_r,
1586
        write_in       => sdram_write(i),
1587
        reserve_in     => w_reserve(i),
1588
        valid_out      => w_valid_r(i),
1589
        reserved_out   => w_reserved_r(i),
1590
        end_addr_out   => w_end_addr_r(i),
1591
        dst_addr_out   => w_dst_addr_r(i),
1592
        amount_out     => w_amount_r(i),
1593
        fifo_we_in     => w_we_r(i),
1594
        fifo_re_in     => w_re_r(i),
1595
        fifo_data_in   => data_to_fifos_r,
1596
        fifo_full_out  => w_full(i),
1597
        fifo_empty_out => w_empty(i),
1598
        fifo_one_p_out => w_one_p_left(i),
1599
        fifo_one_d_out => w_one_d_left(i),
1600
        fifo_data_out  => w_data_out(i),
1601
        error_out      => open);
1602
  end generate gen_write_ports;
1603
 
1604
  gen_read_ports : for i in num_of_read_ports_g - 1 downto 0 generate
1605
    rd_port_1 : sdram_rd_port
1606
      generic map (
1607
        amountw_g       => amountw_g,
1608
        hibi_dataw_g    => hibi_data_width_g,
1609
        block_overlap_g => block_overlap_g,
1610
        offsetw_g       => offset_width_g,
1611
        mem_dataw_g     => mem_data_width_g,
1612
        mem_addrw_g     => mem_addr_width_g)
1613
      port map (
1614
        clk          => clk,
1615
        rst_n        => rst_n,
1616
        conf_we_in   => conf_rd_r(i),
1617
        conf_data_in => conf_data_r,
1618
        read_in      => sdram_read(i),
1619
        reserve_in   => r_reserve(i),
1620
        valid_out    => r_valid_r(i),
1621
        reserved_out => r_reserved_r(i),
1622
        end_addr_out => r_end_addr_r(i),
1623
        src_addr_out => r_src_addr_r(i),
1624
        amount_out   => r_amount_r(i),
1625
        ret_addr_out => r_ret_addr_r(i),
1626
        finish_out   => r_finish_r(i),
1627
        error_out    => open);
1628
  end generate gen_read_ports;
1629
 
1630
  -- fifo for blocking read requests(blocking)
1631
  gen_rq_fifos : if rq_fifo_depth_g /= 0 generate
1632
 
1633
    rd_rq_fifo : fifo
1634
      generic map (
1635
        data_width_g => hibi_data_width_g,
1636
        depth_g      => rq_fifo_depth_g
1637
        )
1638
      port map (
1639
        clk       => clk,
1640
        rst_n     => rst_n,
1641
        data_in   => rd_rq_in_r,        --hibi_msg_data_in,
1642
        we_in     => rd_rq_we_r,
1643
        one_p_out => open,
1644
        full_out  => rd_rq_full,
1645
        data_out  => rd_rq,
1646
        re_in     => rd_rq_re,
1647
        empty_out => rd_rq_empty,
1648
        one_d_out => open
1649
        );
1650
 
1651
    -- fifo for blocking write requests
1652
    wr_rq_fifo : fifo
1653
      generic map (
1654
        data_width_g => hibi_data_width_g,
1655
        depth_g      => rq_fifo_depth_g
1656
        )
1657
      port map (
1658
        clk       => clk,
1659
        rst_n     => rst_n,
1660
        data_in   => wr_rq_in_r,        --hibi_msg_data_in,
1661
        we_in     => wr_rq_we_r,
1662
        one_p_out => open,
1663
        full_out  => wr_rq_full,
1664
        data_out  => wr_rq,
1665
        re_in     => wr_rq_re,
1666
        empty_out => wr_rq_empty,
1667
        one_d_out => open
1668
        );
1669
    zero_fifo : fifo
1670
      generic map (
1671
        data_width_g => hibi_data_width_g,
1672
        depth_g      => 1
1673
        )
1674
      port map (
1675
        clk       => clk,
1676
        rst_n     => rst_n,
1677
        data_in   => zero_in_r,         --hibi_msg_data_in,
1678
        we_in     => zero_we_r,
1679
        one_p_out => open,
1680
        full_out  => zero_full,
1681
        data_out  => zero_out_r,
1682
        re_in     => zero_re,
1683
        empty_out => zero_empty,
1684
        one_d_out => open
1685
        );
1686
 
1687
  end generate gen_rq_fifos;
1688
 
1689
  -- fifo for storing operations of length 1 and don't have their own port
1690
  single_operations_fifo : fifo
1691
    generic map (
1692
      data_width_g => 2 + hibi_data_width_g + hibi_data_width_g,
1693
      depth_g      => input_fifo_depth_g
1694
      )
1695
    port map (
1696
      clk       => clk,
1697
      rst_n     => rst_n,
1698
      data_in   => single_op_in,
1699
      we_in     => single_op_we_r,
1700
      one_p_out => single_op_one_p_left,
1701
      full_out  => single_op_full,
1702
      data_out  => single_op_out,
1703
      re_in     => single_op_re_r,
1704
      empty_out => single_op_empty,
1705
      one_d_out => single_op_one_d_left
1706
      );
1707
 
1708
end rtl;

powered by: WebSVN 2.1.0

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