Skip to content
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

Fix 4-state value support for $readmem (#5070) #5078

Merged
merged 6 commits into from
May 21, 2024

Conversation

sifferman
Copy link
Contributor

Fixes #5070

(I still need to add a couple tests, but I'm posting the PR now in case you have early suggestions).

Changes:

  • A z or x in a data string will be converted to a random bit/nibble according to $readmemb/$readmemh and +verilator+rand+reset
  • A 4-state value in an address will now result in a syntax error.

Copy link
Member

@wsnyder wsnyder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, just naming style nit.

Comment on lines 2035 to 2061
const bool c_is_4state_bin
= c == '0' || c == '1' || c == 'x' || c == 'X' || c == 'z' || c == 'Z';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Verilator mixed cap style.

Suggested change
const bool c_is_4state_bin
= c == '0' || c == '1' || c == 'x' || c == 'X' || c == 'z' || c == 'Z';
const bool chIs4StateBin
= c == '0' || c == '1' || c == 'x' || c == 'X' || c == 'z' || c == 'Z';

Copy link
Contributor Author

@sifferman sifferman Apr 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make this change, but I was trying to match the existing naming style in the function. What are your thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, probably I let it slide when the function was first introduced. For local variables it's not a big deal, either way.

= c == '0' || c == '1' || c == 'x' || c == 'X' || c == 'z' || c == 'Z';
const bool c_is_2state_hex = std::isxdigit(c);
const bool c_is_4state_hex
= std::isxdigit(c) || c == 'x' || c == 'X' || c == 'z' || c == 'Z';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
= std::isxdigit(c) || c == 'x' || c == 'X' || c == 'z' || c == 'Z';
= std::isxdigit(c) || cIs4StateBin;

@wsnyder wsnyder changed the title Fixed 4-state value support for $readmem Fix 4-state value support for $readmem (#5070) Apr 30, 2024
@sifferman
Copy link
Contributor Author

@wsnyder I think this PR is good to go. I renamed all the local variables to mixed cap and added 2 tests

@wsnyder wsnyder merged commit d9078df into verilator:master May 21, 2024
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$readmemb and +verilator+rand+reset incompatible
2 participants