Detect EOL

Discussion in 'VHDL' started by johnp, May 12, 2008.

  1. johnp

    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
    johnp, May 12, 2008
    #1
    1. Advertising

  2. johnp

    johnp Guest

    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$...
    >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
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    johnp, May 12, 2008
    #2
    1. Advertising

  3. johnp

    johnp Guest

    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$...
    >
    > 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$...
    >>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
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>

    >
    >
    johnp, May 23, 2008
    #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. Daves

    replacing EOL with <br>

    Daves, Apr 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    515
    Karl Seguin
    Apr 14, 2005
  2. Tim Tyler
    Replies:
    7
    Views:
    22,939
    danielson317
    Sep 15, 2011
  3. Xah Lee

    replacing two EOL chars by one

    Xah Lee, Dec 20, 2003, in forum: Python
    Replies:
    20
    Views:
    677
  4. Ajay
    Replies:
    0
    Views:
    530
  5. Ajay
    Replies:
    2
    Views:
    7,360
    Ajay Brar
    Aug 4, 2004
Loading...

Share This Page