[sdiy] FIR or IIR Digital filters for the PIC

Scott Gravenhorst music.maker at gte.net
Thu Jun 5 19:00:32 CEST 2008


Csaba Zvekan <czvekan at gmail.com> wrote:
>Highly interesting stuff, Scott.
>I was looking at the dev. board (149$ not too bad) 
>http://www.xilinx.com/products/devkits/HW-SPAR3E-SK-US-G-image.htm 
>. It's looking sweet . But how much is the Verilog compiler? 

Free.  And it's quite comprehensive.  Called WebPACK ISE, it is a full environmant
package with editor, "compiler" and other useful tools.  It is big though, over 1G, but
it is downloadable for free.  A DVD can be ordered if you pay for shipping of it.

Also downloadable for free is an embedded 8 bit RISC microcontroller called PicoBlaze. 
PicoBlaze supports embedded MIDI controllers.  It is programmed in it's own native
assembly language.  PicoBlaze will operate at 25 MIPS and is well more than fast enough
for a full featured MIDI controller.

>I understand it's kind of like C ? 

The syntax (of Verilog) _looks_ like C.  There is also VHDL which can do the same things,
but has different syntax.  Verilog is used more in the USA and VHDL is used more in
Europe.  Modules written in VHDL and Verilog can also be mixed in the same project.   But
an HDL (Hardware Description Language) does not work like a programming language
compiler.  FPGA devices allow you to construct hardware designs that include parallel
operations.  For example, the FPGA I use contains 20 18x18 signed hardware dedicated
multipliers.  In a CPU, there is usually only one and to share it means expending CPU
clocks.  In an FPGA, all 20 can compute a product in the same clock cycle.

>But isn't FPGA a highly complicated matter? 

Not in my opinion.  I learned the language syntax from free web tutorials and less than a
year after I started, I produced my first working synth design (GateMan-I).  It is not
the same as programming, but IMO it's no more complex.  It _is_, however, a different way
of thinking because things don't have to work in a step by step manner (although they can
be designed to work that way).  HDL describes a design, a program describes an
algorithmic sequence.  Both can do the same work, but do so differently and with
different efficiencies.  I actually envision schematics in my head now when I code in
Verilog.  I work the same way I would work with a pile of digital ICs, with RAMs, OR and
AND gates, multiplexors, selectors, etc.  The HDL describes how those bits connect
together, how they are clocked and enabled.  I think of an FPGA as a huge box of digital
Lego.

>Or has it been tamed in the meantime? 

Heh heh.  We wish...  Actually, IMO, the idea that HDL is somehow more complex than
programming is a myth.  I am a programmer, and I found learning HDL to be about as
difficult.  It's mainly just a difference in thinking or approach to problem solving,
i.e., step by step execution as opposed to envisioning a digital design made up of things
you choose.  In my view, the FPGA is an awesome DSP environment.  I've been doing this as
a "hobby" only for about two years.  Also, an FPGA, even on a dev board, allows
connection to a host of external devices, for example, it can accept and/or generate CVs
from and to external sources enabling connection to existing synth circuitry if desired.
 Currently, I use it as a self contained synth.

There is support also, USENET newsgroups exist for FPGAs and for both Verilog and VHDL. 
There is also the FPGA-Synth email list which tends to have low traffic, but there are
some very helpful and knowledgable people hanging out there.

-- I am not a Xilinx employee, I just really like the product.

>Csaba
>
>
>On Jun 5, 2008, at 5:15 PM, Scott Gravenhorst wrote:
>
>> Csaba Zvekan <czvekan at gmail.com> wrote:
>>> Hi group,
>>>
>>> Has anybody done some work on FIR and IIR digital filters with the  
>>> PIC
>>> or dsPIC family that can be used for SDIY ?
>>> I would look at some codes and designs .
>>
>> Not for a PIC, but for DSP inside an FPGA.
>>
>> I tried to use a single stage IIR filter as the main filter in the  
>> GateMan-I synth.
>> While it works, it is sonically underwhelming.  It is, however, very  
>> easy to tune.
>> This filter does not have what we call a corner frequency, at least  
>> not in the same
>> way we describe analog filters like SVF or ladder.  It also doesn't  
>> have resonance.
>> The single stage IIR leaves the corner frequency at zero Hz and the  
>> tuning parameter
>> changes the rolloff slope.  Sonically, it's more like a simple tone  
>> control than what
>> we like to use as an audio filter in music.
>>
>> Two places I found this IIR filter very useful and appropriate are  
>> the reflection
>> filter in PolyDaWG/8, a Karplus-Strong tight string synth and as the  
>> main processing
>> element to implement portamento in all 3 of the GateMan synths.
>>
>> The reason I mention a single stage IIR is that it's simplicity will  
>> be attractive to
>> someone using a device like a PIC, but I warn that it is not a good  
>> choice for a
>> filter used as we often do in modular type synths.
>>
>> An FIR can be quite simple too, but is not so easily tuned, fixed  
>> filters are fairly
>> easy to implement.
>>
>> AVRsynth (google it) is probably a good place to look at digital  
>> filter code for
>> microprocessors, I don't know what type of filter is used in that  
>> synth however.
>>
>> My favorite digital filter so far is the State Variable Filter.   
>> While it sounds
>> great (IMO), it does have some rather intense computational and  
>> sample rate
>> requirements.  I found it fairly simple to implement and it tunes  
>> quite easily.
>>
>> I'd give references to my Verilog code, but it isn't that easy to  
>> transmute into
>> microprocessor type instructions.
>>
>> If you are interesed, here are links to the projects I've published:
>>
>> - http://www.fpga.synth.net/pmwiki/pmwiki.php?n=FPGASynth.GateManI
>> - http://www.fpga.synth.net/pmwiki/pmwiki.php?n=FPGASynth.GateManII
>> - http://www.fpga.synth.net/pmwiki/pmwiki.php?n=FPGASynth.DigitalWaveguide
>> - http://www.fpga.synth.net/pmwiki/pmwiki.php?n=FPGASynth.GateManPoly
>>
>> These projects are all implemented on a Xilinx Spartan-3E Starter  
>> Kit (a development
>> board) with very minimal external hardware (the schematics for the  
>> external hardware
>> are posted with the projects and is the same hardware for all of  
>> them).
>>
>> -- ScottG
>>
>> -----------------------------------------------------------------
>>
>> -- Scott Gravenhorst
>> -- GateManPoly - FPGA Based Polyphonic MIDI LA/FM Synthesizer
>> -- GateMan-III - FPGA Based Monophonic MIDI LA/FM Synthesizer
>> -- PolyDaWG/8 - FPGA Based 8 Voice Polyphonic MIDI Synthesizer
>> -- FatMan: home1.gte.net/res0658s/fatman/
>> -- NonFatMan: home1.gte.net/res0658s/electronics/
>> -- When the going gets tough, the tough use the command line.
>>
>> _______________________________________________
>> Synth-diy mailing list
>> Synth-diy at dropmix.xs4all.nl
>> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
>
>**************
>http://www.csabazvekan.com
>music stuff
>http://www.csaba.ch
>electronic stuff
>http://www.synthmaniac.com
>synthesizer stuff (not fully set up yet)
>
>
>
>
>
>_______________________________________________
>Synth-diy mailing list
>Synth-diy at dropmix.xs4all.nl
>http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
>

-- ScottG

-----------------------------------------------------------------

-- Scott Gravenhorst
-- GateManPoly - FPGA Based Polyphonic MIDI LA/FM Synthesizer
-- GateMan-III - FPGA Based Monophonic MIDI LA/FM Synthesizer
-- PolyDaWG/8 - FPGA Based 8 Voice Polyphonic MIDI Synthesizer
-- FatMan: home1.gte.net/res0658s/fatman/
-- NonFatMan: home1.gte.net/res0658s/electronics/
-- When the going gets tough, the tough use the command line.




More information about the Synth-diy mailing list