exjobb-public/src/manager/management_unit_pkg.vhd

59 lines
2.3 KiB
VHDL

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.NUMERIC_STD.all;
use IEEE.MATH_REAL.all;
library gan_ganimede;
use gan_ganimede.io_types.all;
package management_types is
constant WORD_SIZE : natural := 32;
-- Amount to right shift addres to convert e.g 0x00000004 to 0x00000001 for 32-bit words
constant address_shift : natural := natural(CEIL(LOG2(real(WORD_SIZE) / real(8))));
type manager_word_t is record
address: std_logic_vector(21 downto 0);
size: std_logic_vector(3 downto 0);
command: std_logic_vector(2 downto 0);
reserved: std_logic_vector(WORD_SIZE - 1 - (22 + 4 + 3) downto 0);
end record manager_word_t;
constant empty_word : std_logic_vector(WORD_SIZE - 1 downto 0) := (others => '0');
constant mem_words : natural := 2;
constant min_bits_to_determine_address : natural := natural(CEIL(LOG2(real(mem_words))));
constant address_mask : std_logic_vector(WORD_SIZE - 1 downto 0) := std_logic_vector(to_unsigned(mem_words - 1, 32));
type memory_t is array (0 to mem_words - 1) of manager_word_t;
-- Index in memory array where memory read address is kept.
-- Read is active while it is not all zero.
constant read_address_index : std_logic_vector(WORD_SIZE - 1 downto 0) := x"00000000";
-- Index in memory array where memory write address is kept.
-- Write is active while it is not all zero. Mutex with read address
constant write_address_index : std_logic_vector(WORD_SIZE - 1 downto 0) := x"00000001";
-- Status register for debugging
type manager_state_t is record
memory : memory_t;
data_out : manager_word_t;
end record manager_state_t;
-- reset value of status register
constant manager_word_reset_val : manager_word_t := (
address => (others =>'0'),
size => (others => '0'),
command => (others => '0'),
reserved => (others => '0')
);
constant manager_state_reset_val : manager_state_t := ((others => manager_word_reset_val), manager_word_reset_val);
type socbridge_driver_to_manager_t is record
address : std_logic_vector(WORD_SIZE - 1 downto 0);
data : std_logic_vector(WORD_SIZE - 1 downto 0);
valid: std_logic;
end record socbridge_driver_to_manager_t;
type manager_to_socbridge_driver_t is record
data : std_logic_vector(WORD_SIZE - 1 downto 0);
valid : std_logic;
ready : std_logic;
end record manager_to_socbridge_driver_t;
end package;