dsharlet / LiveSPICE

Real time SPICE simulation for audio signals
MIT License
419 stars 61 forks source link

Target FPGA as execution environment #117

Open jopdorp opened 3 years ago

jopdorp commented 3 years ago

Diving a bit deeper into the code, I think I found the place where I could target a different execution environment. Looking at the following method: https://github.com/jopdorp/LiveSPICE/blob/b795a951a5a7495cc39ddf8ac2988ac9d2664c4d/Circuit/Simulation/Simulation.cs#L192 it seems like it first compiles to linq, and then in compiles linq to binary. I'm thinking to make an abstraction layer between this to add a different target than linq. So basically I would just add an implementation that would target Verilog(hardware design language) instead of linq for every LinqExpr.* method. Then I'd just output the resulting verilog to a file, and leave the compilation to verdor specific tools like altera

Originally posted by @jopdorp in https://github.com/dsharlet/LiveSPICE/issues/67#issuecomment-800654460

dsharlet commented 3 years ago

Sorry for the delayed reply. What you suggest could work. I have been hoping to refactor the way the code generation works to make it easier to replace the backend (e.g. I'd like to be able to generate C code), but it's quite a difficult refactor to perform. I think I have several branches that attempted this, but was never able to finish.

It is possible that generating large single expressions like LiveSPICE does might be problematic for an FPGA to handle without some kind of memory/processor to break it down into smaller pieces. If the common subexpression elimination in the FPGA tools (or the LINQ compiler) is really good, it might be OK?