9

I usually use F# for writing numerical algorithms. Functional programming constructs in F# helps to express algorithms in a very natural way. I often end up with a succinct and understandable implementation, and may be able to parallelize it quite fast if there is a chance of parallelism.

I wonder there is a way to compile F# programs down to FPGA. In this way, I can still use F# to avoid boilerplate codes in FPGA programming, and make use of high performance computing in FPGA. Is this possible to do so? If yes, could you provide some hints for me to start with?

pad
  • 41,040
  • 7
  • 92
  • 166
  • Have you seen [Kiwi](http://research.microsoft.com/en-us/projects/kiwi/default.aspx)? – ildjarn Dec 05 '11 at 22:16
  • Yes, I'm aware of Kiwi. But it's still a research incubation, not ready for use yet. – pad Dec 05 '11 at 22:23
  • I'm not aware of any 'turnkey' software for this, the market for that would be pretty small i guess. Think you're going to have to roll your own. Have you seen this guys blog? http://blogs.msdn.com/b/satnam_singh/ – gjvdkamp Dec 05 '11 at 23:21
  • @gjvdkamp : He's one of the authors of Kiwi. :-] – ildjarn Dec 05 '11 at 23:30
  • 2
    @pad: F# itself just recently got beyond the research stage. Anyway, are you doing this because you find F# easier than VHDL/Verilog, or because you don't know VHDL or Verilog? And have you considered using the GPU for massive parallelism instead of an FPGA, since the GPU programming model is much closer to a CPU, and IL -> compute shader conversion is much more mature. – Ben Voigt Dec 06 '11 at 00:47
  • @BenVoigt: F# is significantly easier for me to express problems and solve them. I prefer FPGA to GPU due to its flexibility. And GPU programming is only suitable for certain problems. – pad Dec 06 '11 at 06:37
  • FPGAs are also only suitable for certain problems, and high-level synthesis imposes even more restrictions. What are you trying to solve? –  Dec 06 '11 at 17:54
  • It is a symbolic algorithm which has high complexity but also contains massive parallelism because I can divide and solve smaller problems individually. – pad Dec 06 '11 at 18:04
  • @BenVoigt: "F# itself just recently got beyond the research stage". F# was at the stage Kiwi is at 10 years ago, was productized 4 years ago and shipped almost 2 years ago. I wouldn't call 10 years ago "recently" in the context of technology... – J D Dec 07 '11 at 02:16
  • @JonHarrop: Until it shipped, it was available only from Microsoft Research under a restrictive non-commercial license. 2 years ago is "recently" in the context of computer science. Programming theory simply doesn't move become obsolete at the same pace as consumer electronics, which seems to be what you're trying to suggest by "technology". – Ben Voigt Dec 07 '11 at 05:29
  • @JonHarrop: You're an expert in F# and parallel programming paradigm. Could you give some insights on this problem? – pad Dec 07 '11 at 11:48
  • @BenVoigt: "Until it shipped, it was available only from Microsoft Research under a restrictive non-commercial license". No, the first F# CTP was released by Microsoft over 3 years ago and even before that the license was neither restrictive nor non-commercial. Note that we have been shipping products written in F# for over 4 years. – J D Dec 09 '11 at 00:53
  • 1
    @JonHarrop: Three years ago, the wording was thus: "You may not use or distribute this Software or any derivative works in any form for commercial purposes, except as follows: (i) you may use the unmodified binary form of the Software to compile your commercial applications as long as you do not redistribute the Software in any form for commercial purposes" That license is restrictive, but allows some commercial use. So we're both wrong. – Ben Voigt Dec 09 '11 at 01:00

3 Answers3

3

I've read about (but never used) Avalda's F# to FPGA conversion, but their site is currently returning a completely blank page. I don't know if that's just temporary of if it means they've gone belly-up.

Benjol
  • 63,995
  • 54
  • 186
  • 268
  • I don't even find anything in their site in Google cache. There is no information left about what they did. – pad Dec 06 '11 at 11:17
  • @Pad, it even got Don Syme's attention: ["From Parallel F# to Parallel FPGAs", from Avalda](http://blogs.msdn.com/b/dsyme/archive/2008/10/24/from-parallel-f-to-parallel-fpgas-from-avalda.aspx) – Benjol Dec 06 '11 at 12:21
  • true. That's why I expected some documentation from them, not just an advertisement everywhere and that's it. – pad Dec 06 '11 at 18:11
  • @pad, I guess [this](http://web.archive.org/web/20100724092322/http://www.avalda.com/) is telling: "buy Now for the big EARLY ADOPTER'S discount: C$39.99" (instead of C$99.99) - imminent death... – Benjol Dec 06 '11 at 19:58
2

F# should be ideal for this task because it is derived from the ML family of languages that were bred for metaprogramming. However, I am not aware of any work in this area (although I have had the idea of working on it myself).

I would focus on writing a compiler in F# that compiled a DSL to an FPGA, rather than trying to compile general F# code.

J D
  • 48,105
  • 13
  • 171
  • 274
  • Can you elaborate "...compiled a DSL to an FPGA"? And it's easier to understand if you give an example or code fragment. – pad Dec 11 '11 at 10:00
  • @pad: I'm afraid I cannot give an FPGA example because I have never done this with FPGAs. Perhaps HLVM will give some idea. This compiles a DSL to LLVM IR. Here are some test programs I wrote in its DSL: https://forge.ocamlcore.org/scm/viewvc.php/*checkout*/test.ml?revision=47&root=hlvm – J D Dec 11 '11 at 10:09
  • Can you fix the link; it seems to be broken? Regarding DSL and FPGA, I think I have to wait until something eventually comes out. – pad Dec 11 '11 at 10:29
  • Ugh, Stack Overflow sucks so much. Here's a bitly link to the same place: http://bit.ly/vi2Vbz – J D Dec 11 '11 at 12:37
  • My first idea would be to fork one of the F# -> JavaScript compilers and see if I can reuse the design or more from that approach. ``[]`` along with code quotations etc. might do the trick. That aside, FPGA tool chains are usually split into 2 parts: The VHDL compiler and a Fitter, which fits the result of the compiler to a specific FPGA. Regarding that, what would be the scope for the F# approach? Fitter included? – BitTickler May 02 '16 at 10:35
0

Here's a list for HLS tools using C. My experience with one of them in 2006 was not favourable but I expect them to be much better today.

Regarding F#, I doubt this will exist any time soon.

Community
  • 1
  • 1