From: ptkwt@... (Phil Tomson) Date: 2006-02-03T10:33:18+09:00 Subject: Re: neuroimage software - scientific computing and visualization In article <43E29027.9090908@path.berkeley.edu>, Joel VanderWerf wrote: >Phil Tomson wrote: >> Here's an tantalizing idea that I'll throw out: C is one thing and, yes, it's >> fast.... but what if you could actually map some algorithm or math operation to >> _hardware_ and thus get a large speed advantage even over C? I'm working on >> something like this... details forthcoming. The idea is very similar to >> Ruby::Inline. It will allow seamless communication between your Ruby program >> and an FPGA board acting as hardware accelerator (these boards are available >> for less than $200 now). > >That would be very cool. Eventually, we're going to be porting a >wireless network stack to FPGA, and being able to still use Ruby would >be very nice. > >What kind of code goes inside your "inline" blocks? > Initially it's going to be VHDL, a hardware description language. There are lots of efforts afoot to use C and a hardware description language, but I'm just not sure yet that there's much advantage (YET) over using an HDL like VHDL. The semantics of an HDL are much different than the semantics of a programming language like C or Ruby. HDLs have to model the parallelism inherant in hardware. So the idea of RubyInline::HDL is evolutionary rather than revolutionary: use Ruby for what it's good for and use HDLs for what they're good for. Of course, from a practical standpoint, using VHDL also makes it easy to use the free (though not open source, unfortuneatly) tools from Xilinx to program their FPGAs. In the future, I'd like to build on RHDL (Ruby as an HDL) so that it can generate VHDL as an output. At that point then the inlined 'language' would be RHDL (really a Ruby-based DSL). Also, at some point it would be good to support FpgaC which is an open source C programming environment for FPGAs. In the short term, you'll either need to know VHDL to use Inline::HDL, or perhaps we could build a repository (using gems perhaps?) of useful VHDL modules that users could download from some website. Lots of common DSP functions could be made available. This could make it so that you wouldn't have to know much VHDL to use Inline::HDL. So, for example, say you want to use Ruby to do some image processing. Maybe you want that image processing to be in real time. Maybe C isn't even fast enough for whatever you're doing. You download some image processing packages which are written in VHDL and you inline them using Inline::HDL. Your system would look something like: camera -> FPGA (running image processing algorithms)->PCI bus->Ruby program In this scenario the dataflow is pretty much one way, but you can imagine other scenarios where your Ruby program sends some data to the FPGA to be processed and waits for an answer back. Maybe you're doing some sort of optimization that would take a long time in software, but would be much faster if it can be implemented in hardware. Your Ruby program would send a block of data over the PCI bus to the FPGA card, the FPGA card would then process that data and send back the processed data. RubyInline::HDL would take care of setting up all the interfaces (hardware and software) between the Ruby program and the FPGA board and it would take care of running the Xilinx tools to create the bitstream (if one doesn't already exist). That's the theory anyway; this is all very preliminary based on some work I did last summer using a VHDL simulator (ghdl) in place of an FPGA board. I need to finish that up to get testing going and then start working with actual hardware. Now that my Masters degree is about done (defense is tomorrow!) I'll have some time to put into this over the next couple of months. Phil