-- Header structure: ----------------------------------------------------------------------------------------------------- --| | | 2bit | 2bit | 2bit | 2bit | 2bit | 2bit | | --| Flit_padding | Packet_id | Z_src | Y_src | X_src | Z_dest | Y_dest | X_dest | Packet_length | --|31 3bits 29|28 12 bits 17|16 6bits 11|10 6bits 5|4 5bits 0| ----------------------------------------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; ----------------------NoC Interface Entity--------------------------- entity Noc_Interface is generic ( SOURCE_ID : std_logic_vector(5 downto 0) := "000000"; -- Default source ID should be changed DEST_ID : std_logic_vector(5 downto 0) := "000001" -- Default destination ID should be changed ); port( clk : in std_logic; rst : in std_logic; Sent_valid_from_DMA : in std_logic; --From DMA Data_bus_noc_in : in std_logic_vector(7 downto 0); --From RAM tx_packet_length_noc : in std_logic_vector(4 downto 0); --From DMA local_noc_rx : in std_logic_vector(31 downto 0);--- --From Noc local_vc_write_tx_noc: in std_logic; ---_vector(192-1 downto 0);--From NoC rx_packet_length_noc : out std_logic_vector(4 downto 0); --To DMA local_noc_tx : out std_logic_vector(31 downto 0);--- --To NoC local_vc_write_rx_noc: out std_logic; ---_vector(192-1 downto 0);--To NoC Receive_valid_to_DMA : out std_logic; --To DMA Sent_Ack_to_DMA : out std_logic_vector(4 downto 0);-----------To DMA Data_bus_noc_out : out std_logic_vector(7 downto 0) --To RAM ); end entity; ----------------------NoC Interface Behaviour------------------------ architecture Noc_Interface_Arch of Noc_Interface is Signal packet_id : std_logic_vector(11 downto 0); signal count : std_logic_vector(4 downto 0); signal Sent_packet : std_logic_vector(4 downto 0); --signal packet_length : std_logic_vector(4 downto 0); begin rxprocess : process(clk, rst) begin if rst = '0' then rx_packet_length_noc <= (others => '0'); local_noc_tx <= (others => '0'); local_vc_write_rx_noc <= (others => '0'); Receive_valid_to_DMA <= (others => '0'); Sent_Ack_to_DMA <= (others => '0'); Data_bus_noc_out <= (others => '0'); count <= (others => '0'); Sent_packet <= (others => '0'); packet_id <= (others => '0'); elsif rising_edge(clk) then --------------------Reading from NoC-------------------------------- if (local_vc_write_tx_noc = '1') then if (local_vc_write_tx_noc(31 downto 29) = "100") then rx_packet_length_noc <= local_vc_write_tx_noc(4 downto 0 ); --packet length count <= (others => '0'); --counter reset packet_id <= local_vc_write_tx_noc(28 downto 17); --current packetid elsif(count < local_vc_write_tx_noc(4 downto 0 )) then Receive_valid_to_DMA <= '1'; --valid to DMA count <= count + 1; --counter update Data_bus_noc_out <= local_vc_write_tx_noc(7 downto 0 ); --NoC is given to RAM else Receive_valid_to_DMA <= '0'; Data_bus_noc_out <= (others=>'0'); count <= (others=>'0'); end if; --------------------Writing to NoC---------------------------------- elsif (Sent_valid_from_DMA = '1' and tx_packet_length_noc > 0) then if(Sent_packet = "00000") then Sent_Ack_to_DMA <= Sent_packet + 1; --to DMA updated value Sent_packet <= Sent_packet + 1; --updating packet id local_noc_tx <= "100" & packet_id & SOURCE_ID & DEST_ID & tx_packet_length_noc; local_vc_write_rx_noc <= '1'; else Sent_Ack_to_DMA <= Sent_packet + 1; --to DMA updated value Sent_packet <= Sent_packet + 1; local_noc_tx <= (others => '0') & Data_bus_noc_in;; --24bit zeros in msb and 8 bit data local_vc_write_rx_noc <= '1'; end if; else rx_packet_length_noc <= (others => '0'); local_noc_tx <= (others => '0'); local_vc_write_rx_noc <= (others => '0'); Receive_valid_to_DMA <= (others => '0'); Sent_Ack_to_DMA <= (others => '0'); Data_bus_noc_out <= (others => '0'); count <= (others => '0'); Sent_packet <= (others => '0'); end if; end if; end process; end architecture;