| 1 | 33 | magro732 | -------------------------------------------------------------------------------
 | 
      
         | 2 | 36 | magro732 | -- 
 | 
      
         | 3 |  |  | -- RapidIO IP Library Core
 | 
      
         | 4 |  |  | -- 
 | 
      
         | 5 |  |  | -- This file is part of the RapidIO IP library project
 | 
      
         | 6 |  |  | -- http://www.opencores.org/cores/rio/
 | 
      
         | 7 |  |  | -- 
 | 
      
         | 8 |  |  | -- Description
 | 
      
         | 9 |  |  | -- Contains a platform to build endpoints on.
 | 
      
         | 10 |  |  | -- 
 | 
      
         | 11 |  |  | -- To Do:
 | 
      
         | 12 | 45 | magro732 | -- REMARK: Clean up and increase the speed of the interface to packet handlers.
 | 
      
         | 13 |  |  | -- REMARK: 8-bit deviceId has not been verified, fix.
 | 
      
         | 14 |  |  | -- REMARK: Egress; Places packets in different queues depending on the packet priority?
 | 
      
         | 15 |  |  | -- REMARK: Add verification of all sizes of packets.
 | 
      
         | 16 | 36 | magro732 | -- 
 | 
      
         | 17 |  |  | -- Author(s): 
 | 
      
         | 18 |  |  | -- - Magnus Rosenius, magro732@opencores.org 
 | 
      
         | 19 |  |  | -- 
 | 
      
         | 20 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 21 |  |  | -- 
 | 
      
         | 22 |  |  | -- Copyright (C) 2013 Authors and OPENCORES.ORG 
 | 
      
         | 23 |  |  | -- 
 | 
      
         | 24 |  |  | -- This source file may be used and distributed without 
 | 
      
         | 25 |  |  | -- restriction provided that this copyright statement is not 
 | 
      
         | 26 |  |  | -- removed from the file and that any derivative work contains 
 | 
      
         | 27 |  |  | -- the original copyright notice and the associated disclaimer. 
 | 
      
         | 28 |  |  | -- 
 | 
      
         | 29 |  |  | -- This source file is free software; you can redistribute it 
 | 
      
         | 30 |  |  | -- and/or modify it under the terms of the GNU Lesser General 
 | 
      
         | 31 |  |  | -- Public License as published by the Free Software Foundation; 
 | 
      
         | 32 |  |  | -- either version 2.1 of the License, or (at your option) any 
 | 
      
         | 33 |  |  | -- later version. 
 | 
      
         | 34 |  |  | -- 
 | 
      
         | 35 |  |  | -- This source is distributed in the hope that it will be 
 | 
      
         | 36 |  |  | -- useful, but WITHOUT ANY WARRANTY; without even the implied 
 | 
      
         | 37 |  |  | -- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 | 
      
         | 38 |  |  | -- PURPOSE. See the GNU Lesser General Public License for more 
 | 
      
         | 39 |  |  | -- details. 
 | 
      
         | 40 |  |  | -- 
 | 
      
         | 41 |  |  | -- You should have received a copy of the GNU Lesser General 
 | 
      
         | 42 |  |  | -- Public License along with this source; if not, download it 
 | 
      
         | 43 |  |  | -- from http://www.opencores.org/lgpl.shtml 
 | 
      
         | 44 |  |  | -- 
 | 
      
         | 45 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 46 |  |  |  
 | 
      
         | 47 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 48 | 33 | magro732 | -- RioLogicalCommon.
 | 
      
         | 49 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 50 |  |  | -- Ingress:
 | 
      
         | 51 | 35 | magro732 | -- * Removes in-the-middle and trailing CRC.
 | 
      
         | 52 | 33 | magro732 | -- * Forwards packets to logical-layer handlers depending on ftype and
 | 
      
         | 53 |  |  | --   transaction (output as address).
 | 
      
         | 54 |  |  | -- * Outputs header and deviceIDs in seperate accesses to facilitate 8- and
 | 
      
         | 55 |  |  | --   16-bit deviceAddress support. All fields are right-justified.
 | 
      
         | 56 |  |  | -- Egress:
 | 
      
         | 57 | 35 | magro732 | -- * Adds in-the-middle and trailing CRC.
 | 
      
         | 58 | 33 | magro732 | -- * Receives packets from logical-layer handlers.
 | 
      
         | 59 | 35 | magro732 | -- * Receives header and deviceIDs in seperate accesses to facilitate 8- and
 | 
      
         | 60 |  |  | --   16-bit deviceAddress support. All fields are right-justified.
 | 
      
         | 61 | 33 | magro732 | -------------------------------------------------------------------------------
 | 
      
         | 62 | 36 | magro732 | library ieee;
 | 
      
         | 63 |  |  | use ieee.std_logic_1164.all;
 | 
      
         | 64 |  |  | use ieee.numeric_std.all;
 | 
      
         | 65 |  |  | use work.rio_common.all;
 | 
      
         | 66 |  |  |  
 | 
      
         | 67 |  |  |  
 | 
      
         | 68 | 38 | magro732 | -------------------------------------------------------------------------------
 | 
      
         | 69 |  |  | -- 
 | 
      
         | 70 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 71 | 36 | magro732 | entity RioLogicalCommon is
 | 
      
         | 72 | 45 | magro732 |   generic(
 | 
      
         | 73 |  |  |     PORTS : natural);
 | 
      
         | 74 | 36 | magro732 |   port(
 | 
      
         | 75 |  |  |     clk : in std_logic;
 | 
      
         | 76 |  |  |     areset_n : in std_logic;
 | 
      
         | 77 |  |  |     enable : in std_logic;
 | 
      
         | 78 |  |  |  
 | 
      
         | 79 |  |  |     readFrameEmpty_i : in std_logic;
 | 
      
         | 80 |  |  |     readFrame_o : out std_logic;
 | 
      
         | 81 |  |  |     readContent_o : out std_logic;
 | 
      
         | 82 |  |  |     readContentEnd_i : in std_logic;
 | 
      
         | 83 |  |  |     readContentData_i : in std_logic_vector(31 downto 0);
 | 
      
         | 84 | 39 | magro732 |  
 | 
      
         | 85 | 36 | magro732 |     writeFrameFull_i : in std_logic;
 | 
      
         | 86 |  |  |     writeFrame_o : out std_logic;
 | 
      
         | 87 |  |  |     writeFrameAbort_o : out std_logic;
 | 
      
         | 88 |  |  |     writeContent_o : out std_logic;
 | 
      
         | 89 |  |  |     writeContentData_o : out std_logic_vector(31 downto 0);
 | 
      
         | 90 |  |  |  
 | 
      
         | 91 | 45 | magro732 |     inboundCyc_o : out std_logic;
 | 
      
         | 92 |  |  |     inboundStb_o : out std_logic;
 | 
      
         | 93 |  |  |     inboundAdr_o : out std_logic_vector(7 downto 0);
 | 
      
         | 94 |  |  |     inboundDat_o : out std_logic_vector(31 downto 0);
 | 
      
         | 95 |  |  |     inboundAck_i : in std_logic;
 | 
      
         | 96 | 39 | magro732 |  
 | 
      
         | 97 | 45 | magro732 |     outboundCyc_i : in std_logic_vector(PORTS-1 downto 0);
 | 
      
         | 98 |  |  |     outboundStb_i : in std_logic_vector(PORTS-1 downto 0);
 | 
      
         | 99 |  |  |     outboundDat_i : in std_logic_vector(32*PORTS-1 downto 0);
 | 
      
         | 100 |  |  |     outboundAck_o : out std_logic_vector(PORTS-1 downto 0));
 | 
      
         | 101 | 36 | magro732 | end entity;
 | 
      
         | 102 |  |  |  
 | 
      
         | 103 |  |  |  
 | 
      
         | 104 | 38 | magro732 | -------------------------------------------------------------------------------
 | 
      
         | 105 |  |  | -- 
 | 
      
         | 106 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 107 | 36 | magro732 | architecture RioLogicalCommon of RioLogicalCommon is
 | 
      
         | 108 |  |  |  
 | 
      
         | 109 | 45 | magro732 |   component RioLogicalCommonInterconnect is
 | 
      
         | 110 |  |  |     generic(
 | 
      
         | 111 |  |  |       WIDTH : natural);
 | 
      
         | 112 |  |  |     port(
 | 
      
         | 113 |  |  |       clk : in std_logic;
 | 
      
         | 114 |  |  |       areset_n : in std_logic;
 | 
      
         | 115 |  |  |  
 | 
      
         | 116 |  |  |       stb_i : in std_logic_vector(WIDTH-1 downto 0);
 | 
      
         | 117 |  |  |       dataM_i : in std_logic_vector(32*WIDTH-1 downto 0);
 | 
      
         | 118 |  |  |       ack_o : out std_logic_vector(WIDTH-1 downto 0);
 | 
      
         | 119 |  |  |  
 | 
      
         | 120 |  |  |       stb_o : out std_logic;
 | 
      
         | 121 |  |  |       dataS_o : out std_logic_vector(31 downto 0);
 | 
      
         | 122 |  |  |       ack_i : in std_logic);
 | 
      
         | 123 |  |  |   end component;
 | 
      
         | 124 |  |  |  
 | 
      
         | 125 | 36 | magro732 |   component RioLogicalCommonIngress is
 | 
      
         | 126 |  |  |     port(
 | 
      
         | 127 |  |  |       clk : in std_logic;
 | 
      
         | 128 |  |  |       areset_n : in std_logic;
 | 
      
         | 129 |  |  |  
 | 
      
         | 130 |  |  |       readFrameEmpty_i : in std_logic;
 | 
      
         | 131 |  |  |       readFrame_o : out std_logic;
 | 
      
         | 132 |  |  |       readContent_o : out std_logic;
 | 
      
         | 133 |  |  |       readContentEnd_i : in std_logic;
 | 
      
         | 134 |  |  |       readContentData_i : in std_logic_vector(31 downto 0);
 | 
      
         | 135 |  |  |  
 | 
      
         | 136 | 45 | magro732 |       inboundCyc_o : out std_logic;
 | 
      
         | 137 |  |  |       inboundStb_o : out std_logic;
 | 
      
         | 138 |  |  |       inboundAdr_o : out std_logic_vector(7 downto 0);
 | 
      
         | 139 |  |  |       inboundDat_o : out std_logic_vector(31 downto 0);
 | 
      
         | 140 |  |  |       inboundAck_i : in std_logic);
 | 
      
         | 141 | 36 | magro732 |   end component;
 | 
      
         | 142 |  |  |  
 | 
      
         | 143 |  |  |   component RioLogicalCommonEgress is
 | 
      
         | 144 |  |  |     port(
 | 
      
         | 145 |  |  |       clk : in std_logic;
 | 
      
         | 146 |  |  |       areset_n : in std_logic;
 | 
      
         | 147 |  |  |  
 | 
      
         | 148 |  |  |       writeFrameFull_i : in std_logic;
 | 
      
         | 149 |  |  |       writeFrame_o : out std_logic;
 | 
      
         | 150 |  |  |       writeFrameAbort_o : out std_logic;
 | 
      
         | 151 |  |  |       writeContent_o : out std_logic;
 | 
      
         | 152 |  |  |       writeContentData_o : out std_logic_vector(31 downto 0);
 | 
      
         | 153 |  |  |  
 | 
      
         | 154 | 45 | magro732 |       outboundCyc_i : in std_logic;
 | 
      
         | 155 |  |  |       outboundStb_i : in std_logic;
 | 
      
         | 156 |  |  |       outboundDat_i : in std_logic_vector(31 downto 0);
 | 
      
         | 157 |  |  |       outboundAck_o : out std_logic);
 | 
      
         | 158 | 36 | magro732 |   end component;
 | 
      
         | 159 |  |  |  
 | 
      
         | 160 | 45 | magro732 |   signal outboundStb : std_logic;
 | 
      
         | 161 |  |  |   signal outboundDat : std_logic_vector(31 downto 0);
 | 
      
         | 162 |  |  |   signal outboundAck : std_logic;
 | 
      
         | 163 |  |  |  
 | 
      
         | 164 | 36 | magro732 | begin
 | 
      
         | 165 |  |  |  
 | 
      
         | 166 | 38 | magro732 |   Ingress: RioLogicalCommonIngress
 | 
      
         | 167 |  |  |     port map(
 | 
      
         | 168 |  |  |       clk=>clk, areset_n=>areset_n,
 | 
      
         | 169 |  |  |       readFrameEmpty_i=>readFrameEmpty_i,
 | 
      
         | 170 |  |  |       readFrame_o=>readFrame_o,
 | 
      
         | 171 |  |  |       readContent_o=>readContent_o,
 | 
      
         | 172 |  |  |       readContentEnd_i=>readContentEnd_i,
 | 
      
         | 173 |  |  |       readContentData_i=>readContentData_i,
 | 
      
         | 174 | 45 | magro732 |       inboundCyc_o=>inboundCyc_o,
 | 
      
         | 175 |  |  |       inboundStb_o=>inboundStb_o,
 | 
      
         | 176 |  |  |       inboundAdr_o=>inboundAdr_o,
 | 
      
         | 177 |  |  |       inboundDat_o=>inboundDat_o,
 | 
      
         | 178 |  |  |       inboundAck_i=>inboundAck_i);
 | 
      
         | 179 | 38 | magro732 |  
 | 
      
         | 180 | 45 | magro732 |   EgressInterconnect: RioLogicalCommonInterconnect
 | 
      
         | 181 |  |  |     generic map(WIDTH=>PORTS)
 | 
      
         | 182 |  |  |     port map(
 | 
      
         | 183 |  |  |       clk=>clk, areset_n=>areset_n,
 | 
      
         | 184 |  |  |       stb_i=>outboundStb_i,
 | 
      
         | 185 |  |  |       dataM_i=>outboundDat_i,
 | 
      
         | 186 |  |  |       ack_o=>outboundAck_o,
 | 
      
         | 187 |  |  |       stb_o=>outboundStb,
 | 
      
         | 188 |  |  |       dataS_o=>outboundDat,
 | 
      
         | 189 |  |  |       ack_i=>outboundAck);
 | 
      
         | 190 |  |  |  
 | 
      
         | 191 | 36 | magro732 |   Egress: RioLogicalCommonEgress
 | 
      
         | 192 |  |  |     port map(
 | 
      
         | 193 |  |  |       clk=>clk, areset_n=>areset_n,
 | 
      
         | 194 |  |  |       writeFrameFull_i=>writeFrameFull_i,
 | 
      
         | 195 |  |  |       writeFrame_o=>writeFrame_o,
 | 
      
         | 196 |  |  |       writeFrameAbort_o=>writeFrameAbort_o,
 | 
      
         | 197 |  |  |       writeContent_o=>writeContent_o,
 | 
      
         | 198 |  |  |       writeContentData_o=>writeContentData_o,
 | 
      
         | 199 | 45 | magro732 |       outboundCyc_i=>'1',
 | 
      
         | 200 |  |  |       outboundStb_i=>outboundStb,
 | 
      
         | 201 |  |  |       outboundDat_i=>outboundDat,
 | 
      
         | 202 |  |  |       outboundAck_o=>outboundAck);
 | 
      
         | 203 | 36 | magro732 |  
 | 
      
         | 204 |  |  | end architecture;
 | 
      
         | 205 |  |  |  
 | 
      
         | 206 |  |  |  
 | 
      
         | 207 |  |  |  
 | 
      
         | 208 | 34 | magro732 | -------------------------------------------------------------------------------
 | 
      
         | 209 |  |  | -- RioLogicalCommonIngress.
 | 
      
         | 210 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 211 | 33 | magro732 | library ieee;
 | 
      
         | 212 | 34 | magro732 | use ieee.std_logic_1164.all;
 | 
      
         | 213 | 33 | magro732 | use ieee.numeric_std.all;
 | 
      
         | 214 |  |  | use work.rio_common.all;
 | 
      
         | 215 |  |  |  
 | 
      
         | 216 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 217 |  |  | -- Entity for RioLogicalCommonIngress.
 | 
      
         | 218 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 219 |  |  | entity RioLogicalCommonIngress is
 | 
      
         | 220 |  |  |   port(
 | 
      
         | 221 |  |  |     clk : in std_logic;
 | 
      
         | 222 |  |  |     areset_n : in std_logic;
 | 
      
         | 223 |  |  |  
 | 
      
         | 224 |  |  |     readFrameEmpty_i : in std_logic;
 | 
      
         | 225 |  |  |     readFrame_o : out std_logic;
 | 
      
         | 226 |  |  |     readContent_o : out std_logic;
 | 
      
         | 227 |  |  |     readContentEnd_i : in std_logic;
 | 
      
         | 228 |  |  |     readContentData_i : in std_logic_vector(31 downto 0);
 | 
      
         | 229 |  |  |  
 | 
      
         | 230 | 45 | magro732 |     inboundCyc_o : out std_logic;
 | 
      
         | 231 |  |  |     inboundStb_o : out std_logic;
 | 
      
         | 232 |  |  |     inboundAdr_o : out std_logic_vector(7 downto 0);
 | 
      
         | 233 |  |  |     inboundDat_o : out std_logic_vector(31 downto 0);
 | 
      
         | 234 |  |  |     inboundAck_i : in std_logic);
 | 
      
         | 235 | 33 | magro732 | end entity;
 | 
      
         | 236 |  |  |  
 | 
      
         | 237 |  |  |  
 | 
      
         | 238 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 239 |  |  | -- 
 | 
      
         | 240 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 241 |  |  | architecture RioLogicalCommonIngress of RioLogicalCommonIngress is
 | 
      
         | 242 | 36 | magro732 |   type StateType is (IDLE,
 | 
      
         | 243 |  |  |                      WAIT_HEADER_0, HEADER_0, HEADER_1,
 | 
      
         | 244 |  |  |                      SEND_HEADER, SEND_DESTINATION, SEND_SOURCE,
 | 
      
         | 245 |  |  |                      FORWARD_SHORT, FORWARD_CRC, FORWARD_LONG, FORWARD_LAST,
 | 
      
         | 246 |  |  |                      END_PACKET);
 | 
      
         | 247 |  |  |   signal state : StateType;
 | 
      
         | 248 | 33 | magro732 |  
 | 
      
         | 249 | 45 | magro732 |   signal packetPosition : natural range 0 to 68;
 | 
      
         | 250 | 36 | magro732 |   signal packetContent : std_logic_vector(63 downto 0);
 | 
      
         | 251 |  |  |  
 | 
      
         | 252 |  |  |   signal tt : std_logic_vector(1 downto 0);
 | 
      
         | 253 |  |  |   signal ftype : std_logic_vector(3 downto 0);
 | 
      
         | 254 |  |  |   signal transaction : std_logic_vector(3 downto 0);
 | 
      
         | 255 |  |  |  
 | 
      
         | 256 | 33 | magro732 | begin
 | 
      
         | 257 |  |  |  
 | 
      
         | 258 |  |  |   process(clk, areset_n)
 | 
      
         | 259 |  |  |   begin
 | 
      
         | 260 |  |  |     if (areset_n = '0') then
 | 
      
         | 261 | 44 | magro732 |       state <= IDLE;
 | 
      
         | 262 | 38 | magro732 |  
 | 
      
         | 263 | 36 | magro732 |       packetPosition <= 0;
 | 
      
         | 264 |  |  |       packetContent <= (others=>'0');
 | 
      
         | 265 | 44 | magro732 |  
 | 
      
         | 266 | 36 | magro732 |       tt <= "00";
 | 
      
         | 267 |  |  |       ftype <= "0000";
 | 
      
         | 268 |  |  |       transaction <= "0000";
 | 
      
         | 269 | 38 | magro732 |  
 | 
      
         | 270 |  |  |       readContent_o <= '0';
 | 
      
         | 271 |  |  |       readFrame_o <= '0';
 | 
      
         | 272 | 44 | magro732 |  
 | 
      
         | 273 | 45 | magro732 |       inboundCyc_o <= '0';
 | 
      
         | 274 |  |  |       inboundStb_o <= '0';
 | 
      
         | 275 |  |  |       inboundAdr_o <= (others=>'0');
 | 
      
         | 276 |  |  |       inboundDat_o <= (others=>'0');
 | 
      
         | 277 | 33 | magro732 |     elsif (clk'event and clk = '1') then
 | 
      
         | 278 |  |  |       readContent_o <= '0';
 | 
      
         | 279 | 38 | magro732 |       readFrame_o <= '0';
 | 
      
         | 280 | 33 | magro732 |  
 | 
      
         | 281 |  |  |       case state is
 | 
      
         | 282 |  |  |         when IDLE =>
 | 
      
         | 283 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 284 |  |  |           -- 
 | 
      
         | 285 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 286 |  |  |           packetPosition <= 0;
 | 
      
         | 287 |  |  |           if (readFrameEmpty_i = '0') then
 | 
      
         | 288 |  |  |             readContent_o <= '1';
 | 
      
         | 289 |  |  |             state <= WAIT_HEADER_0;
 | 
      
         | 290 |  |  |           end if;
 | 
      
         | 291 |  |  |  
 | 
      
         | 292 |  |  |         when WAIT_HEADER_0 =>
 | 
      
         | 293 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 294 |  |  |           -- 
 | 
      
         | 295 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 296 |  |  |           readContent_o <= '1';
 | 
      
         | 297 |  |  |           state <= HEADER_0;
 | 
      
         | 298 |  |  |  
 | 
      
         | 299 |  |  |         when HEADER_0 =>
 | 
      
         | 300 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 301 |  |  |           -- 
 | 
      
         | 302 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 303 |  |  |           packetContent <= packetContent(31 downto 0) & readContentData_i;
 | 
      
         | 304 |  |  |           packetPosition <= packetPosition + 1;
 | 
      
         | 305 |  |  |           readContent_o <= '1';
 | 
      
         | 306 |  |  |  
 | 
      
         | 307 |  |  |           tt <= readContentData_i(21 downto 20);
 | 
      
         | 308 |  |  |           ftype <= readContentData_i(19 downto 16);
 | 
      
         | 309 |  |  |  
 | 
      
         | 310 |  |  |           state <= HEADER_1;
 | 
      
         | 311 |  |  |  
 | 
      
         | 312 |  |  |         when HEADER_1 =>
 | 
      
         | 313 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 314 |  |  |           -- 
 | 
      
         | 315 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 316 |  |  |           packetContent <= packetContent(31 downto 0) & readContentData_i;
 | 
      
         | 317 |  |  |           packetPosition <= packetPosition + 1;
 | 
      
         | 318 |  |  |  
 | 
      
         | 319 |  |  |           if (tt = "00") then
 | 
      
         | 320 |  |  |             transaction <= readContentData_i(31 downto 28);
 | 
      
         | 321 |  |  |           elsif (tt = "01") then
 | 
      
         | 322 |  |  |             transaction <= readContentData_i(15 downto 12);
 | 
      
         | 323 |  |  |           end if;
 | 
      
         | 324 |  |  |  
 | 
      
         | 325 |  |  |           state <= SEND_HEADER;
 | 
      
         | 326 |  |  |  
 | 
      
         | 327 |  |  |         when SEND_HEADER =>
 | 
      
         | 328 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 329 |  |  |           -- 
 | 
      
         | 330 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 331 | 45 | magro732 |           inboundCyc_o <= '1';
 | 
      
         | 332 |  |  |           inboundStb_o <= '1';
 | 
      
         | 333 |  |  |           inboundAdr_o <= ftype & transaction;
 | 
      
         | 334 |  |  |           inboundDat_o <= x"0000" & packetContent(63 downto 48);
 | 
      
         | 335 | 33 | magro732 |           packetContent <= packetContent(47 downto 0) & x"0000";
 | 
      
         | 336 |  |  |  
 | 
      
         | 337 |  |  |           state <= SEND_DESTINATION;
 | 
      
         | 338 |  |  |  
 | 
      
         | 339 |  |  |         when SEND_DESTINATION =>
 | 
      
         | 340 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 341 |  |  |           -- 
 | 
      
         | 342 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 343 | 45 | magro732 |           if (inboundAck_i = '1') then
 | 
      
         | 344 | 33 | magro732 |             if (tt = "00") then
 | 
      
         | 345 | 45 | magro732 |               inboundDat_o <= x"000000" & packetContent(63 downto 56);
 | 
      
         | 346 | 33 | magro732 |               packetContent <= packetContent(55 downto 0) & x"00";
 | 
      
         | 347 |  |  |             elsif (tt = "01") then
 | 
      
         | 348 | 45 | magro732 |               inboundDat_o <= x"0000" & packetContent(63 downto 48);
 | 
      
         | 349 | 38 | magro732 |               packetContent <= packetContent(47 downto 0) & x"0000";
 | 
      
         | 350 | 33 | magro732 |             end if;
 | 
      
         | 351 |  |  |  
 | 
      
         | 352 |  |  |             state <= SEND_SOURCE;
 | 
      
         | 353 |  |  |           end if;
 | 
      
         | 354 |  |  |  
 | 
      
         | 355 |  |  |         when SEND_SOURCE =>
 | 
      
         | 356 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 357 |  |  |           -- 
 | 
      
         | 358 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 359 | 45 | magro732 |           if (inboundAck_i = '1') then
 | 
      
         | 360 | 33 | magro732 |             if (tt = "00") then
 | 
      
         | 361 | 45 | magro732 |               inboundDat_o <= x"000000" & packetContent(63 downto 56);
 | 
      
         | 362 | 33 | magro732 |               packetContent <= packetContent(55 downto 0) & x"00";
 | 
      
         | 363 |  |  |             elsif (tt = "01") then
 | 
      
         | 364 | 45 | magro732 |               inboundDat_o <= x"0000" & packetContent(63 downto 48);
 | 
      
         | 365 | 38 | magro732 |               packetContent <= packetContent(47 downto 32) & readContentData_i & x"0000";
 | 
      
         | 366 |  |  |               readContent_o <= '1';
 | 
      
         | 367 | 33 | magro732 |             end if;
 | 
      
         | 368 |  |  |  
 | 
      
         | 369 | 36 | magro732 |             state <= FORWARD_SHORT;
 | 
      
         | 370 | 33 | magro732 |           end if;
 | 
      
         | 371 |  |  |  
 | 
      
         | 372 | 36 | magro732 |         when FORWARD_SHORT =>
 | 
      
         | 373 | 33 | magro732 |           ---------------------------------------------------------------------
 | 
      
         | 374 |  |  |           -- 
 | 
      
         | 375 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 376 | 45 | magro732 |           if (inboundAck_i = '1') then
 | 
      
         | 377 | 38 | magro732 |             packetPosition <= packetPosition + 1;
 | 
      
         | 378 | 33 | magro732 |  
 | 
      
         | 379 | 38 | magro732 |             if (tt = "00") then
 | 
      
         | 380 | 45 | magro732 |               inboundDat_o <= packetContent(63 downto 32);
 | 
      
         | 381 | 38 | magro732 |               packetContent <= packetContent(31 downto 0) & readContentData_i;
 | 
      
         | 382 |  |  |             elsif (tt = "01") then
 | 
      
         | 383 | 45 | magro732 |               inboundDat_o <= packetContent(63 downto 32);
 | 
      
         | 384 | 38 | magro732 |               packetContent <= packetContent(31 downto 16) & readContentData_i & x"0000";
 | 
      
         | 385 |  |  |             end if;
 | 
      
         | 386 | 36 | magro732 |  
 | 
      
         | 387 |  |  |             if (readContentEnd_i = '0') then
 | 
      
         | 388 | 45 | magro732 |               if (packetPosition = 18) then
 | 
      
         | 389 | 36 | magro732 |                 state <= FORWARD_CRC;
 | 
      
         | 390 |  |  |               end if;
 | 
      
         | 391 |  |  |  
 | 
      
         | 392 |  |  |               readContent_o <= '1';
 | 
      
         | 393 |  |  |             else
 | 
      
         | 394 |  |  |               readFrame_o <= '1';
 | 
      
         | 395 | 44 | magro732 |               state <= FORWARD_LAST;
 | 
      
         | 396 | 36 | magro732 |             end if;
 | 
      
         | 397 |  |  |           end if;
 | 
      
         | 398 | 33 | magro732 |  
 | 
      
         | 399 | 36 | magro732 |         when FORWARD_CRC =>
 | 
      
         | 400 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 401 |  |  |           -- 
 | 
      
         | 402 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 403 | 45 | magro732 |           if (inboundAck_i = '1') then
 | 
      
         | 404 |  |  |             inboundDat_o <= packetContent(63 downto 32);
 | 
      
         | 405 | 36 | magro732 |  
 | 
      
         | 406 |  |  |             packetPosition <= packetPosition + 1;
 | 
      
         | 407 |  |  |             packetContent <=
 | 
      
         | 408 | 45 | magro732 |               packetContent(31 downto 16) & readContentData_i(15 downto 0) & x"00000000";
 | 
      
         | 409 | 36 | magro732 |  
 | 
      
         | 410 |  |  |             if (readContentEnd_i = '0') then
 | 
      
         | 411 |  |  |               readContent_o <= '1';
 | 
      
         | 412 |  |  |               state <= FORWARD_LONG;
 | 
      
         | 413 | 33 | magro732 |             else
 | 
      
         | 414 | 36 | magro732 |               readFrame_o <= '1';
 | 
      
         | 415 |  |  |               state <= FORWARD_LAST;
 | 
      
         | 416 | 33 | magro732 |             end if;
 | 
      
         | 417 | 36 | magro732 |           end if;
 | 
      
         | 418 |  |  |  
 | 
      
         | 419 |  |  |         when FORWARD_LONG =>
 | 
      
         | 420 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 421 |  |  |           -- 
 | 
      
         | 422 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 423 | 45 | magro732 |           if (inboundAck_i = '1') then
 | 
      
         | 424 |  |  |             inboundDat_o <= packetContent(63 downto 32);
 | 
      
         | 425 | 36 | magro732 |  
 | 
      
         | 426 |  |  |             packetPosition <= packetPosition + 1;
 | 
      
         | 427 |  |  |             packetContent <=
 | 
      
         | 428 | 45 | magro732 |               readContentData_i & x"00000000";
 | 
      
         | 429 | 33 | magro732 |  
 | 
      
         | 430 |  |  |             if (readContentEnd_i = '0') then
 | 
      
         | 431 |  |  |               readContent_o <= '1';
 | 
      
         | 432 |  |  |             else
 | 
      
         | 433 |  |  |               readFrame_o <= '1';
 | 
      
         | 434 |  |  |               state <= FORWARD_LAST;
 | 
      
         | 435 |  |  |             end if;
 | 
      
         | 436 |  |  |           end if;
 | 
      
         | 437 |  |  |  
 | 
      
         | 438 |  |  |         when FORWARD_LAST =>
 | 
      
         | 439 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 440 |  |  |           -- 
 | 
      
         | 441 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 442 | 45 | magro732 |           if (inboundAck_i = '1') then
 | 
      
         | 443 |  |  |             inboundDat_o <= packetContent(63 downto 32);
 | 
      
         | 444 | 33 | magro732 |             state <= END_PACKET;
 | 
      
         | 445 |  |  |           end if;
 | 
      
         | 446 |  |  |  
 | 
      
         | 447 |  |  |         when END_PACKET =>
 | 
      
         | 448 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 449 |  |  |           -- 
 | 
      
         | 450 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 451 | 45 | magro732 |           if (inboundAck_i = '1') then
 | 
      
         | 452 |  |  |             inboundCyc_o <= '0';
 | 
      
         | 453 |  |  |             inboundStb_o <= '0';
 | 
      
         | 454 | 33 | magro732 |             state <= IDLE;
 | 
      
         | 455 |  |  |           end if;
 | 
      
         | 456 |  |  |  
 | 
      
         | 457 |  |  |         when others =>
 | 
      
         | 458 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 459 |  |  |           -- 
 | 
      
         | 460 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 461 |  |  |           state <= IDLE;
 | 
      
         | 462 |  |  |       end case;
 | 
      
         | 463 |  |  |     end if;
 | 
      
         | 464 |  |  |   end process;
 | 
      
         | 465 |  |  |  
 | 
      
         | 466 |  |  | end architecture;
 | 
      
         | 467 |  |  |  
 | 
      
         | 468 |  |  |  
 | 
      
         | 469 | 34 | magro732 | -------------------------------------------------------------------------------
 | 
      
         | 470 |  |  | -- RioLogicalCommonEgress.
 | 
      
         | 471 |  |  | -- Only 8-bit and 16-bit deviceId are supported. The first write must contain
 | 
      
         | 472 |  |  | -- the 16-bit header, the second write must contain the destination address and
 | 
      
         | 473 |  |  | -- the third must contain the source address.
 | 
      
         | 474 | 36 | magro732 | -- CRC is calculated during the transfer and is inserted at byte 81 and 82 and
 | 
      
         | 475 | 34 | magro732 | -- appended to the packet when it ends.
 | 
      
         | 476 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 477 |  |  | library ieee;
 | 
      
         | 478 |  |  | use ieee.std_logic_1164.all;
 | 
      
         | 479 |  |  | use ieee.numeric_std.all;
 | 
      
         | 480 |  |  | use work.rio_common.all;
 | 
      
         | 481 | 33 | magro732 |  
 | 
      
         | 482 | 34 | magro732 | -------------------------------------------------------------------------------
 | 
      
         | 483 |  |  | -- Entity for RioLogicalCommonEgress.
 | 
      
         | 484 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 485 |  |  | entity RioLogicalCommonEgress is
 | 
      
         | 486 |  |  |   port(
 | 
      
         | 487 |  |  |     clk : in std_logic;
 | 
      
         | 488 |  |  |     areset_n : in std_logic;
 | 
      
         | 489 | 33 | magro732 |  
 | 
      
         | 490 | 34 | magro732 |     writeFrameFull_i : in std_logic;
 | 
      
         | 491 |  |  |     writeFrame_o : out std_logic;
 | 
      
         | 492 |  |  |     writeFrameAbort_o : out std_logic;
 | 
      
         | 493 |  |  |     writeContent_o : out std_logic;
 | 
      
         | 494 |  |  |     writeContentData_o : out std_logic_vector(31 downto 0);
 | 
      
         | 495 |  |  |  
 | 
      
         | 496 | 45 | magro732 |     outboundCyc_i : in std_logic;
 | 
      
         | 497 |  |  |     outboundStb_i : in std_logic;
 | 
      
         | 498 |  |  |     outboundDat_i : in std_logic_vector(31 downto 0);
 | 
      
         | 499 |  |  |     outboundAck_o : out std_logic);
 | 
      
         | 500 | 34 | magro732 | end entity;
 | 
      
         | 501 |  |  |  
 | 
      
         | 502 |  |  |  
 | 
      
         | 503 | 33 | magro732 | -------------------------------------------------------------------------------
 | 
      
         | 504 | 34 | magro732 | -- Architecture for RioLogicalCommonEgress.
 | 
      
         | 505 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 506 |  |  | architecture RioLogicalCommonEgress of RioLogicalCommonEgress is
 | 
      
         | 507 |  |  |  
 | 
      
         | 508 |  |  |   component Crc16CITT is
 | 
      
         | 509 |  |  |     port(
 | 
      
         | 510 |  |  |       d_i : in  std_logic_vector(15 downto 0);
 | 
      
         | 511 |  |  |       crc_i : in  std_logic_vector(15 downto 0);
 | 
      
         | 512 |  |  |       crc_o : out std_logic_vector(15 downto 0));
 | 
      
         | 513 |  |  |   end component;
 | 
      
         | 514 |  |  |  
 | 
      
         | 515 | 36 | magro732 |   type StateType is (IDLE,
 | 
      
         | 516 |  |  |                      HEADER_GET, HEADER_ACK,
 | 
      
         | 517 |  |  |                      DESTINATION_GET, DESTINATION_ACK,
 | 
      
         | 518 |  |  |                      SOURCE_GET, SOURCE_ACK,
 | 
      
         | 519 | 44 | magro732 |                      CONTENT_GET, CONTENT_ACK,
 | 
      
         | 520 |  |  |                      CRC_APPEND, CRC_UPDATE, CRC_LAST, SEND_FRAME,
 | 
      
         | 521 | 36 | magro732 |                      RESTART_FRAME, WAIT_UPDATE);
 | 
      
         | 522 |  |  |   signal state : StateType;
 | 
      
         | 523 | 44 | magro732 |   signal packetPosition : natural range 0 to 69;
 | 
      
         | 524 | 36 | magro732 |  
 | 
      
         | 525 | 44 | magro732 |   signal temp : std_logic_vector(15 downto 0);
 | 
      
         | 526 |  |  |  
 | 
      
         | 527 | 36 | magro732 |   signal tt : std_logic_vector(1 downto 0);
 | 
      
         | 528 | 38 | magro732 |   signal dstAddr : std_logic_vector(7 downto 0);
 | 
      
         | 529 | 37 | magro732 |  
 | 
      
         | 530 | 44 | magro732 |   signal writeContent : std_logic;
 | 
      
         | 531 |  |  |   signal writeContentData1 : std_logic_vector(31 downto 0);
 | 
      
         | 532 |  |  |   signal writeContentData2 : std_logic_vector(31 downto 0);
 | 
      
         | 533 |  |  |  
 | 
      
         | 534 |  |  |   signal crcReset : std_logic;
 | 
      
         | 535 | 34 | magro732 |   signal crc16Current, crc16Temp, crc16Next: std_logic_vector(15 downto 0);
 | 
      
         | 536 |  |  |  
 | 
      
         | 537 |  |  | begin
 | 
      
         | 538 |  |  |  
 | 
      
         | 539 | 44 | magro732 |   writeContent_o <= writeContent;
 | 
      
         | 540 |  |  |   writeContentData_o <= writeContentData1;
 | 
      
         | 541 |  |  |  
 | 
      
         | 542 | 37 | magro732 |  
 | 
      
         | 543 | 34 | magro732 |   process(clk, areset_n)
 | 
      
         | 544 |  |  |   begin
 | 
      
         | 545 |  |  |     if (areset_n = '0') then
 | 
      
         | 546 | 44 | magro732 |       crc16Current <= x"0000";
 | 
      
         | 547 |  |  |     elsif (clk'event and clk = '1') then
 | 
      
         | 548 |  |  |       if (crcReset = '1') then
 | 
      
         | 549 |  |  |         crc16Current <= x"ffff";
 | 
      
         | 550 |  |  |       elsif (writeContent = '1') then
 | 
      
         | 551 |  |  |         crc16Current <= crc16Next;
 | 
      
         | 552 |  |  |       end if;
 | 
      
         | 553 |  |  |     end if;
 | 
      
         | 554 |  |  |   end process;
 | 
      
         | 555 |  |  |  
 | 
      
         | 556 |  |  |   process(clk, areset_n)
 | 
      
         | 557 |  |  |   begin
 | 
      
         | 558 |  |  |     if (areset_n = '0') then
 | 
      
         | 559 | 36 | magro732 |       state <= IDLE;
 | 
      
         | 560 | 44 | magro732 |       packetPosition <= 0;
 | 
      
         | 561 | 38 | magro732 |  
 | 
      
         | 562 | 44 | magro732 |       tt <= (others=>'0');
 | 
      
         | 563 |  |  |       dstAddr <= (others=>'0');
 | 
      
         | 564 |  |  |  
 | 
      
         | 565 |  |  |       temp <= (others=>'0');
 | 
      
         | 566 |  |  |       writeContent <= '0';
 | 
      
         | 567 |  |  |       writeContentData1 <= (others=>'0');
 | 
      
         | 568 |  |  |       writeContentData2 <= (others=>'0');
 | 
      
         | 569 |  |  |  
 | 
      
         | 570 |  |  |       crcReset <= '0';
 | 
      
         | 571 |  |  |  
 | 
      
         | 572 | 45 | magro732 |       outboundAck_o <= '0';
 | 
      
         | 573 | 38 | magro732 |  
 | 
      
         | 574 |  |  |       writeFrame_o <= '0';
 | 
      
         | 575 |  |  |       writeFrameAbort_o <= '0';
 | 
      
         | 576 | 34 | magro732 |     elsif (clk'event and clk = '1') then
 | 
      
         | 577 | 44 | magro732 |       writeContent <= '0';
 | 
      
         | 578 | 34 | magro732 |       writeFrame_o <= '0';
 | 
      
         | 579 |  |  |  
 | 
      
         | 580 | 44 | magro732 |       crcReset <= '0';
 | 
      
         | 581 |  |  |  
 | 
      
         | 582 | 34 | magro732 |       case state is
 | 
      
         | 583 |  |  |         when IDLE =>
 | 
      
         | 584 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 585 |  |  |           -- 
 | 
      
         | 586 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 587 | 35 | magro732 |           packetPosition <= 0;
 | 
      
         | 588 | 44 | magro732 |           crcReset <= '1';
 | 
      
         | 589 | 34 | magro732 |           if (writeFrameFull_i = '0') then
 | 
      
         | 590 |  |  |             state <= HEADER_GET;
 | 
      
         | 591 |  |  |           end if;
 | 
      
         | 592 |  |  |  
 | 
      
         | 593 | 36 | magro732 |         when HEADER_GET =>
 | 
      
         | 594 | 34 | magro732 |           ---------------------------------------------------------------------
 | 
      
         | 595 |  |  |           -- 
 | 
      
         | 596 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 597 | 45 | magro732 |           if ((outboundCyc_i = '1') and (outboundStb_i = '1')) then
 | 
      
         | 598 |  |  |             temp <= outboundDat_i(15 downto 0);
 | 
      
         | 599 |  |  |             tt <= outboundDat_i(5 downto 4);
 | 
      
         | 600 | 37 | magro732 |  
 | 
      
         | 601 | 45 | magro732 |             outboundAck_o <= '1';
 | 
      
         | 602 | 34 | magro732 |             state <= HEADER_ACK;
 | 
      
         | 603 |  |  |           else
 | 
      
         | 604 | 38 | magro732 |             state <= HEADER_GET;
 | 
      
         | 605 | 34 | magro732 |           end if;
 | 
      
         | 606 |  |  |  
 | 
      
         | 607 |  |  |         when HEADER_ACK =>
 | 
      
         | 608 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 609 |  |  |           -- 
 | 
      
         | 610 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 611 | 45 | magro732 |           outboundAck_o <= '0';
 | 
      
         | 612 | 34 | magro732 |           state <= DESTINATION_GET;
 | 
      
         | 613 |  |  |  
 | 
      
         | 614 |  |  |         when DESTINATION_GET =>
 | 
      
         | 615 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 616 |  |  |           -- 
 | 
      
         | 617 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 618 |  |  |  
 | 
      
         | 619 | 45 | magro732 |           if ((outboundCyc_i = '1') and (outboundStb_i = '1')) then
 | 
      
         | 620 | 44 | magro732 |             if (tt = "01") then
 | 
      
         | 621 | 45 | magro732 |               writeContentData2 <= temp & outboundDat_i(15 downto 0);
 | 
      
         | 622 | 34 | magro732 |             else
 | 
      
         | 623 | 44 | magro732 |               report "TT-field not supported." severity error;
 | 
      
         | 624 | 34 | magro732 |             end if;
 | 
      
         | 625 |  |  |  
 | 
      
         | 626 | 45 | magro732 |             outboundAck_o <= '1';
 | 
      
         | 627 | 34 | magro732 |             state <= DESTINATION_ACK;
 | 
      
         | 628 |  |  |           else
 | 
      
         | 629 |  |  |             state <= RESTART_FRAME;
 | 
      
         | 630 |  |  |           end if;
 | 
      
         | 631 |  |  |  
 | 
      
         | 632 |  |  |         when DESTINATION_ACK =>
 | 
      
         | 633 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 634 |  |  |           -- 
 | 
      
         | 635 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 636 | 45 | magro732 |           outboundAck_o <= '0';
 | 
      
         | 637 | 34 | magro732 |           state <= SOURCE_GET;
 | 
      
         | 638 |  |  |  
 | 
      
         | 639 |  |  |         when SOURCE_GET =>
 | 
      
         | 640 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 641 |  |  |           -- 
 | 
      
         | 642 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 643 |  |  |  
 | 
      
         | 644 | 45 | magro732 |           if ((outboundCyc_i = '1') and (outboundStb_i = '1')) then
 | 
      
         | 645 | 44 | magro732 |             if (tt = "01") then
 | 
      
         | 646 | 45 | magro732 |               temp <= outboundDat_i(15 downto 0);
 | 
      
         | 647 | 34 | magro732 |             end if;
 | 
      
         | 648 |  |  |  
 | 
      
         | 649 | 45 | magro732 |             outboundAck_o <= '1';
 | 
      
         | 650 | 34 | magro732 |             state <= SOURCE_ACK;
 | 
      
         | 651 |  |  |           else
 | 
      
         | 652 |  |  |             state <= RESTART_FRAME;
 | 
      
         | 653 |  |  |           end if;
 | 
      
         | 654 |  |  |  
 | 
      
         | 655 |  |  |         when SOURCE_ACK =>
 | 
      
         | 656 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 657 |  |  |           -- 
 | 
      
         | 658 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 659 | 45 | magro732 |           outboundAck_o <= '0';
 | 
      
         | 660 | 34 | magro732 |           state <= CONTENT_GET;
 | 
      
         | 661 |  |  |  
 | 
      
         | 662 |  |  |         when CONTENT_GET =>
 | 
      
         | 663 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 664 |  |  |           -- 
 | 
      
         | 665 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 666 | 45 | magro732 |           if ((outboundCyc_i = '1') and (outboundStb_i = '1')) then
 | 
      
         | 667 | 44 | magro732 |             if (packetPosition < 19) then
 | 
      
         | 668 |  |  |               if (tt = "01") then
 | 
      
         | 669 | 45 | magro732 |                 writeContentData2 <= temp & outboundDat_i(31 downto 16);
 | 
      
         | 670 |  |  |                 temp <= outboundDat_i(15 downto 0);
 | 
      
         | 671 |  |  |                 outboundAck_o <= '1';
 | 
      
         | 672 | 44 | magro732 |               end if;
 | 
      
         | 673 |  |  |             elsif (packetPosition = 19) then
 | 
      
         | 674 |  |  |               if (tt = "01") then
 | 
      
         | 675 |  |  |                 writeContentData2 <= crc16Next & temp;
 | 
      
         | 676 |  |  |               end if;
 | 
      
         | 677 | 37 | magro732 |             else
 | 
      
         | 678 | 44 | magro732 |               if (tt = "01") then
 | 
      
         | 679 | 45 | magro732 |                 writeContentData2 <= outboundDat_i;
 | 
      
         | 680 |  |  |                 outboundAck_o <= '1';
 | 
      
         | 681 | 44 | magro732 |               end if;
 | 
      
         | 682 | 34 | magro732 |             end if;
 | 
      
         | 683 | 44 | magro732 |             writeContent <= '1';
 | 
      
         | 684 |  |  |             writeContentData1 <= writeContentData2;
 | 
      
         | 685 |  |  |             packetPosition <= packetPosition + 1;
 | 
      
         | 686 | 34 | magro732 |             state <= CONTENT_ACK;
 | 
      
         | 687 |  |  |           else
 | 
      
         | 688 |  |  |             state <= CRC_APPEND;
 | 
      
         | 689 |  |  |           end if;
 | 
      
         | 690 | 44 | magro732 |  
 | 
      
         | 691 | 34 | magro732 |         when CONTENT_ACK =>
 | 
      
         | 692 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 693 |  |  |           -- 
 | 
      
         | 694 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 695 | 44 | magro732 |           if (packetPosition = 20) then
 | 
      
         | 696 |  |  |             if (tt = "01") then
 | 
      
         | 697 |  |  |               writeContentData2 <= crc16Next & temp;
 | 
      
         | 698 |  |  |             end if;
 | 
      
         | 699 |  |  |           end if;
 | 
      
         | 700 | 45 | magro732 |           outboundAck_o <= '0';
 | 
      
         | 701 | 44 | magro732 |           state <= CONTENT_GET;
 | 
      
         | 702 | 34 | magro732 |  
 | 
      
         | 703 | 44 | magro732 |         when CRC_APPEND =>
 | 
      
         | 704 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 705 |  |  |           -- 
 | 
      
         | 706 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 707 |  |  |           if (packetPosition < 19) then
 | 
      
         | 708 |  |  |             if (tt = "01") then
 | 
      
         | 709 |  |  |               writeContent <= '1';
 | 
      
         | 710 |  |  |               writeContentData1 <= writeContentData2;
 | 
      
         | 711 | 34 | magro732 |               packetPosition <= packetPosition + 1;
 | 
      
         | 712 |  |  |             end if;
 | 
      
         | 713 | 44 | magro732 |           elsif (packetPosition = 19) then
 | 
      
         | 714 |  |  |             if (tt = "01") then
 | 
      
         | 715 |  |  |               writeContent <= '1';
 | 
      
         | 716 |  |  |               writeContentData1 <= writeContentData2;
 | 
      
         | 717 |  |  |               packetPosition <= packetPosition + 1;
 | 
      
         | 718 |  |  |             end if;
 | 
      
         | 719 |  |  |           else
 | 
      
         | 720 |  |  |             if (tt = "01") then
 | 
      
         | 721 |  |  |               writeContentData1 <= writeContentData2(31 downto 16) & x"0000";
 | 
      
         | 722 |  |  |               packetPosition <= packetPosition + 1;
 | 
      
         | 723 |  |  |             end if;
 | 
      
         | 724 | 34 | magro732 |           end if;
 | 
      
         | 725 | 44 | magro732 |           state <= CRC_UPDATE;
 | 
      
         | 726 | 34 | magro732 |  
 | 
      
         | 727 | 44 | magro732 |         when CRC_UPDATE =>
 | 
      
         | 728 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 729 |  |  |           -- 
 | 
      
         | 730 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 731 |  |  |           state <= CRC_LAST;
 | 
      
         | 732 | 34 | magro732 |  
 | 
      
         | 733 | 44 | magro732 |         when CRC_LAST =>
 | 
      
         | 734 | 34 | magro732 |           ---------------------------------------------------------------------
 | 
      
         | 735 |  |  |           -- 
 | 
      
         | 736 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 737 | 44 | magro732 |           if (packetPosition < 19) then
 | 
      
         | 738 |  |  |             if (tt = "01") then
 | 
      
         | 739 |  |  |               writeContent <= '1';
 | 
      
         | 740 |  |  |               writeContentData1 <= crc16Current & x"0000";
 | 
      
         | 741 |  |  |             end if;
 | 
      
         | 742 |  |  |           elsif (packetPosition = 19) then
 | 
      
         | 743 |  |  |             if (tt = "01") then
 | 
      
         | 744 |  |  |  
 | 
      
         | 745 |  |  |             end if;
 | 
      
         | 746 |  |  |           else
 | 
      
         | 747 |  |  |             if (tt = "01") then
 | 
      
         | 748 |  |  |               writeContent <= '1';
 | 
      
         | 749 |  |  |               writeContentData1 <= writeContentData2(31 downto 16) & crc16Temp;
 | 
      
         | 750 |  |  |               packetPosition <= packetPosition + 1;
 | 
      
         | 751 |  |  |             end if;
 | 
      
         | 752 | 34 | magro732 |           end if;
 | 
      
         | 753 | 44 | magro732 |  
 | 
      
         | 754 | 34 | magro732 |           state <= SEND_FRAME;
 | 
      
         | 755 | 44 | magro732 |  
 | 
      
         | 756 | 34 | magro732 |         when SEND_FRAME =>
 | 
      
         | 757 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 758 |  |  |           -- 
 | 
      
         | 759 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 760 |  |  |           writeFrame_o <= '1';
 | 
      
         | 761 |  |  |           state <= WAIT_UPDATE;
 | 
      
         | 762 |  |  |  
 | 
      
         | 763 |  |  |         when RESTART_FRAME =>
 | 
      
         | 764 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 765 |  |  |           -- 
 | 
      
         | 766 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 767 |  |  |           writeFrameAbort_o <= '1';
 | 
      
         | 768 |  |  |           state <= WAIT_UPDATE;
 | 
      
         | 769 |  |  |  
 | 
      
         | 770 |  |  |         when WAIT_UPDATE =>
 | 
      
         | 771 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 772 |  |  |           -- 
 | 
      
         | 773 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 774 | 38 | magro732 |           writeFrameAbort_o <= '0';
 | 
      
         | 775 | 34 | magro732 |           state <= IDLE;
 | 
      
         | 776 |  |  |  
 | 
      
         | 777 |  |  |         when others =>
 | 
      
         | 778 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 779 |  |  |           -- 
 | 
      
         | 780 |  |  |           ---------------------------------------------------------------------
 | 
      
         | 781 |  |  |       end case;
 | 
      
         | 782 |  |  |     end if;
 | 
      
         | 783 |  |  |   end process;
 | 
      
         | 784 |  |  |  
 | 
      
         | 785 |  |  |   -----------------------------------------------------------------------------
 | 
      
         | 786 |  |  |   -- Packet CRC calculation.
 | 
      
         | 787 |  |  |   -----------------------------------------------------------------------------
 | 
      
         | 788 |  |  |  
 | 
      
         | 789 |  |  |   Crc16High: Crc16CITT
 | 
      
         | 790 |  |  |     port map(
 | 
      
         | 791 | 44 | magro732 |       d_i=>writeContentData1(31 downto 16), crc_i=>crc16Current, crc_o=>crc16Temp);
 | 
      
         | 792 | 34 | magro732 |   Crc16Low: Crc16CITT
 | 
      
         | 793 |  |  |     port map(
 | 
      
         | 794 | 44 | magro732 |       d_i=>writeContentData1(15 downto 0), crc_i=>crc16Temp, crc_o=>crc16Next);
 | 
      
         | 795 | 34 | magro732 |  
 | 
      
         | 796 |  |  | end architecture;
 | 
      
         | 797 | 45 | magro732 |  
 | 
      
         | 798 |  |  |  
 | 
      
         | 799 |  |  |  
 | 
      
         | 800 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 801 |  |  | -- 
 | 
      
         | 802 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 803 |  |  |  
 | 
      
         | 804 |  |  | library ieee;
 | 
      
         | 805 |  |  | use ieee.std_logic_1164.all;
 | 
      
         | 806 |  |  | use ieee.numeric_std.all;
 | 
      
         | 807 |  |  | use work.rio_common.all;
 | 
      
         | 808 |  |  |  
 | 
      
         | 809 |  |  |  
 | 
      
         | 810 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 811 |  |  | -- 
 | 
      
         | 812 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 813 |  |  | entity RioLogicalCommonInterconnect is
 | 
      
         | 814 |  |  |   generic(
 | 
      
         | 815 |  |  |     WIDTH : natural);
 | 
      
         | 816 |  |  |   port(
 | 
      
         | 817 |  |  |     clk : in std_logic;
 | 
      
         | 818 |  |  |     areset_n : in std_logic;
 | 
      
         | 819 |  |  |  
 | 
      
         | 820 |  |  |     stb_i : in std_logic_vector(WIDTH-1 downto 0);
 | 
      
         | 821 |  |  |     dataM_i : in std_logic_vector(32*WIDTH-1 downto 0);
 | 
      
         | 822 |  |  |     ack_o : out std_logic_vector(WIDTH-1 downto 0);
 | 
      
         | 823 |  |  |  
 | 
      
         | 824 |  |  |     stb_o : out std_logic;
 | 
      
         | 825 |  |  |     dataS_o : out std_logic_vector(31 downto 0);
 | 
      
         | 826 |  |  |     ack_i : in std_logic);
 | 
      
         | 827 |  |  | end entity;
 | 
      
         | 828 |  |  |  
 | 
      
         | 829 |  |  |  
 | 
      
         | 830 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 831 |  |  | -- 
 | 
      
         | 832 |  |  | -------------------------------------------------------------------------------
 | 
      
         | 833 |  |  | architecture RioLogicalCommonInterconnectImpl of RioLogicalCommonInterconnect is
 | 
      
         | 834 |  |  |   signal activeCycle : std_logic;
 | 
      
         | 835 |  |  |   signal selectedMaster : natural range 0 to WIDTH-1;
 | 
      
         | 836 |  |  | begin
 | 
      
         | 837 |  |  |  
 | 
      
         | 838 |  |  |   -----------------------------------------------------------------------------
 | 
      
         | 839 |  |  |   -- Arbitration.
 | 
      
         | 840 |  |  |   -----------------------------------------------------------------------------
 | 
      
         | 841 |  |  |   Arbiter: process(areset_n, clk)
 | 
      
         | 842 |  |  |   begin
 | 
      
         | 843 |  |  |     if (areset_n = '0') then
 | 
      
         | 844 |  |  |       activeCycle <= '0';
 | 
      
         | 845 |  |  |       selectedMaster <= 0;
 | 
      
         | 846 |  |  |     elsif (clk'event and clk = '1') then
 | 
      
         | 847 |  |  |       if (activeCycle = '0') then
 | 
      
         | 848 |  |  |         for i in 0 to WIDTH-1 loop
 | 
      
         | 849 |  |  |           if (stb_i(i) = '1') then
 | 
      
         | 850 |  |  |             activeCycle <= '1';
 | 
      
         | 851 |  |  |             selectedMaster <= i;
 | 
      
         | 852 |  |  |           end if;
 | 
      
         | 853 |  |  |         end loop;
 | 
      
         | 854 |  |  |       else
 | 
      
         | 855 |  |  |         if (stb_i(selectedMaster) = '0') then
 | 
      
         | 856 |  |  |           activeCycle <= '0';
 | 
      
         | 857 |  |  |         end if;
 | 
      
         | 858 |  |  |       end if;
 | 
      
         | 859 |  |  |     end if;
 | 
      
         | 860 |  |  |   end process;
 | 
      
         | 861 |  |  |  
 | 
      
         | 862 |  |  |   -----------------------------------------------------------------------------
 | 
      
         | 863 |  |  |   -- Interconnection.
 | 
      
         | 864 |  |  |   -----------------------------------------------------------------------------
 | 
      
         | 865 |  |  |   stb_o <= stb_i(selectedMaster) and activeCycle;
 | 
      
         | 866 |  |  |   dataS_o <= dataM_i(32*(selectedMaster+1)-1 downto 32*selectedMaster);
 | 
      
         | 867 |  |  |  
 | 
      
         | 868 |  |  |   Interconnect: for i in 0 to WIDTH-1 generate
 | 
      
         | 869 |  |  |     ack_o(i) <= ack_i when (selectedMaster = i) else '0';
 | 
      
         | 870 |  |  |   end generate;
 | 
      
         | 871 |  |  |  
 | 
      
         | 872 |  |  | end architecture;
 | 
      
         | 873 |  |  |  
 | 
      
         | 874 |  |  |  
 |