---------------------------------------------------------------------------
-- File           : p_interfaces.vhd
-- Author(s)      : Nikola Avramovic
-- Created        : March 11th, 2019
---------------------------------------------------------------------------
-- Description    : Hardware tesetr Interfaces 
---------------------------------------------------------------------------

---------------------------------------------------------------------------

library ieee;
   use ieee.std_logic_1164.all;
   use ieee.numeric_std.all;
   use work.p_parameters_and_constants.all;

package p_interfaces is
    
   ----------------------------------------------------------------
   -- Avalon Memory Map interface
   ----------------------------------------------------------------
   type TYPE_AVALON_MM_MASTER_TO_SLAVE is record
       address            : std_logic_vector (C_AVALON_MM_ADDR_WIDTH-1 downto 0);
       write              : std_logic;
       writedata          : std_logic_vector (C_AVALON_MM_DATA_WIDTH-1 downto 0);
       read               : std_logic;
       beginbursttransfer : std_logic;
       burstcount         : std_logic_vector(C_BURSTCOUNT_WIDTH-1 downto 0);
       byteenable         : std_logic_vector(C_BYTES_PER_WORD-1 downto 0);
   end record;

   type TYPE_AVALON_MM_MASTER_TO_SLAVE_ARRAY is array (natural range <>) of TYPE_AVALON_MM_MASTER_TO_SLAVE;

   constant C_AVALON_MM_MASTER_TO_SLAVE : TYPE_AVALON_MM_MASTER_TO_SLAVE := (
      address            => (others => '0'),
      write              => '0',
      writedata          => (others => '0'),
      read               => '0',
      beginbursttransfer => '0',
      burstcount         => (others => '0'),
      byteenable         => (others => '0')
   );
   
   type TYPE_AVALON_MM_SLAVE_TO_MASTER is record
      readdatavalid      : std_logic;
      readdata           : std_logic_vector (C_AVALON_MM_DATA_WIDTH-1 downto 0);
      waitrequest        : std_logic;
   end record;

   type TYPE_AVALON_MM_SLAVE_TO_MASTER_ARRAY is array (natural range <>) of TYPE_AVALON_MM_SLAVE_TO_MASTER;

   constant C_AVALON_MM_SLAVE_TO_MASTER : TYPE_AVALON_MM_SLAVE_TO_MASTER := (
      readdatavalid      => '0',
      readdata           => (others => '0'),
      waitrequest        => '0'
   );
   
   ----------------------------------------------------------------
   -- Avalon Streaming interface
   ----------------------------------------------------------------
   type TYPE_AVALON_ST_SOURCE_TO_SINK is record
       valid             : std_logic;
       sop               : std_logic;
       eop               : std_logic;
       data              : std_logic_vector(C_AVALON_ST_DATA_WIDTH - 1 downto 0);
   end record;

   type TYPE_AVALON_ST_SOURCE_TO_SINK_ARRAY is array (natural range <>) of TYPE_AVALON_ST_SOURCE_TO_SINK;
   
   constant C_AVALON_ST_SOURCE_TO_SINK  : TYPE_AVALON_ST_SOURCE_TO_SINK := (
       valid             => '0',
       sop               => '0',
       eop               => '0',
       data              => (others => '0')
   );

   type TYPE_AVALON_ST_SINK_TO_SOURCE is record
       ready             :  std_logic;
   end record;
   
   type TYPE_AVALON_ST_SINK_TO_SOURCE_ARRAY is array (natural range <>) of TYPE_AVALON_ST_SINK_TO_SOURCE;

   constant C_AVALON_ST_SINK_TO_SOURCE  : TYPE_AVALON_ST_SINK_TO_SOURCE := (
       ready             => '0'
   );  
   
end package;
