Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What does the return boolean "Good" do in VHDL textio read function?

Status
Not open for further replies.

matrixofdynamism

Advanced Member level 2
Joined
Apr 17, 2011
Messages
593
Helped
24
Reputation
48
Reaction score
23
Trophy points
1,298
Activity points
7,681
The read function has multiple overloaded versions in the textio package. Among them I have noticed that there is a set of read functions that have 3 parameters instead of 2. The third parameter is always GOOD: out BOOLEAN

How is this GOOD used?
 

good can be used to determine if the attempted read was valid or not.
consider the following line from a text file:

1 2 3 4 5 6 7 8 9 A B C

if you used:


Code VHDL - [expand]
1
2
3
4
5
variable l : line;
variable i : integer;
 
....
read(l,i);



would cause a fatal error when you got to the character A.
but if you use the good parameter, it wont fail:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
variable l : line;
variable i : integer;
variable good : boolean;
 
....
read(l,i,good);
 
if not good then 
  report "You tried to read an illegal value. Im going to set i to 100 for you" severity warning;
  i := 100;
end if;



It allows you to act on bad reads.
 
  • Like
Reactions: ads-ee

    ads-ee

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top