-- MIPS I system -- Copyright 2011-2012 Stefan Schuermans -- Copyleft GNU public license V2 or later -- http://www.gnu.org/copyleft/gpl.html LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.numeric_std.all; PACKAGE io_switches_pins IS TYPE t_io_switches_pins IS RECORD sw: std_logic_vector(3 DOWNTO 0); east: std_logic; north: std_logic; south: std_logic; west: std_logic; center: std_logic; rot_a: std_logic; rot_b: std_logic; END RECORD; CONSTANT c_io_switches_pins_default: t_io_switches_pins := ( sw => "0000", east => '0', north => '0', south => '0', west => '0', center => '0', rot_a => '1', rot_b => '1' ); FUNCTION io_switches_to_slv(switches: t_io_switches_pins) RETURN std_logic_vector; FUNCTION io_switches_from_slv(slv: std_logic_vector(31 DOWNTO 0)) RETURN t_io_switches_pins; END PACKAGE io_switches_pins; PACKAGE BODY io_switches_pins IS FUNCTION io_switches_to_slv(switches: t_io_switches_pins) RETURN std_logic_vector IS VARIABLE v_slv: std_logic_vector(31 DOWNTO 0); BEGIN v_slv( 3 DOWNTO 0) := switches.sw; v_slv( 7 DOWNTO 4) := (OTHERS => '0'); v_slv( 8) := switches.east; v_slv( 9) := switches.north; v_slv(10) := switches.south; v_slv(11) := switches.west; v_slv(15 DOWNTO 12) := (OTHERS => '0'); v_slv(16) := switches.center; v_slv(23 DOWNTO 17) := (OTHERS => '0'); v_slv(24) := switches.rot_a; v_slv(25) := switches.rot_b; v_slv(31 DOWNTO 26) := (OTHERS => '0'); RETURN v_slv; END FUNCTION io_switches_to_slv; FUNCTION io_switches_from_slv(slv: std_logic_vector(31 DOWNTO 0)) RETURN t_io_switches_pins IS VARIABLE v_switches: t_io_switches_pins; BEGIN v_switches.sw := slv( 3 DOWNTO 0); v_switches.east := slv( 8); v_switches.north := slv( 9); v_switches.south := slv(10); v_switches.west := slv(11); v_switches.center := slv(16); v_switches.rot_a := slv(24); v_switches.rot_b := slv(25); RETURN v_switches; END FUNCTION io_switches_from_slv; END PACKAGE BODY io_switches_pins;