Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Detect EOL

Reply
Thread Tools

Detect EOL

 
 
johnp
Guest
Posts: n/a
 
      05-12-2008
I have a bench which reads from a regular text file.
Google has not come up with a neat way to detect
EOL so I tried to roll my own - snippets follow.
I am using ModelSimXE.

attempt 1
use std.textio.all
-- Declare boolean variable EOL & set to true in declaration
-- read new char from file
if TxBufEmpty then
if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
if EOL then
READLINE(TxText, aline) ;
char := LF ;
else
EOL := READ(aline, char) ; -- Compile error. No feasible entries for
subprogram "read".
end if ;
writebyte <= char2slv(char) ;
TxByteLoaded := true ;
end if ;
end if ;

attempt 2
-- read new char from file
if TxBufEmpty then
if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
if aline.all'length = 0 then -- Modelsim generates
runtime error or crashes
-- if (aline.all)'length = 0 then -- this doesn't work either
READLINE(TxText, aline) ;
char := CR ;
else
READ(aline, char) ;
end if ;
writebyte <= char2slv(char) ;
TxByteLoaded := true ;
end if ;
end if ;

attempt 3
-- read new char from file
if TxBufEmpty then
if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
if aline = NULL then -- the boolean is never true even when the
debugger says aline is NULL !
READLINE(TxText, aline) ;
char := CR ;
else
READ(aline, char) ;
end if ;
writebyte <= char2slv(char) ;
TxByteLoaded := true ;
end if ;
end if ;

Attempt 1.
Textio has two overloaded procedures under "-- Character reading"
The first procedure appears to return a boolean so why the
compile error for EOL := READ(aline, char) ?;

Attempt 2
So this is not good VHDL then ?
aline.all'length

Attempt 3
If I break on
if aline = NULL then
and examine aline when it is empty Modelsim says it
is NULL, but execution is for a false conditional.
What is going on ?

I have not used ENDLINE() cos I understand it
is deprecated in later LRMs because of a bug. (The
snippets are compiled to LRM'02)

There must be an easy way to find EOL.
But what is it ?

Rgds johnp












 
Reply With Quote
 
 
 
 
johnp
Guest
Posts: n/a
 
      05-12-2008

Please do not explain why attempt 1 failed.
READ() is a procedure, not a function so it
cannot be used as an expression and does
not return anything. Sorry for that

johnp

"johnp" <john.pearson@No_Spam.co.uk> wrote in message
news:4828857d$(E-Mail Removed)...
>I have a bench which reads from a regular text file.
> Google has not come up with a neat way to detect
> EOL so I tried to roll my own - snippets follow.
> I am using ModelSimXE.
>
> attempt 1
> use std.textio.all
> -- Declare boolean variable EOL & set to true in declaration
> -- read new char from file
> if TxBufEmpty then
> if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
> if EOL then
> READLINE(TxText, aline) ;
> char := LF ;
> else
> EOL := READ(aline, char) ; -- Compile error. No feasible entries for
> subprogram "read".
> end if ;
> writebyte <= char2slv(char) ;
> TxByteLoaded := true ;
> end if ;
> end if ;
>
> attempt 2
> -- read new char from file
> if TxBufEmpty then
> if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
> if aline.all'length = 0 then -- Modelsim generates
> runtime error or crashes
> -- if (aline.all)'length = 0 then -- this doesn't work either
> READLINE(TxText, aline) ;
> char := CR ;
> else
> READ(aline, char) ;
> end if ;
> writebyte <= char2slv(char) ;
> TxByteLoaded := true ;
> end if ;
> end if ;
>
> attempt 3
> -- read new char from file
> if TxBufEmpty then
> if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
> if aline = NULL then -- the boolean is never true even when the
> debugger says aline is NULL !
> READLINE(TxText, aline) ;
> char := CR ;
> else
> READ(aline, char) ;
> end if ;
> writebyte <= char2slv(char) ;
> TxByteLoaded := true ;
> end if ;
> end if ;
>
> Attempt 1.
> Textio has two overloaded procedures under "-- Character reading"
> The first procedure appears to return a boolean so why the
> compile error for EOL := READ(aline, char) ?;
>
> Attempt 2
> So this is not good VHDL then ?
> aline.all'length
>
> Attempt 3
> If I break on
> if aline = NULL then
> and examine aline when it is empty Modelsim says it
> is NULL, but execution is for a false conditional.
> What is going on ?
>
> I have not used ENDLINE() cos I understand it
> is deprecated in later LRMs because of a bug. (The
> snippets are compiled to LRM'02)
>
> There must be an easy way to find EOL.
> But what is it ?
>
> Rgds johnp
>
>
>
>
>
>
>
>
>
>
>
>



 
Reply With Quote
 
 
 
 
johnp
Guest
Posts: n/a
 
      05-23-2008
Hmmmmmmmmm.
Poking about with my ModelsimXE 6.2g EOL problem I find that

if aline.all'length = 0 then --
ModelsimXE Crashes
if aline = NULL OR aline.all'length = 0 then -- Detects EOL
fine, Modelsim is OK

johnp

viz:-
if TxBufEmpty then
if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
-- if aline.all'length = 0 then --
Crash
if aline = NULL OR aline.all'length = 0 then -- OK
READLINE(TxText, aline) ;
char := CR ;
else
READ(aline, char) ;
end if ;
writebyte <= char2slv(char) ;
TxByteLoaded := true ;
end if ;
end if ;

"johnp" <john.pearson@No_Spam.co.uk> wrote in message
news:4828bbac$(E-Mail Removed)...
>
> Please do not explain why attempt 1 failed.
> READ() is a procedure, not a function so it
> cannot be used as an expression and does
> not return anything. Sorry for that
>
> johnp
>
> "johnp" <john.pearson@No_Spam.co.uk> wrote in message
> news:4828857d$(E-Mail Removed)...
>>I have a bench which reads from a regular text file.
>> Google has not come up with a neat way to detect
>> EOL so I tried to roll my own - snippets follow.
>> I am using ModelSimXE.
>>
>> attempt 1
>> use std.textio.all
>> -- Declare boolean variable EOL & set to true in declaration
>> -- read new char from file
>> if TxBufEmpty then
>> if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
>> if EOL then
>> READLINE(TxText, aline) ;
>> char := LF ;
>> else
>> EOL := READ(aline, char) ; -- Compile error. No feasible entries for
>> subprogram "read".
>> end if ;
>> writebyte <= char2slv(char) ;
>> TxByteLoaded := true ;
>> end if ;
>> end if ;
>>
>> attempt 2
>> -- read new char from file
>> if TxBufEmpty then
>> if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
>> if aline.all'length = 0 then -- Modelsim generates
>> runtime error or crashes
>> -- if (aline.all)'length = 0 then -- this doesn't work
>> either
>> READLINE(TxText, aline) ;
>> char := CR ;
>> else
>> READ(aline, char) ;
>> end if ;
>> writebyte <= char2slv(char) ;
>> TxByteLoaded := true ;
>> end if ;
>> end if ;
>>
>> attempt 3
>> -- read new char from file
>> if TxBufEmpty then
>> if NOT ENDFILE(TxTEXT) AND NOT TxByteLoaded then
>> if aline = NULL then -- the boolean is never true even when the
>> debugger says aline is NULL !
>> READLINE(TxText, aline) ;
>> char := CR ;
>> else
>> READ(aline, char) ;
>> end if ;
>> writebyte <= char2slv(char) ;
>> TxByteLoaded := true ;
>> end if ;
>> end if ;
>>
>> Attempt 1.
>> Textio has two overloaded procedures under "-- Character reading"
>> The first procedure appears to return a boolean so why the
>> compile error for EOL := READ(aline, char) ?;
>>
>> Attempt 2
>> So this is not good VHDL then ?
>> aline.all'length
>>
>> Attempt 3
>> If I break on
>> if aline = NULL then
>> and examine aline when it is empty Modelsim says it
>> is NULL, but execution is for a false conditional.
>> What is going on ?
>>
>> I have not used ENDLINE() cos I understand it
>> is deprecated in later LRMs because of a bug. (The
>> snippets are compiled to LRM'02)
>>
>> There must be an easy way to find EOL.
>> But what is it ?
>>
>> Rgds johnp
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>

>
>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse: Stripping whitespace at EOL Tim Tyler Java 7 09-15-2011 04:07 PM
replacing EOL with <br> Daves ASP .Net 1 04-13-2005 11:40 PM
replacing two EOL chars by one Xah Lee Python 20 12-22-2003 09:17 PM
3640 EOL Bill F Cisco 3 11-28-2003 08:27 PM
3640 EOL Issues Bill F Cisco 0 11-27-2003 11:39 PM



Advertisments