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

Verilog attribute parsing OpenSTA #11

Merged
merged 12 commits into from
Mar 16, 2024

Conversation

QuantamHD
Copy link
Contributor

@QuantamHD QuantamHD commented Mar 5, 2024

Allows STA to read, parse and write verilog attributes, example below.

/* Generated by Yosys 0.8+ */

(* hdlname = "\\counter" *)
(* top =  1  *)
(* src = "synthesis/tests/counter.v:16.1-32.10" *)
module counter(clk, reset, out);
  wire _0000_;
  wire _0001_;

@CLAassistant
Copy link

CLAassistant commented Mar 5, 2024

CLA assistant check
All committers have signed the CLA.

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@QuantamHD
Copy link
Contributor Author

Thanks for the feedback.

Addressed all comments. After moving to std::string I needed to wrap it in std::optional in order to preserve an unset value check.

I the new API overall, but if you don't we can go back to const char * or return an empty std::string when the attribute is not found.

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@jjcherry56
Copy link
Collaborator

I am having a hard time seeing a reason to distinguish between an empty string and a missing value. I don't think the std::optional is very useful here. Please use a "using" to get rid of all the std::'s. I think string is already covered by StringUtil.hh

@QuantamHD
Copy link
Contributor Author

I think the question is, is this a valid attribute (* src="" *), and if it is can an API user differentiate between (* src="" *) and (**). The optional would be empty in the latter, but not the former.

I think I tend to agree with you though. It seems like in most other place we don't differentiate between empty string and not present. I'll go back to just string

This reverts commit 8aef4d5.

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@QuantamHD
Copy link
Contributor Author

All feedback has been addressed.

Copy link
Collaborator

@jjcherry56 jjcherry56 left a comment

Choose a reason for hiding this comment

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

ship it

@QuantamHD
Copy link
Contributor Author

Cool, Merge whenever you're ready. I don't have any permission on this repo

@jjcherry56 jjcherry56 merged commit 3c541e0 into parallaxsw:master Mar 16, 2024
1 check passed
@QuantamHD QuantamHD deleted the attribute_parsing_parallax branch March 16, 2024 15:59
@akashlevy
Copy link
Contributor

akashlevy commented Mar 24, 2024

Hey Ethan @QuantamHD ,

I am finding that this PR results in a parsing error when >2 attributes are present on a line:

netlist.v line 1520, syntax error, unexpected ',', expecting ATTRIBUTE_CLOSED

To reproduce, try a multi-attribute statement like: (* src = "design.v:1.1-2.1", test1 = "test1", test2 = "test2" *)

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.

4 participants