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.communication/] [pkt_codec_mk2/] [1.0/] [vhd/] [addr_rip.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Address flit ripper / replacer
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : addr_rip.vhd
6
-- Author     : Lasse Lehtonen
7
-- Company    : 
8
-- Created    : 2011-10-12
9
-- Last update: 2011-12-02
10
-- Platform   : 
11
-- Standard   : VHDL'87
12
-------------------------------------------------------------------------------
13
-- Description:
14
-- Converts the addresses received from NoC to IP. All transfers start with NoC
15
-- address which can be optionally followed by (memory-mapped original) address.
16
-- This unit rips (removes) the NoC address flit, if wanted. Moreover, this can
17
-- replace the network address with original address (2nd flit). Or this doesn't
18
-- do a thing but just forwards everything to IP.
19
--
20
-------------------------------------------------------------------------------
21
-- Copyright (c) 2011 
22
-------------------------------------------------------------------------------
23
-- Revisions  :
24
-- Date        Version  Author  Description
25
-- 2011-10-12  1.0      lehton87        Created
26
-------------------------------------------------------------------------------
27
 
28
library ieee;
29
use ieee.std_logic_1164.all;
30
 
31
 
32
entity addr_rip is
33
 
34
  generic (
35
    cmd_width_g    : positive;          -- in bits
36
    data_width_g   : positive;          -- in bits
37
    addr_flit_en_g : natural;           -- Is there an address in 2nd flit?
38
    rip_addr_g     : natural            -- Enable removing the NoC address
39
    );
40
  port (
41
    clk           : in  std_logic;
42
    rst_n         : in  std_logic;
43
    net_cmd_in    : in  std_logic_vector(cmd_width_g-1 downto 0);
44
    net_data_in   : in  std_logic_vector(data_width_g-1 downto 0);
45
    net_stall_out : out std_logic;
46
    ip_cmd_out    : out std_logic_vector(cmd_width_g-1 downto 0);
47
    ip_data_out   : out std_logic_vector(data_width_g-1 downto 0);
48
    ip_stall_in   : in  std_logic
49
    );
50
end addr_rip;
51
 
52
 
53
architecture rtl of addr_rip is
54
 
55
  signal was_addr_r : std_logic;
56
 
57
begin  -- rtl
58
 
59
 
60
  -- Check if NoC address was received
61
  addr_check_p : process (clk, rst_n)
62
  begin  -- process addr_check_p
63
    if rst_n = '0' then                 -- asynchronous reset (active low)
64
      was_addr_r <= '0';
65
    elsif clk'event and clk = '1' then  -- rising clock edge
66
      if net_cmd_in = "01" then
67
        was_addr_r <= '1';
68
      else
69
        was_addr_r <= '0';
70
      end if;
71
    end if;
72
  end process addr_check_p;
73
 
74
  ip_data_out   <= net_data_in;
75
  net_stall_out <= ip_stall_in;
76
 
77
 
78
  -- 1. Do not forward NoC address to IP.
79
  rip : if rip_addr_g = 1 generate
80
 
81
    -- Give the second flit as address to the IP
82
    replace : if addr_flit_en_g = 1 generate
83
 
84
      m1 : process (net_cmd_in, was_addr_r)
85
      begin  -- process m
86
        if net_cmd_in = "01" then
87
          ip_cmd_out <= "00";
88
        elsif was_addr_r = '1' then
89
          ip_cmd_out <= "01";
90
        else
91
          ip_cmd_out <= net_cmd_in;
92
        end if;
93
      end process m1;
94
    end generate replace;
95
 
96
    -- NoC addr is followed by data. Don't give any address to IP.
97
    dont_replace : if addr_flit_en_g = 0 generate
98
      m2: process (net_cmd_in)
99
      begin  -- process m2
100
        if net_cmd_in = "01" then
101
          ip_cmd_out <= "00";
102
        else
103
          ip_cmd_out <= net_cmd_in;
104
        end if;
105
      end process m2;
106
    end generate dont_replace;
107
  end generate rip;
108
 
109
 
110
 
111
  -- 2. Forward NoC address to IP.
112
  dont_rip : if rip_addr_g = 0 generate
113
 
114
    -- Give both the NoC addr and 2nd addr flit to IP
115
    replace1 : if addr_flit_en_g = 1 generate
116
      m3 : process (net_cmd_in, was_addr_r)
117
      begin  -- process m
118
        if net_cmd_in = "01" then
119
          ip_cmd_out <= "01";
120
        elsif was_addr_r = '1' then
121
          ip_cmd_out <= "01";
122
        else
123
          ip_cmd_out <= net_cmd_in;
124
        end if;
125
      end process m3;
126
    end generate replace1;
127
 
128
    -- Everything goes straight through to the IP
129
    dont_replace1 : if addr_flit_en_g = 0 generate
130
      ip_cmd_out <= net_cmd_in;
131
    end generate dont_replace1;
132
  end generate dont_rip;
133
 
134
end rtl;

powered by: WebSVN 2.1.0

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