Detect EOL

J

johnp

Guest
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
 
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$1_3@mk-nntp-2.news.uk.tiscali.com...
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
 
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$1_3@mk-nntp-2.news.uk.tiscali.com...
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
 
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$1_2@mk-nntp-2.news.uk.tiscali.com...
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$1_3@mk-nntp-2.news.uk.tiscali.com...
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
 
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$1_2@mk-nntp-2.news.uk.tiscali.com...
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$1_3@mk-nntp-2.news.uk.tiscali.com...
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
 

Welcome to EDABoard.com

Sponsor

Back
Top