J
johnp
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
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