character to std_logic value

J

jahaya

Hello folks,

Can someone guide me how to convert a chacter to std_logic value ? in
the below mentioned piece of code :it's a test bench to take value from
a file

PROCESS

FILE file_program: text;

VARIABLE command_file: string (1 to SimDir'LENGTH + 17);
VARIABLE data_frame: line;
VARIABLE data_char: character;

BEGIN
command_file := SimDir & "/stimuli/file.dat";

LOOP
WAIT UNTIL reset='0';
ent_cs <= '1';
ent_file <= '0';

file_open(ent_program, command_file, read_mode);

WAIT UNTIL reset='1';
WHILE NOT endfile(ent_program) LOOP
readline(ent_program, ent_frame);

NEXT WHEN ent_frame'LENGTH = 0;

WAIT UNTIL clk_ent='0';

FOR index IN 1 TO ent_frame'LENGTH LOOP
read(ent_frame, data_char);

EXIT WHEN (data_char: /='0' AND data_char: /='1');

ent_cs <= '0';

WAIT UNTIL clk_ent='0';
ent_file <= I need to change this character type to std_logic value
(data_char); ??????? what type conversion we can use here?

END LOOP;

ent_cs <= '1';

END LOOP;

file_close(ent_program);

END LOOP;

END PROCESS;


Thanks
Regards,
ALI
 
R

Reiner Huober

Can someone guide me how to convert a chacter to std_logic value ?

If you use VHDL'93, you can use the 'value attribut of a type T. You
must first convert your character into a string:

std_logic s;
character c;

s<=std_logic'value("'"& c & "'");


(untested)

Hubble
 
M

Mike Treseler

Can someone guide me how to convert a chacter to std_logic value ?

function char2std(arg : character)
return std_logic_vector is
begin
return std_logic_vector(to_unsigned(char2int(arg), 8));
end char2std;

-- Mike Treseler
 
M

Mike Treseler

function char2int(arg : character)
return natural is
begin
return character'pos(arg);
end char2int;
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top