Conversion: String to std_ulogic_vector

S

Stefan Duenser

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
 
N

Nicolas Matringe

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;
 
Z

zingafriend

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top