-- VHDL code position: p236_ex8_15_DataTypeConvert_example -- Note : This is code for explaining different data type convert of VHDL -- Debug : no debug --------------------------------------------------------------------------------- FUNCTION To_bit ( s : std_ulogic; xamp: BIT :='0' ) -- std_ulogic ?? RETURN BIT; FUNCTION To_bitvector ( s : std_logic_vector; xamp: BIT :='0' ) RETURN BIT_VECTOR; FUNCTION To_bitvector ( s : std_ulogic_vector; xamp: BIT :='0' ) RETURN BIT_VECTOR; ---------------------------------------------------------------- -- -- FUNCTION To_bitvector ( s : std_logic_vector; xamp: BIT :='0' ) RETURN BIT_VECTOR IS ALLAS SV : std_logic_vector ( s'LENGTH -1 DOWNTO 0 ) IS s ; -- ALLAS ?? VARIABLE result : BIT_VECTOR ( s'LENGTH -1 DOWNTO 0 ); BEGIN FOR i IN result'RANGE LOOP CASE sv( i ) IS WHEN '0'|'L' => result( i ) := '0'; WHEN '1'|'H' => result( i ) := '1'; WHEN OTHERS => result( i ) := xamp; END CASE; END LOOP; RETURN result; END FUNCTION;