title: Simple Verilog VPI module to open audio files
body: <p>I would like to write a VPI/PLI interface which will open audio files (i.e. wav, aiff, etc)
  and present the data to Verilog simulator. I am using Icarus at the moment and wish to
  use libsndfile to handle input file formats and data type conversion.</p>
  
  <p>I am not quite sure what to use in the C code ... have looked at IEEE 1364-2001 and still
  confused which functions am I supposed to use.</p>
  
  <p>Ideally I'd like to have a verilog module with data port (serial or parallel), clock input
  and start/stop pin. I'd like to implement two modules, one for playback from from a file, and another would record output from a filter under test.</p>
  
  <p><strong>Can I do it all in C and just instantiate the module in my testbench or I'll have to write
  a function (say <code>$read_audio_data</code>) and wrapper module to call it on each clock pulse ??</strong></p>
  
  <p>Hm, or may be I need to create the module and then get a handle for it and pass value/vect
  to the handle somehow ?</p>
  
  <p>I am not quite concerned about how file names will be set, as I probably
  wouldn't do it from the verilog code anyway.
  And I will probably stick to 24-bit integer samples for the time being and
  <code>libsndfile</code> supposed to handle conversion quite nicely.
  Perhaps, I'll stick to serial for now (may be even do in the I2S-like fashion) and
  de-serialise it in Verilog if needed.</p>
  
  <p>Also I have looked at Icarus <a href="ftp://icarus.com/pub/eda/verilog/plug-ins/image-vpi/" rel="nofollow">plug-in</a> which implements a video camera that reads PNG files,
  though there are many more aspects to image processing then there is to audio.
  Hence that code looks a bit overcomplicated to me at the moment - neither I managed to get
  it to run.</p>