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

Add Clash.Annotations.SynthesisAttributes.markDebug (plus an unfortunate amount of baggage) #2547

Merged
merged 9 commits into from
Jul 19, 2023

Conversation

martijnbastiaan
Copy link
Member

I was playing around with constraint files and thought it would be nice if we could have a term level way of annotating signals with synthesis attributes. That is, the markDebug proposed in this PR. Unfortunately, I ran into quite a number of things I needed (and "needed") to fix before being able to add the function:

  • Fixed a layout issue with block rendering in VHDL
  • Discovered tests in shouldwork/ that weren't part of clash-testsuite
  • Fixed an issue where VHDL would render a bool attribute, while only boolean is recognized
  • Add TermLiteral (Vec n a)
  • Refactored and simplified coreToAttrs / coreToAttr. The old implementation tried to be helpful with its error messages, but I didn't feel they helped out very much. Reading the code wasn't as nice as it could be either so...
  • Generalized Attr to work over Symbol (type level) and String (term level)
    • Preparation work for annotate
  • Removed Attr' now that Attr is generalized
  • Add annotate: a way of adding synthesis attributes to signals
  • Add markDebug: a convenience function that emits all keep/debug pragmas needed for synthesis tooling (currently verified for Vivado and Quartus)

Each of these points correspond to a commit. This PR can be split up into multiple smaller ones if desired.

Still TODO:

  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files

Copy link
Member

@christiaanb christiaanb left a comment

Choose a reason for hiding this comment

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

One of the commit messages uses the term "erasion". Although it seems to be an actual word, both my Firefox dictionary and the other people in the office prefer the term "erasure".

clash-lib/src/Clash/Core/Type.hs Outdated Show resolved Hide resolved
martijnbastiaan and others added 6 commits July 19, 2023 22:11
Before:

    block
      ...
      attribute str_attr of my_signal : signal is "foo";begin
      ...
    end block;

After:

    block
      ...
      attribute str_attr of my_signal : signal is "foo";
    begin
      ...
    end block;
The former is not a VHDL attribute type
 * Use TemplateHaskellQuotes where possible
 * Use more sensible argument names + add comment
 * Use string interpolation
Allows `clash-prelude` and `clash-lib` to share the type, as well as
allow `Attr` to be used in combination with `TermLiteral`.
@martijnbastiaan martijnbastiaan force-pushed the add-mark-debug branch 2 times, most recently from eab26a5 to 793f6a6 Compare July 19, 2023 20:14
Add a term-level way of adding annotations to signals. This is more
reliable than type level annotations, as it is guaranteed to survive
optimizations and type alias erasure.
Add a term level way of marking a signal as "debug". This instructs
synthesizers to leave a signal alone, even after optimizations.
@martijnbastiaan martijnbastiaan merged commit d2c58e0 into master Jul 19, 2023
13 checks passed
@martijnbastiaan martijnbastiaan deleted the add-mark-debug branch July 19, 2023 22:02
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.

None yet

2 participants