Carrier Generator (carrier_generator)
A numerically controlled oscillator (NCO) for generating complex sinusoidal signals.
Design
This component is the equivalent of carrier_generator_xs component within OpenCPI SDR Components Library (ocpi.comp.sdr) .
Generates a complex stream of shorts which are the sine and cosine waves, with both the amplitude and frequency of the output wave settable.
The mathematical representation of the implementation is given in (1).
In (1):
\(x[n]\) is the input values.
\(y[n]\) is the output values.
\(A\) is the output amplitude.
\(\delta\) controls the frequency of the output wave, and is set by the
step_sizeproperty.
The relation between the output frequency and \(\delta\) is given by (2).
The mathematical representation of the implementation is given in (1).
In (1):
\(f\) is the desired output frequency
\(F_s\) is the sample rate of the system.
\(\delta\) is the value same as set in (1).
Interface
<componentspec>
<property name="enable" type="bool" writable="true" default="true" description="When true an output carrier wave is generated. When false the component output is disabled."/>
<property name="step_size" type="long" writable="true" default="0" description="Sets the step size of the carrier generator which determines the output frequency. step_size = (desired_freq*2^32)/sample_rate"/>
<property name="carrier_amplitude" type="ushort" writable="true" default="19872" description="Sets the amplitude of the output carrier signal. Set to floor(desired_amplitude/1.646760258)."/>
<property name="discontinuity_on_step_size_change" type="bool" writable="true" default="false" description="Sends a discontinuity message at the point the step size changes at the output."/>
<property name="discontinuity_on_carrier_amplitude_change" type="bool" writable="true" default="false" description="Sends a discontinuity message at the point the carrier amplitude changes at the output."/>
<property name="message_length" type="ushort" writable="false" initial="true" default="512" description="Sets the output message length. Must not be 0."/>
<port name="output" producer="true" protocol="complex_short_timed_sample-prot"/>
</componentspec>
Ports
Inputs:
None.
Outputs:
output: Primary output samples port.Protocol:
complex_short_timed_sample-protOptional:
False
Properties
enable: When true an output carrier wave is generated. When false the component output is disabled.Type:
boolAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
true
step_size: Sets the step size of the carrier generator which determines the output frequency. step_size = (desired_freq*2^32)/sample_rate.Type:
longAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
0
carrier_amplitude: Sets the amplitude of the output carrier signal. Set to floor(desired_amplitude/1.646760258). Should not be set to greater than 19,872, as this has a safety margin under the maximum of the short output values - this value maps to near full range output on a 16-bit signed value.Type:
ushortAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
19872
discontinuity_on_step_size_change: Sends a discontinuity message at the point the step size changes at the output. The discontinuity is sent directly after the last output sample generated using the previous step size is sent.Type:
boolAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
false
discontinuity_on_carrier_amplitude_change: Sends a discontinuity message at the point the carrier amplitude changes at the output. The discontinuity is sent directly after the last output sample generated using the previous carrier amplitude values is sent.Type:
boolAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
false
message_length: Sets the output message length. Must not be 0.Type:
ushortAccess:
Parameter:
FalseWritable:
FalseInitial:
TrueVolatile:
False
Default value:
512
Implementations
carrier_generator(HDL)
Example Application
<?xml version="1.0"?>
<application done="file_write">
<instance component="ocpi.comp.sdr.generator.carrier_generator" connect="file_write">
<property name="enable" value="true"/>
<property name="step_size" value="150000"/>
<property name="carrier_amplitude" value="19872"/>
</instance>
<instance component="ocpi.core.file_write">
<property name="filename" value="output.bin"/>
</instance>
</application>
Dependencies
The dependencies to other elements in OpenCPI are:
There is also a dependency on:
ieee.std_logic_1164
ieee.numeric_std
ieee.math_real
Limitations
Limitations of carrier_generator_xs are:
Setting of
carrier_amplitudeabove 19,872 is untested behaviour and will result in unpredictable behaviour. At low carrier amplitude values (100 or less) the error from a true carrier becomes a significant proportion of the output signal magnitude.Setting of
message_sizeaboveocpi_max_bytes_output/sample_size_bytesis unsupported behaviour.