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

Subversion Repositories neorv32

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

Go to most recent revision | 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
-- # Copyright (c) 2021, Stephan Nolting. All rights reserved.                                     #
12
-- #                                                                                               #
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
    pending : std_ulogic; -- pending interrupt request
157
    detect  : detect_t; -- rising-edge detector
158
    trigger : std_ulogic_vector(7 downto 0);
159
    set     : std_ulogic_vector(7 downto 0);
160
    clr     : std_ulogic;
161
  end record;
162
  signal rx_irq, tx_irq : irq_t;
163
 
164 61 zero_gravi
begin
165
 
166
  -- Sanity Checks --------------------------------------------------------------------------
167
  -- -------------------------------------------------------------------------------------------
168
  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;
169
  assert not (SLINK_TX_FIFO > 2**15) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_TX_FIFO> has to be 1..32768." severity error;
170
  --
171
  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;
172
  assert not (SLINK_RX_FIFO > 2**15) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_RX_FIFO> has to be 1..32768." severity error;
173
  --
174
  assert not (SLINK_NUM_RX > 8) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_NUM_RX> has to be 0..8." severity error;
175
  assert not (SLINK_NUM_TX > 8) report "NEORV32 PROCESSOR CONFIG ERROR: SLINK <SLINK_NUM_TX> has to be 0..8." severity error;
176
  --
177
  assert false report "NEORV32 PROCESSOR CONFIG NOTE: Implementing " & integer'image(SLINK_NUM_RX) & " RX and " &
178
  integer'image(SLINK_NUM_TX) & " TX stream links." severity note;
179
 
180
 
181
  -- Access Control -------------------------------------------------------------------------
182
  -- -------------------------------------------------------------------------------------------
183
  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';
184
  addr   <= slink_base_c(31 downto lo_abb_c) & addr_i(lo_abb_c-1 downto 2) & "00"; -- word aligned
185 68 zero_gravi
  wren   <= acc_en and wren_i;
186
  rden   <= acc_en and rden_i;
187 61 zero_gravi
 
188
 
189
  -- Read/Write Access ----------------------------------------------------------------------
190
  -- -------------------------------------------------------------------------------------------
191
  rw_access: process(clk_i)
192
  begin
193
    if rising_edge(clk_i) then
194
      -- write access --
195 65 zero_gravi
      ack_write <= '0';
196 68 zero_gravi
      if (wren = '1') then
197 65 zero_gravi
        if (addr(5) = '0') then -- control/status/irq
198
          if (addr(4 downto 3) = "00") then -- control register
199 62 zero_gravi
            enable <= data_i(ctrl_en_c);
200
          end if;
201 65 zero_gravi
          if (addr(4 downto 3) = "01") then -- IRQ configuration register
202
            for i in 0 to SLINK_NUM_RX-1 loop
203
              irq_rx_en(i)   <= data_i(i + irq_rx_en_lsb_c);
204
              irq_rx_mode(i) <= data_i(i + irq_rx_mode_lsb_c);
205
            end loop;
206
            for i in 0 to SLINK_NUM_TX-1 loop
207
              irq_tx_en(i)   <= data_i(i + irq_tx_en_lsb_c);
208
              irq_tx_mode(i) <= data_i(i + irq_tx_mode_lsb_c);
209
            end loop;
210
          end if;
211 61 zero_gravi
          ack_write <= '1';
212
        else -- TX links
213
          ack_write <= or_reduce_f(link_sel and tx_fifo_free);
214
        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
          data_o   <= rx_fifo_rdata(to_integer(unsigned(addr(4 downto 2))));
249
          ack_read <= or_reduce_f(link_sel and rx_fifo_avail);
250
        end if;
251
      end if;
252
    end if;
253
  end process rw_access;
254
 
255
  -- bus access acknowledge --
256
  ack_o <= ack_write or ack_read;
257
 
258
  -- link fifo reset (sync) --
259
  fifo_clear <= not enable;
260
 
261
 
262
  -- Interrupt Generator --------------------------------------------------------------------
263
  -- -------------------------------------------------------------------------------------------
264 68 zero_gravi
  irq_type: process(irq_rx_mode, rx_fifo_avail, rx_fifo_half,
265
                    irq_tx_mode, tx_fifo_free,  tx_fifo_half)
266 61 zero_gravi
  begin
267 68 zero_gravi
    -- RX interrupt --
268
    rx_irq.trigger <= (others => '0');
269
    for i in 0 to SLINK_NUM_RX-1 loop
270
      if (SLINK_RX_FIFO = 1) then
271
        rx_irq.trigger(i) <= rx_fifo_avail(i); -- fire if any RX_FIFO is not empty
272 62 zero_gravi
      else
273 68 zero_gravi
        if (irq_rx_mode(i) = '0') then -- fire if any RX_FIFO is at least half-full
274
          rx_irq.trigger(i) <= rx_fifo_half(i);
275
        else -- fire if any RX_FIFO is not empty (= data available)
276
          rx_irq.trigger(i) <= rx_fifo_avail(i);
277 62 zero_gravi
        end if;
278 68 zero_gravi
      end if;
279
    end loop;
280
    -- TX interrupt --
281
    tx_irq.trigger <= (others => '0');
282
    for i in 0 to SLINK_NUM_TX-1 loop
283
      if (SLINK_TX_FIFO = 1) then
284
        tx_irq.trigger(i) <= tx_fifo_free(i); -- fire if any TX_FIFO is not full
285
      else
286
        if (irq_tx_mode(i) = '0') then -- fire if any TX_FIFO is less than half-full
287
          tx_irq.trigger(i) <= not tx_fifo_half(i);
288
        else -- fire if any TX_FIFO is not full (= free buffer space available)
289
          tx_irq.trigger(i) <= tx_fifo_free(i);
290
        end if;
291
      end if;
292
    end loop;
293
  end process irq_type;
294 65 zero_gravi
 
295 68 zero_gravi
  -- interrupt trigger --
296
  irq_trigger_sync: process(clk_i)
297
  begin
298
    if rising_edge(clk_i) then
299
      -- RX --
300
      rx_irq.detect <= (others => (others => '0')); -- default
301
      if (enable = '1') then
302
        for i in 0 to SLINK_NUM_RX-1 loop
303
          rx_irq.detect(i) <= rx_irq.detect(i)(0) & rx_irq.trigger(i);
304
        end loop;
305
      end if;
306
      -- TX --
307
      tx_irq.detect <= (others => (others => '0')); -- default
308
      if (enable = '1') then
309
        for i in 0 to SLINK_NUM_TX-1 loop
310
          tx_irq.detect(i) <= tx_irq.detect(i)(0) & tx_irq.trigger(i);
311
        end loop;
312
      end if;
313
    end if;
314
  end process irq_trigger_sync;
315
 
316
  -- interrupt trigger --
317
  irq_trigger_comb: process(rx_irq, irq_rx_en, tx_irq, irq_tx_en)
318
  begin
319
    -- RX --
320
    rx_irq.set <= (others => '0');
321
    for i in 0 to SLINK_NUM_RX-1 loop
322
      if (rx_irq.detect(i) = "01") and (irq_rx_en(i) = '1') then -- rising-edge
323
        rx_irq.set(i) <= '1';
324
      end if;
325
    end loop;
326
    -- TX --
327
    tx_irq.set <= (others => '0');
328
    for i in 0 to SLINK_NUM_TX-1 loop
329
      if (tx_irq.detect(i) = "01") and (irq_tx_en(i) = '1') then -- rising-edge
330
        tx_irq.set(i) <= '1';
331
      end if;
332
    end loop;
333
  end process irq_trigger_comb;
334
 
335
  -- interrupt arbiter --
336
  irq_generator: process(clk_i)
337
  begin
338
    if rising_edge(clk_i) then
339
      if (enable = '0') then
340
        rx_irq.pending <= '0';
341
        tx_irq.pending <= '0';
342
      else
343
        -- RX --
344
        if (or_reduce_f(rx_irq.set) = '1') then
345
          rx_irq.pending <= '1';
346
        elsif (rx_irq.clr = '1') then
347
          rx_irq.pending <= '0';
348 62 zero_gravi
        end if;
349 68 zero_gravi
        -- TX --
350
        if (or_reduce_f(tx_irq.set) = '1') then
351
          tx_irq.pending <= '1';
352
        elsif (tx_irq.clr = '1') then
353
          tx_irq.pending <= '0';
354
        end if;
355 62 zero_gravi
      end if;
356 61 zero_gravi
    end if;
357 68 zero_gravi
  end process irq_generator;
358 61 zero_gravi
 
359 68 zero_gravi
  -- IRQ requests to CPU --
360
  irq_rx_o <= rx_irq.pending;
361
  irq_tx_o <= tx_irq.pending;
362 61 zero_gravi
 
363 68 zero_gravi
  -- IRQ acknowledge --
364
  rx_irq.clr <= '1' when ((rden = '1') and (addr(5) = '1')) or ((wren = '1') and (addr(5 downto 3) = "000")) else '0'; -- read from data FIFO OR write to control register
365
  tx_irq.clr <= '1' when ((wren = '1') and (addr(5) = '1')) or ((wren = '1') and (addr(5 downto 3) = "000")) else '0'; -- write to data FIFO  OR write to control register
366
 
367
 
368 61 zero_gravi
  -- Link Select ----------------------------------------------------------------------------
369
  -- -------------------------------------------------------------------------------------------
370
  link_select: process(addr)
371
  begin
372
    case addr(5 downto 2) is -- MSB = data fifo access at all?
373
      when "1000" => link_sel <= "00000001";
374
      when "1001" => link_sel <= "00000010";
375
      when "1010" => link_sel <= "00000100";
376
      when "1011" => link_sel <= "00001000";
377
      when "1100" => link_sel <= "00010000";
378
      when "1101" => link_sel <= "00100000";
379
      when "1110" => link_sel <= "01000000";
380
      when "1111" => link_sel <= "10000000";
381
      when others => link_sel <= "00000000";
382
    end case;
383
  end process link_select;
384
 
385
  fifo_access_gen:
386
  for i in 0 to 7 generate
387 68 zero_gravi
    tx_fifo_we(i) <= link_sel(i) and wren;
388
    rx_fifo_re(i) <= link_sel(i) and rden;
389 61 zero_gravi
  end generate;
390
 
391
 
392
  -- TX Link FIFOs --------------------------------------------------------------------------
393
  -- -------------------------------------------------------------------------------------------
394
  transmit_fifo_gen:
395
  for i in 0 to SLINK_NUM_TX-1 generate
396
    transmit_fifo_inst: neorv32_fifo
397
    generic map (
398
      FIFO_DEPTH => SLINK_TX_FIFO, -- number of fifo entries; has to be a power of two; min 1
399
      FIFO_WIDTH => 32,            -- size of data elements in fifo
400 65 zero_gravi
      FIFO_RSYNC => false,         -- async read
401
      FIFO_SAFE  => true           -- safe access
402 61 zero_gravi
    )
403
    port map (
404
      -- control --
405
      clk_i   => clk_i,             -- clock, rising edge
406
      rstn_i  => '1',               -- async reset, low-active
407
      clear_i => fifo_clear,        -- sync reset, high-active
408 65 zero_gravi
      level_o => open,              -- fill level
409
      half_o  => tx_fifo_half(i),   -- FIFO is at least half full
410 61 zero_gravi
      -- write port --
411
      wdata_i => data_i,            -- write data
412
      we_i    => tx_fifo_we(i),     -- write enable
413
      free_o  => tx_fifo_free(i),   -- at least one entry is free when set
414
      -- read port --
415
      re_i    => slink_tx_rdy_i(i), -- read enable
416
      rdata_o => slink_tx_dat_o(i), -- read data
417
      avail_o => slink_tx_val_o(i)  -- data available when set
418
    );
419
  end generate;
420
 
421
  -- terminate unimplemented links --
422
  transmit_fifo_gen_terminate:
423
  for i in SLINK_NUM_TX to 7 generate
424
    tx_fifo_free(i)   <= '0';
425
    slink_tx_dat_o(i) <= (others => '0');
426
    slink_tx_val_o(i) <= '0';
427 65 zero_gravi
    tx_fifo_half(i)   <= '0';
428 61 zero_gravi
  end generate;
429
 
430
 
431
  -- RX Link FIFOs --------------------------------------------------------------------------
432
  -- -------------------------------------------------------------------------------------------
433
  receive_fifo_gen:
434
  for i in 0 to SLINK_NUM_RX-1 generate
435
    receive_fifo_inst: neorv32_fifo
436
    generic map (
437
      FIFO_DEPTH => SLINK_RX_FIFO, -- number of fifo entries; has to be a power of two; min 1
438
      FIFO_WIDTH => 32,            -- size of data elements in fifo
439 65 zero_gravi
      FIFO_RSYNC => false,         -- async read
440
      FIFO_SAFE  => true           -- safe access
441 61 zero_gravi
    )
442
    port map (
443
      -- control --
444
      clk_i   => clk_i,             -- clock, rising edge
445
      rstn_i  => '1',               -- async reset, low-active
446
      clear_i => fifo_clear,        -- sync reset, high-active
447 65 zero_gravi
      level_o => open,              -- fill level
448
      half_o  => rx_fifo_half(i),   -- FIFO is at least half full
449 61 zero_gravi
      -- write port --
450
      wdata_i => slink_rx_dat_i(i), -- write data
451
      we_i    => slink_rx_val_i(i), -- write enable
452
      free_o  => slink_rx_rdy_o(i), -- at least one entry is free when set
453
      -- read port --
454
      re_i    => rx_fifo_re(i),     -- read enable
455
      rdata_o => rx_fifo_rdata(i),  -- read data
456
      avail_o => rx_fifo_avail(i)   -- data available when set
457
    );
458
  end generate;
459
 
460
  -- terminate unimplemented links --
461
  receive_fifo_gen_terminate:
462
  for i in SLINK_NUM_RX to 7 generate
463
    rx_fifo_avail(i)  <= '0';
464
    slink_rx_rdy_o(i) <= '0';
465
    rx_fifo_rdata(i)  <= (others => '0');
466 65 zero_gravi
    rx_fifo_half(i)   <= '0';
467 61 zero_gravi
  end generate;
468
 
469
 
470
end neorv32_slink_rtl;

powered by: WebSVN 2.1.0

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