%% Design a HDL-Compatible NCO Source
% This example shows how to design an HDL-compatible NCO source. 
%% 
% Write a function that creates and calls the System object(TM), based on 
% the waveform requirements. You can generate HDL from this function. 
% 
% *Note:* This object syntax runs only in R2016b or later. If you are using an 
% earlier release, replace each call of an object with the equivalent |step|
% syntax. For example, replace |myObject(x)| with |step(myObject,x)|.
%
% <include>HDLNCO510.m</include> 
%
%%
% Call the object to generate data points in a sine wave. The
% input to the object is a valid control signal.  
Ts = 1/4000;
y = zeros(1,1/Ts);
for k = 1:1/Ts
   y(k) = HDLNCO510(true);
end
%% 
% Plot the mean-square spectrum of the 510 Hz sine wave generated by the 
% NCO. 
sa = dsp.SpectrumAnalyzer('SampleRate',1/Ts);
sa.SpectrumType = 'Power density';
sa.PlotAsTwoSidedSpectrum = false;
sa(y')

%% 
% Copyright 2012 The MathWorks, Inc.