Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20705 Discussions

Arbitrary Waveform Generator

Altera_Forum
Honored Contributor II
1,915 Views

Hi, Im trying to build an arbitrary waveform generator using the Stratix-III DSP development kit. I have been successful at outputting a sine wave using the NCO megafunction, but is there a way for me to load a ROM initialization file or at least point the NCO to one? I know that there are a few initialization files created during compile time, sine.hex.. etc, but I am still baffled with their format. I can create an Intel-hex file without a problem in Matlab, but none of my waveforms look correct when loaded into the FPGA. Is there a better way of doing this? 

 

Thanks
0 Kudos
9 Replies
Altera_Forum
Honored Contributor II
445 Views

I would rather do my own LUT and play logic. Since you are not doing anything else such as modulation apart from outputting waves then it is quite easy to design your addressing logic using modulo adder.

0 Kudos
Altera_Forum
Honored Contributor II
445 Views

 

--- Quote Start ---  

Is there a better way of doing this? 

 

--- Quote End ---  

 

 

You can use a dual-ported RAM. One side of the RAM can appear as an Avalon-MM slave, and you can then read/write to the RAM. The other side of the interface can then be accessed by an FSM that reads data from RAM and sends it to your ADC. You can get 'fancy' by making this an Avalon-ST streaming source, and making your ADC an Avalon-ST sink, and then you can wire them altogether in SOPC Builder or Qsys. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

I don't want to sound like a n00b, but ..... that seems like alot more work that what I want to do. 

 

I didn't mention that this is just a quick and dirty project, it doesn't need to be the "correct" method, just the fast way.  

 

Anyway, I wrote up a sinewave in matlab, and got it recognized by the NCO at compile time. It works.....except for the fact that it "overlaps" on itself every few clock periods. It seems that the NCO is looking for a file a certain size, not sure though.  

 

This is slightly off topic, but lastly, I heard that some higher-speed DACs don't like it when they are told to hold a value for a constant amount of time, ie, put out a pulse with a really long period. Is this true? Has anyone heard of this? The Terasic DAC/ADC board manual doesn't indicate this so I'm a little confused. In the future I will like to create a ROM that is filled with values for a Pulse.  

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

You can find out size of NCO's table from phase resolution or look at synthesis report. However it will be much easier to do your own LUT (power of 2 for example) then insert mif of one cycle worth of your waveform. All you need is then a binary adder outputting address. The lowest frequency would be that of clock/table size. You increment your adder by a word of 1 or more(1 gives lowest frequency). 

 

As for the long pulse on DAC, you might look at dc characteristic of your DAC and hope you don't mix it up with sample and hold issue.
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

If you review the NCO user guide, you'll notice, that the "large ROM" implementation involves full 360° sine tables. In so far, this (and only this) NCO variant is suited to place an arbitrary function table instead of the sine. Because the NCO design is protected IP, you can't change other features than the table. 

 

I agree with kaz and Dave, that it's easy to set up a basic NCO (phase accumulator and look-up table) on your own, but for a fixed function table, the suggested method should work.
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

The nco ip may have one of several LUT configurations e.g. full cycle or quarter or even small table in which case intermediate values will be interpolated by the ip. In all cases if you match the table with your waveforms then it could be possible to run your waveforms instead of sine wave. 

The problem would be how to do that match? So it might be much easier not to hack into the ip at all. 

 

It may even use cordic structure which wouldn't suit the case.
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

OK, thanks for the input. Anyway, I wrote up a script that takes a Matlab waveform and converts it to the intel hex file. I get great sinewaves, modulated sinewaves, triangle waves, etc. Unfortunately, my pulses look like the attached pictures. Before I start hacking away at my DAC code, does anyone have a clue what might be happening? These were supposed to be continuous pulse trains, 4us long, but instead i get short pulses. 

 

 

http://i56.tinypic.com/2d0l8jk.jpg  

 

http://i53.tinypic.com/24azwcl.jpg  

 

http://i51.tinypic.com/20p3lw.jpg  

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

Late reply,... but thanks everyone for the help. I figured this out a few weeks ago and just ended up building an NCO by hand. It turns out the DC characteristics of the DAC weren't that great.

0 Kudos
Altera_Forum
Honored Contributor II
445 Views

hi, can i do this by using the cyclone ii de2 board? 

 

p/s: i just want to test out sine wave generated for some interval.
0 Kudos
Reply