Retargeting Haskell compiler to embedded/hardware

A few years ago I attempted to build a Haskell hardware compiler (Haskell -> Verilog) based on the Yhc frontent. At the time I was trying to overcome several problems [1] with implementing a hardware description language as a light eDSL, which convinced me a proper compiler may be a better approach. Yhc was recommended as a good starting point since it had a simpler IR compared with GHC -- at least at the time. I am considering restarting this effort, but this time to target hard realtime embedded code. What is the recommended compiler to start from? I need an IR that is post type checking with as much desugaring as possible, and a code base that is relatively easy to splice and build. My other requirement is not to be bound to IO () for 'main'. The top level will be a monad, but with different semantics than IO. I would also like to reuse the standard library, with exception to the values related to IO. What are my options? Thanks. -Tom [1] Lack of observable sharing; function definitions, case expressions, ADTs disappear at compile time; etc.

Hi,
--- On Wed, Sep 29, 2010 at 7:28 AM, Tom Hawkins

On Tue, Sep 28, 2010 at 9:20 PM, Shakthi Kannan
If you are still at it, you can have a look at Chalmers Lava [1], or Kansas Lava [2]. Feldspar [3] project targets DSP though.
These are examples light embedded DSLs, i.e. sophisticated libraries where you compile, then run the program to generate code. This is not what I want. Rather, I am looking for advice on how to splice GHC -- or another implementation -- where I can build a compiler starting from a type checked, simplified Haskell AST; or better yet, an unevaluated call graph. -Tom

2010/9/29 Tom Hawkins
On Tue, Sep 28, 2010 at 9:20 PM, Shakthi Kannan
wrote: If you are still at it, you can have a look at Chalmers Lava [1], or Kansas Lava [2]. Feldspar [3] project targets DSP though.
These are examples light embedded DSLs, i.e. sophisticated libraries where you compile, then run the program to generate code. This is not what I want. Rather, I am looking for advice on how to splice GHC -- or another implementation -- where I can build a compiler starting from a type checked, simplified Haskell AST; or better yet, an unevaluated call graph.
Hi Tom, How much of GHC's Haskell do you want? If you are happy with something *similar* to Haskell, did you consider to implement (or reuse if something exists) your own concrete syntax and type checker? I would think those problems are quite lightweight in regard to writing a new backend. Cheers, Thu

tomahawkins:
A few years ago I attempted to build a Haskell hardware compiler (Haskell -> Verilog) based on the Yhc frontent. At the time I was trying to overcome several problems [1] with implementing a hardware description language as a light eDSL, which convinced me a proper compiler may be a better approach. Yhc was recommended as a good starting point since it had a simpler IR compared with GHC -- at least at the time.
I am considering restarting this effort, but this time to target hard realtime embedded code. What is the recommended compiler to start from? I need an IR that is post type checking with as much desugaring as possible, and a code base that is relatively easy to splice and build.
My other requirement is not to be bound to IO () for 'main'. The top level will be a monad, but with different semantics than IO. I would also like to reuse the standard library, with exception to the values related to IO.
What are my options?
Have you looked at Clash, the GHC to VHDL compiler?

Don Stewart:
tomahawkins:
A few years ago I attempted to build a Haskell hardware compiler (Haskell -> Verilog) based on the Yhc frontent. At the time I was trying to overcome several problems [1] with implementing a hardware description language as a light eDSL, which convinced me a proper compiler may be a better approach. Yhc was recommended as a good starting point since it had a simpler IR compared with GHC -- at least at the time.
I am considering restarting this effort, but this time to target hard realtime embedded code. What is the recommended compiler to start from? I need an IR that is post type checking with as much desugaring as possible, and a code base that is relatively easy to splice and build.
My other requirement is not to be bound to IO () for 'main'. The top level will be a monad, but with different semantics than IO. I would also like to reuse the standard library, with exception to the values related to IO.
What are my options?
Have you looked at Clash, the GHC to VHDL compiler?
Links are always useful: http://clash.ewi.utwente.nl/ http://hackage.haskell.org/package/clash http://dutchhug.nl/static/dutchhugday-2010/clash.pdf http://wiki.clean.cs.ru.nl/images/8/86/Christiaan-from-haskell-to.pdf Sean

If you are really interested in embedded realtime code you may want to have a look at the timber language[1] or bit-c[2]. Another very interesting project is this[3] developing a new Haskell like language called Habit for systems programming. There are also some great papers about systems programming and problems in Haskell. For example "Strongly typed memory areas programming systems-level data structures in a functional language". [1] http://www.timber-lang.org/ [2] http://www.bitc-lang.org/ [3] http://hasp.cs.pdx.edu/ [4] http://web.cecs.pdx.edu/~mpj/pubs/bytedata.pdf Tom Hawkins-2 wrote:
A few years ago I attempted to build a Haskell hardware compiler (Haskell -> Verilog) based on the Yhc frontent. At the time I was trying to overcome several problems [1] with implementing a hardware description language as a light eDSL, which convinced me a proper compiler may be a better approach. Yhc was recommended as a good starting point since it had a simpler IR compared with GHC -- at least at the time.
I am considering restarting this effort, but this time to target hard realtime embedded code. What is the recommended compiler to start from? I need an IR that is post type checking with as much desugaring as possible, and a code base that is relatively easy to splice and build.
My other requirement is not to be bound to IO () for 'main'. The top level will be a monad, but with different semantics than IO. I would also like to reuse the standard library, with exception to the values related to IO.
What are my options?
Thanks.
-Tom
[1] Lack of observable sharing; function definitions, case expressions, ADTs disappear at compile time; etc. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- View this message in context: http://old.nabble.com/Retargeting-Haskell-compiler-to-embedded-hardware-tp29... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
participants (6)
-
-Steffen
-
Don Stewart
-
Sean Leather
-
Shakthi Kannan
-
Tom Hawkins
-
Vo Minh Thu