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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [rtl/] [core/] [neorv32_slink.vhd] - Blame information for rev 74

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 61 zero_gravi
-- #################################################################################################
2
-- # << NEORV32 - Stream Link Interface (SLINK) >>                                                 #
3
-- # ********************************************************************************************* #
4 62 zero_gravi
-- # Up to 8 input (RX) and up to 8 output (TX) stream links are supported. Each link provides an  #
5
-- # internal FIFO for buffering. Each stream direction provides a global interrupt to indicate    #
6
-- # that a RX link has received new data or that a TX link has finished sending data              #
7
-- # (if FIFO_DEPTH = 1) OR if RX/TX link FIFO has become half full (if FIFO_DEPTH > 1).           #
8 61 zero_gravi
-- # ********************************************************************************************* #
9
-- # BSD 3-Clause License                                                                          #
10
-- #                                                                                               #
11 74 zero_gravi
-- # Copyright (c) 2022, Stephan Nolting. All rights reserved.                                     #
12 61 zero_gravi
-- #                                                                                               #
13
-- # Redistribution and use in source and binary forms, with or without modification, are          #
14
-- # permitted provided that the following conditions are met:                                     #
15
-- #                                                                                               #
16
-- # 1. Redistributions of source code must retain the above copyright notice, this list of        #
17
-- #    conditions and the following disclaimer.                                                   #
18
-- #                                                                                               #
19
-- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of     #
20
-- #    conditions and the following disclaimer in the documentation and/or other materials        #
21
-- #    provided with the distribution.                                                            #
22
-- #                                                                                               #
23
-- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to  #
24
-- #    endorse or promote products derived from this software without specific prior written      #
25
-- #    permission.                                                                                #
26
-- #                                                                                               #
27
-- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS   #
28
-- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF               #
29
-- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE    #
30
-- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     #
31
-- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
32
-- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    #
33
-- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     #
34
-- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  #
35
-- # OF THE POSSIBILITY OF SUCH DAMAGE.                                                            #
36
-- # ********************************************************************************************* #
37
-- # The NEORV32 Processor - https://github.com/stnolting/neorv32              (c) Stephan Nolting #
38
-- #################################################################################################
39
 
40
library ieee;
41
use ieee.std_logic_1164.all;
42
use ieee.numeric_std.all;
43
 
44
library neorv32;
45
use neorv32.neorv32_package.all;
46
 
47
entity neorv32_slink is
48
  generic (
49 62 zero_gravi
    SLINK_NUM_TX  : natural; -- number of TX links (0..8)
50
    SLINK_NUM_RX  : natural; -- number of TX links (0..8)
51
    SLINK_TX_FIFO : natural; -- TX fifo depth, has to be a power of two
52
    SLINK_RX_FIFO : natural  -- RX fifo depth, has to be a power of two
53 61 zero_gravi
  );
54
  port (
55
    -- host access --
56
    clk_i          : in  std_ulogic; -- global clock line
57
    addr_i         : in  std_ulogic_vector(31 downto 0); -- address
58
    rden_i         : in  std_ulogic; -- read enable
59
    wren_i         : in  std_ulogic; -- write enable
60
    data_i         : in  std_ulogic_vector(31 downto 0); -- data in
61
    data_o         : out std_ulogic_vector(31 downto 0); -- data out
62
    ack_o          : out std_ulogic; -- transfer acknowledge
63
    -- interrupt --
64
    irq_tx_o       : out std_ulogic; -- transmission done
65
    irq_rx_o       : out std_ulogic; -- data received
66
    -- TX stream interfaces --
67
    slink_tx_dat_o : out sdata_8x32_t; -- output data
68
    slink_tx_val_o : out std_ulogic_vector(7 downto 0); -- valid output
69
    slink_tx_rdy_i : in  std_ulogic_vector(7 downto 0); -- ready to send
70
    -- RX stream interfaces --
71
    slink_rx_dat_i : in  sdata_8x32_t; -- input data
72
    slink_rx_val_i : in  std_ulogic_vector(7 downto 0); -- valid input
73
    slink_rx_rdy_o : out std_ulogic_vector(7 downto 0)  -- ready to receive
74
  );
75
end neorv32_slink;
76
 
77
architecture neorv32_slink_rtl of neorv32_slink is
78
 
79
  -- IO space: module base address --
80
  constant hi_abb_c : natural := index_size_f(io_size_c)-1; -- high address boundary bit
81
  constant lo_abb_c : natural := index_size_f(slink_size_c); -- low address boundary bit
82
 
83 62 zero_gravi
  -- control register bits --
84
  constant ctrl_rx_num_lsb_c  : natural :=  0; -- r/-: number of implemented RX links
85
  constant ctrl_rx_num_msb_c  : natural :=  3;
86 61 zero_gravi
  --
87 62 zero_gravi
  constant ctrl_tx_num_lsb_c  : natural :=  4; -- r/-: number of implemented TX links
88
  constant ctrl_tx_num_msb_c  : natural :=  7;
89 61 zero_gravi
  --
90 62 zero_gravi
  constant ctrl_rx_size_lsb_c : natural :=  8; -- r/-: log2(RX FIFO size)
91
  constant ctrl_rx_size_msb_c : natural := 11;
92 61 zero_gravi
  --
93 62 zero_gravi
  constant ctrl_tx_size_lsb_c : natural := 12; -- r/-: log2(TX FIFO size)
94
  constant ctrl_tx_size_msb_c : natural := 15;
95 61 zero_gravi
  --
96 62 zero_gravi
  constant ctrl_en_c          : natural := 31; -- r/w: global enable
97 61 zero_gravi
 
98 65 zero_gravi
  -- interrupt configuration register bits --
99
  constant irq_rx_en_lsb_c   : natural :=  0; -- r/w: enable RX interrupt for link 0..7
100
  constant irq_rx_en_msb_c   : natural :=  7;
101
  --
102
  constant irq_rx_mode_lsb_c : natural :=  8; -- r/w: RX IRQ mode: 0=FIFO at least half-full; 1=FIFO not empty
103
  constant irq_rx_mode_msb_c : natural := 15;
104
  --
105
  constant irq_tx_en_lsb_c   : natural := 16; -- r/w: enable TX interrupt for link 0..7
106
  constant irq_tx_en_msb_c   : natural := 23;
107
  --
108
  constant irq_tx_mode_lsb_c : natural := 24; -- r/w: TX IRQ mode: 0=FIFO less than half-full; 1=FIFO not full
109
  constant irq_tx_mode_msb_c : natural := 31;
110
 
111 62 zero_gravi
  -- status register bits --
112 65 zero_gravi
  constant status_rx_avail_lsb_c : natural :=  0; -- r/-: set if RX link 0..7 FIFO is NOT empty
113 62 zero_gravi
  constant status_rx_avail_msb_c : natural :=  7;
114
  --
115 65 zero_gravi
  constant status_tx_free_lsb_c  : natural :=  8; -- r/-: set if TX link 0..7 FIFO is NOT full
116 62 zero_gravi
  constant status_tx_free_msb_c  : natural := 15;
117
  --
118 65 zero_gravi
  constant status_rx_half_lsb_c  : natural := 16; -- r/-: set if RX link 0..7 FIFO fill-level is >= half-full
119 62 zero_gravi
  constant status_rx_half_msb_c  : natural := 23;
120
  --
121 65 zero_gravi
  constant status_tx_half_lsb_c  : natural := 24; -- r/-: set if TX link 0..7 FIFO fill-level is > half-full
122 62 zero_gravi
  constant status_tx_half_msb_c  : natural := 31;
123
 
124 61 zero_gravi
  -- bus access control --
125
  signal ack_read  : std_ulogic;
126
  signal ack_write : std_ulogic;
127
  signal acc_en    : std_ulogic;
128
  signal addr      : std_ulogic_vector(31 downto 0);
129 68 zero_gravi
  signal wren      : std_ulogic; -- word write enable
130
  signal rden      : std_ulogic; -- read enable
131 61 zero_gravi
 
132
  -- control register --
133
  signal enable : std_ulogic; -- global enable
134
 
135 65 zero_gravi
  -- IRQ configuration register --
136
  signal irq_rx_en   : std_ulogic_vector(7 downto 0);
137
  signal irq_rx_mode : std_ulogic_vector(7 downto 0);
138
  signal irq_tx_en   : std_ulogic_vector(7 downto 0);
139
  signal irq_tx_mode : std_ulogic_vector(7 downto 0);
140
 
141 61 zero_gravi
  -- stream link fifo interface --
142
  type fifo_data_t is array (0 to 7) of std_ulogic_vector(31 downto 0);
143 65 zero_gravi
  signal rx_fifo_rdata : fifo_data_t;
144
  signal fifo_clear    : std_ulogic;
145
  signal link_sel      : std_ulogic_vector(7 downto 0);
146
  signal tx_fifo_we    : std_ulogic_vector(7 downto 0);
147
  signal rx_fifo_re    : std_ulogic_vector(7 downto 0);
148
  signal rx_fifo_avail : std_ulogic_vector(7 downto 0);
149
  signal tx_fifo_free  : std_ulogic_vector(7 downto 0);
150
  signal rx_fifo_half  : std_ulogic_vector(7 downto 0);
151
  signal tx_fifo_half  : std_ulogic_vector(7 downto 0);
152 61 zero_gravi
 
153 68 zero_gravi
  -- interrupt generator --
154
  type detect_t is array (0 to 7) of std_ulogic_vector(1 downto 0);
155
  type irq_t is record
156
    detect  : detect_t; -- rising-edge detector
157
    trigger : std_ulogic_vector(7 downto 0);
158
    set     : std_ulogic_vector(7 downto 0);
159
  end record;
160
  signal rx_irq, tx_irq : irq_t;
161
 
162 61 zero_gravi
begin
163
 
164
  -- Sanity Checks --------------------------------------------------------------------------
165
  -- -------------------------------------------------------------------------------------------
166
  assert not (is_power_of_two_f(SLINK_TX_FIFO) = false) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_TX_FIFO> has to be a power of two." severity error;
167
  assert not (SLINK_TX_FIFO > 2**15) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_TX_FIFO> has to be 1..32768." severity error;
168
  --
169
  assert not (is_power_of_two_f(SLINK_RX_FIFO) = false) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_RX_FIFO> has to be a power of two." severity error;
170
  assert not (SLINK_RX_FIFO > 2**15) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_RX_FIFO> has to be 1..32768." severity error;
171
  --
172
  assert not (SLINK_NUM_RX > 8) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_NUM_RX> has to be 0..8." severity error;
173
  assert not (SLINK_NUM_TX > 8) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_NUM_TX> has to be 0..8." severity error;
174
  --
175
  assert false report "NEORV32 PROCESSOR CONFIG NOTE: Implementing " & integer'image(SLINK_NUM_RX) & " RX and " &
176
  integer'image(SLINK_NUM_TX) & " TX stream links." severity note;
177
 
178
 
179
  -- Access Control -------------------------------------------------------------------------
180
  -- -------------------------------------------------------------------------------------------
181
  acc_en <= '1' when (addr_i(hi_abb_c downto lo_abb_c) = slink_base_c(hi_abb_c downto lo_abb_c)) else '0';
182
  addr   <= slink_base_c(31 downto lo_abb_c) & addr_i(lo_abb_c-1 downto 2) & "00"; -- word aligned
183 68 zero_gravi
  wren   <= acc_en and wren_i;
184
  rden   <= acc_en and rden_i;
185 61 zero_gravi
 
186
 
187
  -- Read/Write Access ----------------------------------------------------------------------
188
  -- -------------------------------------------------------------------------------------------
189
  rw_access: process(clk_i)
190
  begin
191
    if rising_edge(clk_i) then
192
      -- write access --
193 65 zero_gravi
      ack_write <= '0';
194 68 zero_gravi
      if (wren = '1') then
195 65 zero_gravi
        if (addr(5) = '0') then -- control/status/irq
196
          if (addr(4 downto 3) = "00") then -- control register
197 62 zero_gravi
            enable <= data_i(ctrl_en_c);
198
          end if;
199 65 zero_gravi
          if (addr(4 downto 3) = "01") then -- IRQ configuration register
200
            for i in 0 to SLINK_NUM_RX-1 loop
201
              irq_rx_en(i)   <= data_i(i + irq_rx_en_lsb_c);
202
              irq_rx_mode(i) <= data_i(i + irq_rx_mode_lsb_c);
203
            end loop;
204
            for i in 0 to SLINK_NUM_TX-1 loop
205
              irq_tx_en(i)   <= data_i(i + irq_tx_en_lsb_c);
206
              irq_tx_mode(i) <= data_i(i + irq_tx_mode_lsb_c);
207
            end loop;
208
          end if;
209 61 zero_gravi
          ack_write <= '1';
210
        else -- TX links
211 74 zero_gravi
          if (or_reduce_f(link_sel and tx_fifo_free) = '1') then
212
            ack_write <= '1';
213
          end if;
214 61 zero_gravi
        end if;
215
      end if;
216
 
217
      -- read access --
218 65 zero_gravi
      data_o   <= (others => '0');
219
      ack_read <= '0';
220 68 zero_gravi
      if (rden = '1') then
221 62 zero_gravi
        if (addr(5) = '0') then -- control/status registers
222 61 zero_gravi
          ack_read <= '1';
223 65 zero_gravi
          case addr(4 downto 3) is
224
            when "00" => -- control register
225
              data_o(ctrl_rx_num_msb_c  downto ctrl_rx_num_lsb_c)  <= std_ulogic_vector(to_unsigned(SLINK_NUM_RX, 4));
226
              data_o(ctrl_tx_num_msb_c  downto ctrl_tx_num_lsb_c)  <= std_ulogic_vector(to_unsigned(SLINK_NUM_TX, 4));
227
              data_o(ctrl_rx_size_msb_c downto ctrl_rx_size_lsb_c) <= std_ulogic_vector(to_unsigned(index_size_f(SLINK_RX_FIFO), 4));
228
              data_o(ctrl_tx_size_msb_c downto ctrl_tx_size_lsb_c) <= std_ulogic_vector(to_unsigned(index_size_f(SLINK_TX_FIFO), 4));
229
              data_o(ctrl_en_c)                                    <= enable;
230
            when "01" => -- IRQ configuration register
231
              for i in 0 to SLINK_NUM_RX-1 loop
232
                data_o(irq_rx_en_lsb_c   + i) <= irq_rx_en(i);
233
                data_o(irq_rx_mode_lsb_c + i) <= irq_rx_mode(i) or bool_to_ulogic_f(boolean(SLINK_RX_FIFO = 1)); -- tie to one if SLINK_RX_FIFO is 1
234
              end loop;
235
              for i in 0 to SLINK_NUM_TX-1 loop
236
                data_o(irq_tx_en_lsb_c   + i) <= irq_tx_en(i);
237
                data_o(irq_tx_mode_lsb_c + i) <= irq_tx_mode(i) or bool_to_ulogic_f(boolean(SLINK_TX_FIFO = 1)); -- tie to one if SLINK_TX_FIFO is 1
238
              end loop;
239
            when "10" | "11" => -- fifo status register
240
              data_o(status_rx_avail_msb_c downto status_rx_avail_lsb_c) <= rx_fifo_avail;
241
              data_o(status_tx_free_msb_c  downto status_tx_free_lsb_c)  <= tx_fifo_free;
242
              data_o(status_rx_half_msb_c  downto status_rx_half_lsb_c)  <= rx_fifo_half;
243
              data_o(status_tx_half_msb_c  downto status_tx_half_lsb_c)  <= tx_fifo_half;
244
            when others =>
245
              data_o <= (others => '0');
246
          end case;
247 61 zero_gravi
        else -- RX links
248 74 zero_gravi
          data_o <= rx_fifo_rdata(to_integer(unsigned(addr(4 downto 2))));
249
          if (or_reduce_f(link_sel and rx_fifo_avail) = '1') then
250
            ack_read <= '1';
251
          end if;
252 61 zero_gravi
        end if;
253
      end if;
254
    end if;
255
  end process rw_access;
256
 
257
  -- bus access acknowledge --
258
  ack_o <= ack_write or ack_read;
259
 
260
  -- link fifo reset (sync) --
261
  fifo_clear <= not enable;
262
 
263
 
264
  -- Interrupt Generator --------------------------------------------------------------------
265
  -- -------------------------------------------------------------------------------------------
266 69 zero_gravi
  -- interrupt trigger type / condition --
267
  irq_type: process(irq_rx_mode, rx_fifo_avail, rx_fifo_half, irq_tx_mode, tx_fifo_free, tx_fifo_half, tx_fifo_we)
268 61 zero_gravi
  begin
269 68 zero_gravi
    -- RX interrupt --
270
    rx_irq.trigger <= (others => '0');
271
    for i in 0 to SLINK_NUM_RX-1 loop
272 69 zero_gravi
      if (SLINK_RX_FIFO = 1) or (irq_rx_mode(i) = '0') then
273
        rx_irq.trigger(i) <= rx_fifo_avail(i); -- fire if any RX_FIFO is not empty (= data available)
274 62 zero_gravi
      else
275 69 zero_gravi
        rx_irq.trigger(i) <= rx_fifo_half(i);
276 68 zero_gravi
      end if;
277
    end loop;
278
    -- TX interrupt --
279
    tx_irq.trigger <= (others => '0');
280
    for i in 0 to SLINK_NUM_TX-1 loop
281 69 zero_gravi
      if (SLINK_TX_FIFO = 1) or (irq_tx_mode(i) = '0') then
282
        tx_irq.trigger(i) <= tx_fifo_free(i) and tx_fifo_we(i); -- fire if any TX_FIFO is not full (= free buffer space available)
283 68 zero_gravi
      else
284 69 zero_gravi
        tx_irq.trigger(i) <= not tx_fifo_half(i);
285 68 zero_gravi
      end if;
286
    end loop;
287
  end process irq_type;
288 65 zero_gravi
 
289 69 zero_gravi
  -- edge detector - sync --
290
  irq_edge_detect_sync: process(clk_i)
291 68 zero_gravi
  begin
292
    if rising_edge(clk_i) then
293
      -- RX --
294 69 zero_gravi
      for i in 0 to SLINK_NUM_RX-1 loop
295
        if (enable = '1') and (irq_rx_en(i) = '1') then
296 68 zero_gravi
          rx_irq.detect(i) <= rx_irq.detect(i)(0) & rx_irq.trigger(i);
297 69 zero_gravi
        else
298
          rx_irq.detect(i) <= "00";
299
        end if;
300
      end loop;
301 68 zero_gravi
      -- TX --
302 69 zero_gravi
      for i in 0 to SLINK_NUM_TX-1 loop
303
        if (enable = '1') and (irq_tx_en(i) = '1') then
304 68 zero_gravi
          tx_irq.detect(i) <= tx_irq.detect(i)(0) & tx_irq.trigger(i);
305 69 zero_gravi
        else
306
          tx_irq.detect(i) <= "00";
307
        end if;
308
      end loop;
309 68 zero_gravi
    end if;
310 69 zero_gravi
  end process irq_edge_detect_sync;
311 68 zero_gravi
 
312 69 zero_gravi
  -- edge detector - sync --
313
  irq_edge_detect_comb: process(rx_irq, irq_rx_en, tx_irq, irq_tx_en)
314 68 zero_gravi
  begin
315
    -- RX --
316
    rx_irq.set <= (others => '0');
317
    for i in 0 to SLINK_NUM_RX-1 loop
318 69 zero_gravi
      if (rx_irq.detect(i) = "01") then -- rising-edge
319 68 zero_gravi
        rx_irq.set(i) <= '1';
320
      end if;
321
    end loop;
322
    -- TX --
323
    tx_irq.set <= (others => '0');
324
    for i in 0 to SLINK_NUM_TX-1 loop
325 69 zero_gravi
      if (tx_irq.detect(i) = "01") then -- rising-edge
326 68 zero_gravi
        tx_irq.set(i) <= '1';
327
      end if;
328
    end loop;
329 69 zero_gravi
  end process irq_edge_detect_comb;
330 68 zero_gravi
 
331
  -- interrupt arbiter --
332
  irq_generator: process(clk_i)
333
  begin
334
    if rising_edge(clk_i) then
335 74 zero_gravi
      irq_rx_o <= '0';
336
      irq_tx_o <= '0';
337
      if (or_reduce_f(rx_irq.set) = '1') then
338
        irq_rx_o <= '1';
339
      end if;
340
      if (or_reduce_f(tx_irq.set) = '1') then
341
        irq_tx_o <= '1';
342
      end if;
343 61 zero_gravi
    end if;
344 68 zero_gravi
  end process irq_generator;
345 61 zero_gravi
 
346
 
347
  -- Link Select ----------------------------------------------------------------------------
348
  -- -------------------------------------------------------------------------------------------
349
  link_select: process(addr)
350
  begin
351
    case addr(5 downto 2) is -- MSB = data fifo access at all?
352
      when "1000" => link_sel <= "00000001";
353
      when "1001" => link_sel <= "00000010";
354
      when "1010" => link_sel <= "00000100";
355
      when "1011" => link_sel <= "00001000";
356
      when "1100" => link_sel <= "00010000";
357
      when "1101" => link_sel <= "00100000";
358
      when "1110" => link_sel <= "01000000";
359
      when "1111" => link_sel <= "10000000";
360
      when others => link_sel <= "00000000";
361
    end case;
362
  end process link_select;
363
 
364
  fifo_access_gen:
365
  for i in 0 to 7 generate
366 68 zero_gravi
    tx_fifo_we(i) <= link_sel(i) and wren;
367
    rx_fifo_re(i) <= link_sel(i) and rden;
368 61 zero_gravi
  end generate;
369
 
370
 
371
  -- TX Link FIFOs --------------------------------------------------------------------------
372
  -- -------------------------------------------------------------------------------------------
373
  transmit_fifo_gen:
374
  for i in 0 to SLINK_NUM_TX-1 generate
375
    transmit_fifo_inst: neorv32_fifo
376
    generic map (
377
      FIFO_DEPTH => SLINK_TX_FIFO, -- number of fifo entries; has to be a power of two; min 1
378
      FIFO_WIDTH => 32,            -- size of data elements in fifo
379 65 zero_gravi
      FIFO_RSYNC => false,         -- async read
380
      FIFO_SAFE  => true           -- safe access
381 61 zero_gravi
    )
382
    port map (
383
      -- control --
384
      clk_i   => clk_i,             -- clock, rising edge
385
      rstn_i  => '1',               -- async reset, low-active
386
      clear_i => fifo_clear,        -- sync reset, high-active
387 65 zero_gravi
      level_o => open,              -- fill level
388
      half_o  => tx_fifo_half(i),   -- FIFO is at least half full
389 61 zero_gravi
      -- write port --
390
      wdata_i => data_i,            -- write data
391
      we_i    => tx_fifo_we(i),     -- write enable
392
      free_o  => tx_fifo_free(i),   -- at least one entry is free when set
393
      -- read port --
394
      re_i    => slink_tx_rdy_i(i), -- read enable
395
      rdata_o => slink_tx_dat_o(i), -- read data
396
      avail_o => slink_tx_val_o(i)  -- data available when set
397
    );
398
  end generate;
399
 
400
  -- terminate unimplemented links --
401
  transmit_fifo_gen_terminate:
402
  for i in SLINK_NUM_TX to 7 generate
403
    tx_fifo_free(i)   <= '0';
404
    slink_tx_dat_o(i) <= (others => '0');
405
    slink_tx_val_o(i) <= '0';
406 65 zero_gravi
    tx_fifo_half(i)   <= '0';
407 61 zero_gravi
  end generate;
408
 
409
 
410
  -- RX Link FIFOs --------------------------------------------------------------------------
411
  -- -------------------------------------------------------------------------------------------
412
  receive_fifo_gen:
413
  for i in 0 to SLINK_NUM_RX-1 generate
414
    receive_fifo_inst: neorv32_fifo
415
    generic map (
416
      FIFO_DEPTH => SLINK_RX_FIFO, -- number of fifo entries; has to be a power of two; min 1
417
      FIFO_WIDTH => 32,            -- size of data elements in fifo
418 65 zero_gravi
      FIFO_RSYNC => false,         -- async read
419
      FIFO_SAFE  => true           -- safe access
420 61 zero_gravi
    )
421
    port map (
422
      -- control --
423
      clk_i   => clk_i,             -- clock, rising edge
424
      rstn_i  => '1',               -- async reset, low-active
425
      clear_i => fifo_clear,        -- sync reset, high-active
426 65 zero_gravi
      level_o => open,              -- fill level
427
      half_o  => rx_fifo_half(i),   -- FIFO is at least half full
428 61 zero_gravi
      -- write port --
429
      wdata_i => slink_rx_dat_i(i), -- write data
430
      we_i    => slink_rx_val_i(i), -- write enable
431
      free_o  => slink_rx_rdy_o(i), -- at least one entry is free when set
432
      -- read port --
433
      re_i    => rx_fifo_re(i),     -- read enable
434
      rdata_o => rx_fifo_rdata(i),  -- read data
435
      avail_o => rx_fifo_avail(i)   -- data available when set
436
    );
437
  end generate;
438
 
439
  -- terminate unimplemented links --
440
  receive_fifo_gen_terminate:
441
  for i in SLINK_NUM_RX to 7 generate
442
    rx_fifo_avail(i)  <= '0';
443
    slink_rx_rdy_o(i) <= '0';
444
    rx_fifo_rdata(i)  <= (others => '0');
445 65 zero_gravi
    rx_fifo_half(i)   <= '0';
446 61 zero_gravi
  end generate;
447
 
448
 
449
end neorv32_slink_rtl;

powered by: WebSVN 2.1.0

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