Conversion: String to std_ulogic_vector

S

Stefan Duenser

Guest
Hello

I have a file and read out the values: The values are presented in binary
form: 00110011
I want to assign this value to a std_ulogic_signal(7 downto 0), but
unfortunately I have found so far only functions which convert
integers to std_ulogic_vector. Anybody knows which function I should use
here?

Thanks a lot!

Stephan
 
Stefan Duenser a écrit:
Hello

I have a file and read out the values: The values are presented in binary
form: 00110011
I want to assign this value to a std_ulogic_signal(7 downto 0), but
unfortunately I have found so far only functions which convert
integers to std_ulogic_vector. Anybody knows which function I should use
here?
Hi
I don't know about such a function but you can write your own:

function to_slv(s:string) return std_logic_vector is
variable slv : std_logic_vector(s'length - 1 downto 0);
begin
for i in slv'range loop
case s(i) is
when '0' => slv(i) <= '0';
when '1' => slv(i) <= '1';
when 'Z' => slv(i) <= 'Z';
when 'X' => slv(i) <= 'X';
when 'U' => slv(i) <= 'U';
when 'H' => slv(i) <= 'H';
when 'L' => slv(i) <= 'L';
when 'W' => slv(i) <= 'W';
when '-' => slv(i) <= '-';
when others => null;
end case;
end loop;
return slv;
end to_slv;

--
____ _ __ ___
| _ \_)/ _|/ _ \ Adresse de retour invalide: retirez le -
| | | | | (_| |_| | Invalid return address: remove the -
|_| |_|_|\__|\___/
 
FUNCTION To_StdULogic ( b : BIT ) RETURN std_ulogic;
FUNCTION To_StdLogicVector ( b : BIT_VECTOR ) RETURN std_logic_vector;
These two functions are available in ieee.std_logic_1164.all library.
 

Welcome to EDABoard.com

Sponsor

Back
Top