character to std_logic value

Discussion in 'VHDL' started by jahaya@gmail.com, Apr 25, 2006.

  1. Guest

    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 <= To_Std_Logic(data_char);

    END LOOP;

    ent_cs <= '1';

    END LOOP;

    file_close(ent_program);

    END LOOP;

    END PROCESS;


    Thanks
    Regards,
    ALI
     
    , Apr 25, 2006
    #1
    1. Advertising

  2. How about:

    z <= std_logic_vector (to_unsigned (character'POS ('k'), z'LENGTH));
    -- chararacter could be LF, CR, HT etc.

    Clyde


    wrote:
    > 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 <= To_Std_Logic(data_char);
    >
    > END LOOP;
    >
    > ent_cs <= '1';
    >
    > END LOOP;
    >
    > file_close(ent_program);
    >
    > END LOOP;
    >
    > END PROCESS;
    >
    >
    > Thanks
    > Regards,
    > ALI
    >
     
    Clyde R. Shappee, Apr 30, 2006
    #2
    1. Advertising

  3. Dal Guest

    This seems to work...

    std_logic sl;
    character c;
    string(blah) s;
    integer i;

    sl<=std_logic'value(c & NUL);

    similarly..

    sl<=std_logic'value(s(i) & NUL);
     
    Dal, May 2, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher Bunk

    Synthesis of STD_LOGIC

    Christopher Bunk, Jul 1, 2003, in forum: VHDL
    Replies:
    2
    Views:
    1,356
    Tim Hubberstey
    Jul 4, 2003
  2. zoro
    Replies:
    2
    Views:
    3,107
    =?ISO-8859-1?Q?Nicolai_J=F8rgensen?=
    Jul 5, 2003
  3. valentin tihomirov

    boolean to std_logic

    valentin tihomirov, Dec 31, 2003, in forum: VHDL
    Replies:
    3
    Views:
    14,688
    Mike Treseler
    Jan 5, 2004
  4. Replies:
    3
    Views:
    5,450
    Mike Treseler
    Apr 25, 2006
  5. George2
    Replies:
    2
    Views:
    409
    James Kanze
    Jan 25, 2008
Loading...

Share This Page