Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Electronic Equipment > VHDL > std.textio.read...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 14 Topic 6108 of 6417
Post > Topic >>

std.textio.read strange behaviour?!

by pontus.stenstrom@[EMAIL PROTECTED] Jun 24, 2008 at 05:01 AM

I'm reading a text file containing values into a vhdl variable which I
ranged to [0..255].
If the values in the file are outside this range I expected the
simulator to complain,
but it happily reads in "any" integer into my byte, and displays it as
you can try below.
What am I missing? Shouldn't the assignment done in the read procedure
fail?
(tested with both modelsim and aldec - same behaviour)

Name this to a file called t.vhd (including the first comment line):

-- 1 23 456 7890

entity t is
end entity t;

use std.textio.all;

architecture t of t is
begin
  t : process is
    file my_file       : text;
    variable ok        : file_open_status;
    variable my_line   : line;
    variable to_stdout : line;
    variable comment   : string(1 to 2);
    variable good      : boolean := true;
    subtype u8 is integer range 0 to 255;
    variable byte, b2  : u8;
  begin
    file_open(ok, my_file, "t.vhd");
    while (not endfile(my_file)) loop
      readline(my_file, my_line);
      exit when my_line'length = 0;     -- only parse first non empty
lines
      read(my_line, comment);           -- throw comment
      while good loop
        std.textio.read(my_line, byte, good);
        if good then
          -- look at the output, even values larger than 255 are
printed!
          write(to_stdout, integer'image(byte)); writeline(output,
to_stdout);
          b2:= byte;                    -- this assignment works!?
--          b2:= byte+0;                  -- this fails as it should
        end if;
      end loop;
    end loop;
    file_close(my_file);
    wait;
  end process t;
end architecture t;

Regards -- Pontus
 




 14 Posts in Topic:
std.textio.read strange behaviour?!
pontus.stenstrom@[EMAIL P  2008-06-24 05:01:17 
Re: std.textio.read strange behaviour?!
Mike Treseler <mtresel  2008-06-24 07:58:17 
Re: std.textio.read strange behaviour?!
pontus.stenstrom@[EMAIL P  2008-06-24 11:19:14 
Re: std.textio.read strange behaviour?!
pontus.stenstrom@[EMAIL P  2008-06-25 06:23:07 
Re: std.textio.read strange behaviour?!
James Unterburger <jam  2008-06-25 07:57:09 
Re: std.textio.read strange behaviour?!
Mike Treseler <mike_tr  2008-06-25 10:25:29 
Re: std.textio.read strange behaviour?!
James Unterburger <jam  2008-06-25 15:41:47 
Re: std.textio.read strange behaviour?!
Mike Treseler <mike_tr  2008-06-25 16:17:53 
Re: std.textio.read strange behaviour?!
James Unterburger <jam  2008-06-26 08:25:49 
Re: std.textio.read strange behaviour?!
pontus.stenstrom@[EMAIL P  2008-06-25 15:08:12 
Re: std.textio.read strange behaviour?!
James Unterburger <jam  2008-06-26 08:23:49 
Re: std.textio.read strange behaviour?!
pontus.stenstrom@[EMAIL P  2008-06-25 15:15:16 
Re: std.textio.read strange behaviour?!
Mike Treseler <mike_tr  2008-06-25 15:37:07 
Re: std.textio.read strange behaviour?!
KJ <kkjennings@[EMAIL   2008-06-26 10:18:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 8:22:11 CST 2008.