2 use ieee.std_logic_1164.all;
8 subtype crnum_t is integer range 0 to 7;
9 subtype crmask_t is std_ulogic_vector(7 downto 0);
11 function fxm_to_num(fxm: crmask_t) return crnum_t;
12 function num_to_fxm(num: crnum_t) return crmask_t;
13 end package crhelpers;
15 package body crhelpers is
17 function fxm_to_num(fxm: crmask_t) return crnum_t is
19 -- If multiple fields are set (undefined), match existing
20 -- hardware by returning the first one.
22 -- Big endian bit numbering
23 if fxm(7-i) = '1' then
28 -- If no fields are set (undefined), also match existing
29 -- hardware by returning cr7.
33 function num_to_fxm(num: crnum_t) return crmask_t is
57 end package body crhelpers;