Forum Discussion
26 Replies
- Altera_Forum
Honored Contributor
Hi,
an NCO generates any frequency below clk/2 on the fly by changing the tuning word value. The tuning word value depends on your clock frequency and tone as well as the width of tuning word and there is a formula for that. The easiest way is this: When you enter your NCO settings you will find entry for sampling frequency(your effective clock) and a given tone in Hz ...etc then the GUI will get you the tuning word value. kaz - Altera_Forum
Honored Contributor
Real numbers require a decimal point, so 425e0 is not a valid real number, but 425.0 will work.
It is true that if you have a system clock of 50MHz and wish to produce a tone of 425Hz, the MIF can get large. On the other hand, you can throttle the generation of the tone using the enable strobe to manage the size of the ROM generated. The sample frequency then becomes the rate at which the enable line is strobed while the tone value stays the same. While the original question was to be able to generate a single tone, it is true the Altera NCO can produce a variety of tones based on the tuning word. If tuning is something that is required, I'd recommend reading up on cordics (http://en.wikipedia.org/wiki/cordic). - Altera_Forum
Honored Contributor
Hi,
I don't see tuning as an issue for our friend Kapilvar. But as a ready-made design I suggested that. If it was me, I will generate my own mif using ant tool and simply read out in firmware - a very basic module. At work, we generate carriers just from few data points, no need for memory even. You may even just as well use two values if you accept harmonics. so just use a clock twice your tone and output the two values. kaz - Altera_Forum
Honored Contributor
--- Quote Start --- If it was me, I will generate my own mif using ant tool and simply read out in firmware - a very basic module. --- Quote End --- Why use a different tool when VHDL can do this for you? I suppose if you are using NIOS II this makes sense, but without it I don't quite follow how you would read it out? It is true that you may only require a few points to generate a tone depending on the quality of the tone that is needed. - Altera_Forum
Honored Contributor
Hi,
I mean read out in firmware i.e. a normal HDL model with memory initiailsed by mif... You are quite right that if you can use vhdl itself as your computation tool besides its use as the normal firmware design that is impressive indeed as in your program. In fact I have never used it as such but I need to try it... the problem is at the end of the day a more powerful tool like Matlab will be eventually needed and mess-up the experience... Kaz - Altera_Forum
Honored Contributor
--- Quote Start --- ... the problem is at the end of the day a more powerful tool like Matlab will be eventually needed and mess-up the experience... --- Quote End --- I actually try to avoid using MATLAB for anything other than analysis. I've successfully written RRC and Gaussian filter fixed-point coefficient functions for inclusion into hand-written FIR filters for digital downconversion in software defined radios. Fundamentally, I agree that, for rapid prototyping, using the Megafunctions is probably the easiest route, but for the sake of learning how to implement something efficiently and be somewhat architecture agnostic (as well as not relying on third-party tools) - nothing beats hand writing it and taking the time to fully understand the design. I am a firm believer in the fact that the power of VHDL allows one to be third party tool independent. - Altera_Forum
Honored Contributor
Hi,
I agree that handcrafting is essential for understanding and then I will use whatever is faster. By the way you can modify your previous code to be more efficient by using the idea of DDS(or NCO) i.e. generate just one suitable LUT then a use modulo adder to address the table by jumping according to a tuning word value. If you don't want any tuning then just use a fixed word. This is explained fully in DDS tutorial from AnalogDevices. kaz - Altera_Forum
Honored Contributor
hi kaz,,
in NCO i did like that..it generate some file of .v and .mif for sine and cos but in that mif file not any data is their,.....can u plz tell me where is the problem - Altera_Forum
Honored Contributor
hi bpadalino..
i tried with tone frequency : 44.0e1 but it still giving an error Error (10536): VHDL Loop Statement error at complex_tone_ram.vhdl(29): loop must terminate within 10,000 iterations can u plz modify ur code for that perticular frequency... - Altera_Forum
Honored Contributor
--- Quote Start --- hi kaz,, in NCO i did like that..it generate some file of .v and .mif for sine and cos but in that mif file not any data is their,.....can u plz tell me where is the problem --- Quote End --- Hi, You better try the module first, it will work... you probably have chosen a setting that does not need memory. I remember there is setting for "Large memory", "small memory" , "cordic" ...etc. If you choose small memory it uses multipliers, if you choose large memory it does not use multiplier but mem could be very large... You can see the resource usage in the GUI. The cordic uses logic only instead of multipliers and (I believe) it doesn't use memory so no mif data needed. Kaz