Skip to content
Snippets Groups Projects
pkg_combpm_stream.vhd 2.85 KiB
Newer Older
library ieee;
use ieee.std_logic_1164.all;

package pkg_bpmframe_stream is
BRONES Romain's avatar
BRONES Romain committed
    ----------------------
    -- MACRO PARAMETERS --
    ----------------------
    constant C_TDEST_W : natural := 7;
    constant C_TDATA_W : natural := 128;

    ---------------------------------
    -- AXIS MASTER/SLAVE INTERFACE --
    ---------------------------------
    type t_bpmframe_axis_m2s is record
        tdest  : std_logic_vector(C_TDEST_W-1 downto 0);
        tdata  : std_logic_vector(C_TDATA_W-1 downto 0);
        tlast  : std_logic;
        tvalid : std_logic;
        ---tid    : std_logic_vector(0 downto 0);
        --tuser  : std_logic_vector(0 downto 0);
        --tstrb  : std_logic_vector(15 downto 0);
        --tkeep  : std_logic_vector(15 downto 0);
    end record t_bpmframe_axis_m2s;
    type t_bpmframe_axis_s2m is record
        tready : std_logic;
    end record t_bpmframe_axis_s2m;
    subtype t_bpmframe_m_axis_out is t_bpmframe_axis_m2s;
    subtype t_bpmframe_s_axis_in  is t_bpmframe_axis_m2s;
    subtype t_bpmframe_m_axis_in  is t_bpmframe_axis_s2m;
    subtype t_bpmframe_s_axis_out is t_bpmframe_axis_s2m;

    ------------------------
    -- AXIS STREAM PACKET --
    ------------------------
    type t_bpmframe is record
        pos_x                        : std_logic_vector(31 downto 0);
        pos_y                        : std_logic_vector(31 downto 0);
        bpm_id                       : std_logic_vector(15 downto 0);
        mc_timestamp                 : std_logic_vector(39 downto 0);
        fa_seq                       : std_logic_vector(7 downto 0);
    end record t_bpmframe;
    constant C_BPMFRAME_ZERO : t_bpmframe := (
BRONES Romain's avatar
BRONES Romain committed
        pos_x         => (others => '0'),
        pos_y         => (others => '0'),
        bpm_id        => (others => '0'),
        mc_timestamp  => (others => '0'),
        fa_seq        => (others => '0')
        );

    function slv2bpmframe(
        signal tdata : std_logic_vector(C_TDATA_W-1 downto 0)
        )
        return t_bpmframe;
    function bpmframe2slv(
        signal packet : t_bpmframe
        )
        return std_logic_vector;


end package;

package body pkg_bpmframe_stream is
    function slv2bpmframe(
        signal tdata : std_logic_vector(C_TDATA_W-1 downto 0)
        )
        return t_bpmframe is
        variable packet : t_bpmframe;
    begin
        packet.pos_x        := tdata(31 downto 0);
        packet.pos_y        := tdata(63 downto 32);
        packet.bpm_id       := tdata(79 downto 64);
        packet.mc_timestamp := tdata(119 downto 80);
        packet.fa_seq       := tdata(127 downto 120);
        return packet;
    end function;

    function bpmframe2slv(
        signal packet : t_bpmframe
        )
        return std_logic_vector is
    begin
        return packet.fa_seq & packet.mc_timestamp & packet.bpm_id & packet.pos_y & packet.pos_x;
    end function;

end package body;