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

PortProduct prefixing, auto-generating notation #914

Open
DigitalBrains1 opened this issue Nov 14, 2019 · 7 comments
Open

PortProduct prefixing, auto-generating notation #914

DigitalBrains1 opened this issue Nov 14, 2019 · 7 comments

Comments

@DigitalBrains1
Copy link
Member

Using a Synthesize annotation, we can specify names for the ports of the generated component.

Currently:

  • PortName "" indicates an auto-generated name is wanted.
  • PortProduct "pre" [ Portname "a", PortName "" ] creates two ports named pre_a and pre_X, where X is auto-generated.

This has two undesirable aspects:

  • It is impossible to get rid of the prefix for some of the ports in a PortProduct.
  • PortName "" is a bit of a misnomer.

After some internal discussion, we suggest

  • Add a friendly name AutoName that does the exact same as PortName "" and keep the latter for backward compatibility.
  • Add AbsPortName s which gives the port the name s without any of the prefixes of the enclosing PortProducts.

Note that the current documentation regarding prefixes is wrong, this is based on actual behaviour of CλaSH 1.0.1.

@DigitalBrains1
Copy link
Member Author

On a related note, PortProduct "pre" [ PortName "suf" ] generates the name pre_suf. Personally, to get that result, I'd like to write, e.g., PortProduct "pre_" [ Portname "suf" ] so I am free to choose whether I actually want that underscore or not.

@martijnbastiaan
Copy link
Member

On a related note, PortProduct "pre" [ PortName "suf" ] generates the name pre_suf. Personally, to get that result, I'd like to write, e.g., PortProduct "pre_" [ Portname "suf" ] so I am free to choose whether I actually want that underscore or not.

Maybe we could add a "t_separator" option to Synthesize?

@DigitalBrains1
Copy link
Member Author

To me, it's perfectly natural to write PortProduct "pre_" [ PortName "suf" ] or PortProduct "camel" [ PortName "Case" ] or some such construction. I'd prefer that simplicity, but if you want the explicitness of

, t_output = PortProduct "camel" [ PortName "Case" ]
, t_separator = ""

I'd be fine with that as well.

@leonschoorl
Copy link
Member

We should also think about how this interacts with makeTopEntity from #729

@martijnbastiaan
Copy link
Member

martijnbastiaan commented Nov 14, 2019

We discussed this offline: Adding t_separator would break backwards compatibility, so we should refrain from doing that the "dumb" way. We propose the following upgrade path:

  1. [1.2] Adding a "smart constructor" for Synthesize.
  2. [1.2] Deprecate using the Synthesize smart constructor.
  3. [1.2] Encourage users to use defSyn nm { prop = ... }
  4. [1.4] Remove the smart constructor for Synthesize

Correct @leonschoorl @DigitalBrains1 ?

@DigitalBrains1
Copy link
Member Author

I think that is what we discussed. But: how does CλaSH know when we write:

{-# ANN f def #-}
f a b = ...

that it should fill in the default for Synthesize and not some other annotation? I think you'd have to write:

{-# ANN f (def :: TopEntity) #-}

and then I'd rather use defSyn.

@martijnbastiaan
Copy link
Member

Yeah, excellent point. I'll edit it in.

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

No branches or pull requests

3 participants