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

Maintain variable names post-compilation #128

Closed
ghost opened this issue Feb 25, 2016 · 4 comments
Closed

Maintain variable names post-compilation #128

ghost opened this issue Feb 25, 2016 · 4 comments
Milestone

Comments

@ghost
Copy link

ghost commented Feb 25, 2016

I would really appreciate a feature to maintain variable naming post-compilation to VHDL or Verilog like MyHDL. As of now the code that clash outputs is very difficult to read or reason about its connection to the initial Haskell.

@christiaanb
Copy link
Member

I'm currently working on fixing blockRam inference for Xilinx Vivado. Afterwards, I'll take a look at this.

christiaanb added a commit that referenced this issue Mar 1, 2016
This helps in preserving more of the original variable names.
See #128 for more information.
christiaanb added a commit that referenced this issue Mar 1, 2016
Also make derived names more readable, so "result" instead of
"topLet", or "app_arg" instead of "repANF", etc.

Progress towards #128
christiaanb added a commit that referenced this issue Mar 2, 2016
Names cannot be preserved when:
* It conflicts with a HDL keyword
* It was originally a shadowed name, which, after let-expr
  flattening now exists in the same scope.

See issue #128
@christiaanb
Copy link
Member

I'm making progress on this. Some notes:

  • Given the following Haskell written by the user:

    f (x,y) = ...

    I get the following code from the GHC Haskell compiler:

    f ds = case ds of (x,y) -> ...

    which I translate to a component f with a single input port called ds, and not, as one might expect, a component f with two inputs ports x and y. The problem is, is that I cannot distinguish between f ds = case ds of (x,y) -> ... written by the user, or f ds = case ds of (x,y) -> ... generated by the GHC Haskell compiler. I don't plan to add any heuristics as to what might be generated or not, so I will always create the single input-port version of the component f.

  • GHC generates a lot of so-called worker/wrapper function pairs, where you have the user-written function f, which becomes the wrapper, and the compiler optimized function f', the worker. Now, most of the "optimized" functions are actually only running faster when they would be executed on a normal CPU, when translating them to circuits, it makes absolutely no difference. Also, the worker/wrapper transformation does some name-mangling on the argument names, meaning that it is currently sometimes hard to preserve names in the HDL output. However, once GHC8 is released, and I can base CLaSH on top of GHC8, I can finally disable the worker/wrapper transformation, and hence no longer have the annoying name-mangling.

@christiaanb
Copy link
Member

Some of the name-preservation improvements are part of the 0.6.11 release of CLaSH. I'll keep this issue open, as I'm sure we can do better than what's currently implemented.

@christiaanb christiaanb added this to the 1.1 milestone Dec 18, 2018
@christiaanb
Copy link
Member

Clash preserves most names these days; and when it doesn't you simply add a {-# NOINLINE xyz #-} pragma

leonschoorl pushed a commit that referenced this issue Jul 31, 2023
* add hypercube, line graphs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant