Coder Social home page Coder Social logo

Comments (6)

zachjs avatar zachjs commented on June 3, 2024

Personally, I think to make the expression clearer, the tool should not remove parentheses.

Can you help me understand your downstream use case where the existing output of sv2v doesn't suit your needs? Are you feeding it into a downstream tool? Editing the generated output manually? Something else?

from sv2v.

anhdv2000 avatar anhdv2000 commented on June 3, 2024

@zachjs I used Spyglass to check the .v code generated by SV2V and encountered the warning WRN_61 (547): Parentheses should be used with the reduction AND operator following the bitwise AND operator [a&(&b)]. I think you shouldn't remove the parentheses in this case; it both conforms to the standard and provides clarity for designers

from sv2v.

zachjs avatar zachjs commented on June 3, 2024

sv2v's frontend, where the text is turned into an AST, doesn't distinguish x = y; from x = (y); from x = ((((y))));. In this sense, certain parentheses are always "removed". I do not intend to adjust sv2v's frontend to preserve such parentheses.

Instead, we could change the behavior of sv2v's backend, where the converted AST is turned back into text, to adhere to some particular stylistic preferences.

Can you confirm that you are requesting only these two specific stylistic changes, where x and y are arbitrary expressions?

  • x | |y => x | (|y)
  • x & &y => x & (&y)

I personally disagree with Spyglass here, but I'm willing to make changes to sv2v's backend where the complexity is low and the scope is narrow. Though I might implement the above request, I do not necessarily intend to make sv2v's output Spyglass compliant.

I'm also not really sure that the existing output is unclear. There are at least a few other cases in SystemVerilog where spacing distinguishes between two valid parses.

  • x ^~ y vs. x ^ ~ y
  • x <<< y vs. x << < y
  • x >>> y vs. x >> < y

from sv2v.

anhdv2000 avatar anhdv2000 commented on June 3, 2024

@zachjs I completely agree with you on this. It's just a warning in Spyglass, not a big concern. However, I think, for code readability, it would be beneficial to include parentheses for frequently used operations to avoid misunderstandings (even though it already has spaces for distinction). It also reduces warnings for downstream tool.
I think changing just these two specific stylistic elements is sufficient

  • x | |y ==> x | (|y)
  • x & &y ==> x & (&y)

I believe its scope is quite narrow and only slightly adjusts the code representation. So, it would be great if you're willing to make these changes. Thank you !!!

from sv2v.

zachjs avatar zachjs commented on June 3, 2024

I just pushed 9825bb9 to make this change. Please let me know if it works for you.

from sv2v.

zachjs avatar zachjs commented on June 3, 2024

I'm closing this because I think the original request is now satisfied. Please let me know if you have further issues!

from sv2v.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.