Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
document coverUnreachable and strict options for the switch block #139
document coverUnreachable and strict options for the switch block #139
Changes from 1 commit
9941d5d
c350549
7d849dc
bba8bd7
91c873d
b170c31
a8959b7
83c70ab
d300f7b
2b91b59
9c2e002
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure to understand correctly what it is about here so I suggest another way to explain.
If I understand correctly there are two kinds of "cover" to do (I use my words here but feel free to use other words if they are clearer):
For example, using this encoding in an enumerated type (maybe provide an example with actual code)
MOV -> b00
ADD -> b10
SUB -> b11
"logic" cover requires covering the 3 cases MOV, ADD and SUB and "bits" cover requires covering the 4 cases b00 to b11, which are the 3 cases from "logic" cover + unreachable case b01.
By default SpinalHDL only checks "logic" coverage. To reach full "bits" coverage, unreachable cases are redirected to the last case of the
switch
(note: it can be anis
as well as adefault
?).If you have defined
is
cases with a complete "logic" cover and want to define a specific behavior for unreachable cases, you will add adefault
case; but as all reachable cases were already covered, it will be considered unreachable. To not consider it unreachable and use it for unreachable cases, usecoverUnreachable = true
.Example…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so it matters if I use an enumerate (logic cover) or just bits (bits cover) [regardless of constants or immediate values].
I will try to rewrite it then to make it a bit more close to that understanding. Maybe I can also come up with a good example to code show this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it is just my understanding and I do not use it so maybe my understanding is wrong.
@Dolu1990
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sound wrong or else confusing to me.
The goal here is to document coverUnreachable right ?
What's about something kind of like :
"""
If a switch/is contains a 'default' statement while already all the possible values of the 'switch' are covered by the 'is' values, SpinalHDL will generate an "UNREACHABLE DEFAULT STATEMENT" error. You can drop this error reporting by specifying switch(myValue, coverUnreachable = true){ ... }.
"""
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dolu1990 was my suggestion correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I 80% agree so I agree XD
Okay now I 100% agree to just don't tell about it then XD XD
So for the explanation of
coverUnreachable
, I suggest:is
statements, have to usecoverUnreachable
with adefault
statement.Are you okay with it @Dolu1990 and @saahm ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will adapt it then according to what I see here. I couldnt follow this in the past few days but I will catch up and propose a respective change :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@numero-744 Seems good to me ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i had time now to read a bit here, what I conclude is the documentation wont talk about all of the details we discussed about here but what @numero-744 concluded "show and explain logic(enum?) vs bits" and the small thing about coverage of all logic cases by using coverUnreachable for some corner cases of switch-is