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 'RenderVoid' option to blackboxes #911

Merged
merged 5 commits into from
Nov 19, 2019
Merged

Conversation

martijnbastiaan
Copy link
Member

@martijnbastiaan martijnbastiaan commented Nov 7, 2019

Add 'RenderVoid' option to blackboxes

Void data (e.g., `Index 1`, `BitVector 0`, `()`) results in zero-width
vectors in HDL. HDL tools handle these constructs poorly. To work around
that 01843d3f1907111c460536ef3e37ccb679d74135 added void-filtering to
Clash. As a consequence, any functions solely generating a void
construct aren't rendered at all. Often, this is okay: functions
yielding voids are generally the result of a generalization and don't
perform any actually work when instantiated with a void. _Sometimes_
though, we would like to generate them:

 * In the case of `BiSignal`s, one would like to completely remove any
   `BiSignalOut`s from the HDL, as the corresponding `BiSignalIn` will
   already be converted to an `inout` wire. We'd still like to render
   all the blackboxes yielding a `BiSignalOut` though.

 * (SystemVerilog) Assertions don't carry any "out" signals. They
   construct a comment instructing the simulator / verification tool to
   check some property. Clash simulation can't support this though:
   functions without outputs simply do not exist. In this case, we'd
   like to mark an "assertion result" as void, so it would get filtered
   in HDL. Similar to the previous use case, we'ld like the comments
   to be rendered still. See #864 for more information.

 * Some `IO ()` actions as described in #815 must result in HDL. Like
   the previous two features, `IO ()` would get filtered though.

This commit allows blackboxes to specify whether they would like to be
rendered even if their result is void. Note that any blackboxes
specifying this must make sure that they do not assign anything to
their result - as this is zero bits, Clash won't generate any signal
declarations for it.

As a happy coincidence, this removes the need for special support for
BiSignalOut in the compiler.

@martijnbastiaan
Copy link
Member Author

martijnbastiaan commented Nov 7, 2019

I was going to add isVoidType, but it turned out I didn't need it in the end, so I'll revert the rename in the final version. Edit: Done

clash-lib/src/Clash/Netlist.hs Outdated Show resolved Hide resolved
clash-lib/src/Clash/Netlist.hs Outdated Show resolved Hide resolved
@christiaanb
Copy link
Member

@martijnbastiaan When CI passes, this can be merged?

@martijnbastiaan
Copy link
Member Author

Yes. Thanks for looking into it.

martijnbastiaan and others added 5 commits November 19, 2019 08:56
Void data (e.g., `Index 1`, `BitVector 0`, `()`) results in zero-width
vectors in HDL. HDL tools handle these constructs poorly. To work around
that 01843d3 added void-filtering to
Clash. As a consequence, any functions solely generating a void
construct aren't rendered at all. Often, this is okay: functions
yielding voids are generally the result of a generalization and don't
perform any actually work when instantiated with a void. _Sometimes_
though, we would like to generate them:

 * In the case of `BiSignal`s, one would like to completely remove any
   `BiSignalOut`s from the HDL, as the corresponding `BiSignalIn` will
   already be converted to an `inout` wire. We'd still like to render
   all the blackboxes yielding a `BiSignalOut` though.

 * (SystemVerilog) Assertions don't carry any "out" signals. They
   construct a comment instructing the simulator / verification tool to
   check some property. Clash simulation can't support this though:
   functions without outputs simply do not exist. In this case, we'd
   like to mark an "assertion result" as void, so it would get filtered
   in HDL. Similar to the previous use case, we'ld like the comments
   to be rendered still. See #864 for more information.

 * Some `IO ()` actions as described in #815 must result in HDL. Like
   the previous two features, `IO ()` would get filtered though.

This commit allows blackboxes to specify whether they would like to be
rendered even if their result is void. Note that any blackboxes
specifying this must make sure that they do not assign anything to
their result - as this is zero bits, Clash won't generate any signal
declarations for it.

As a happy coincidence, this removes the need for special support for
BiSignalOut in the compiler.
@martijnbastiaan martijnbastiaan merged commit 667c969 into master Nov 19, 2019
@martijnbastiaan martijnbastiaan deleted the render-void-decls branch November 19, 2019 09:56
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