Ramp Generator (ramp_generator_l)

Generates a sawtooth waveform.

Design

Generates a ramp output. The shape of the sawtooth wave is to be set using the properties step_size, start_amplitude, and stop_amplitude.

The output of the ramp generator is controlled by a counter that increments by step_size every output sample. Typically the ramp generator is configured such that the counter counts toward stop_amplitude. When the counter value equals or passes the stop_amplitude it resets its value to start_amplitude.

Graph of sawtooth wave and how available properties relate to the output wave.

Figure 384: Ramp generator output.

The mathematical representation of the implementation is given in (103) and (104).

(103)\[A_{step} = \frac{A_{stop} - A_{start}}{n_{stop} - n_{start}}\]
(104)\[\begin{split}x[n] = \begin{cases} A_{start} + n A_{step} & n_{start} < n <= n_{stop} \\ A_{start} & \text{otherwise} \end{cases}\end{split}\]

In (103) and (104):

  • \(x[n]\) is the output values.

  • \(A_{start}\), \(A_{stop}\) are start_amplitude and stop_amplitude respectively.

  • \(A_{step}\) is the step_size.

  • \(n_{start}\), \(n_{stop}\) are start sample and stop sample respectively.

  • \(n\) is samples counting from \(A_{start}\).

Interface

<?xml version="1.0"?>
<componentspec>
  <property name="message_length" type="ushort" writable="true" default="512"
    description="Sets the output message length. Must not be 0."/>
  <property name="step_size" type="long" writable="true" default="1"
    description="Step size is the amount the amplitude changes between each sample (default 1, Type: long). This effectively sets
      the period of the sawtooth wave."/>
  <property name="start_amplitude" type="long" writable="true" default="0"
    description="Start amplitude is the amplitude value that the sawtooth starts (default is 0, Type: long)."/>
  <property name="stop_amplitude" type="long" writable="true" default="0"
    description="Stop amplitude is the amplitude value that the sawtooth stops at (default 0, Type: long)."/>
  <property name="enable" type="bool" writable="true" default="true" description="When true the ramp generator is enabled."/>
  <property name="discontinuity_on_amplitude_change" type="bool" writable="true" default="false"
    description="This boolean will control if a discontinuity is sent when the start/stop amplitude changes."/>
  <property name="discontinuity_on_step_size_change" type="bool" writable="true" default="false"
    description="This boolean will control if a discontinuity is sent when the step_size changes."/>
  <port name="output" producer="true" protocol="long_timed_sample-prot"/>
</componentspec>

Ports

Inputs:

None.

Outputs:

  • output: Primary output samples port.

    • Protocol: long_timed_sample-prot

    • Optional: False

Opcode Handling

If discontinuity_on_amplitude_change or discontinuity_on_step_size_change are true, a discontinuity opcode is output whenever amplitude or step size related properties are changed during run time, respectively.

Properties

  • message_length: Sets the output message length. Must not be 0.

    • Type: ushort

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: 512

  • step_size: Step size is the amount the amplitude changes between each sample (default 1, Type: long). This effectively sets the period of the sawtooth wave.

    • Type: long

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: 1

  • start_amplitude: Start amplitude is the amplitude value that the sawtooth starts (default is 0, Type: long).

    • Type: long

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: 0

  • stop_amplitude: Stop amplitude is the amplitude value that the sawtooth stops at (default 0, Type: long).

    • Type: long

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: 0

  • enable: When true the ramp generator is enabled.

    • Type: bool

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: true

  • discontinuity_on_amplitude_change: This boolean will control if a discontinuity is sent when the start/stop amplitude changes.

    • Type: bool

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: false

  • discontinuity_on_step_size_change: This boolean will control if a discontinuity is sent when the step_size changes.

    • Type: bool

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: false

Implementations

Example Application

<?xml version="1.0"?>
<application done="file_write">
  <instance component="ocpi.comp.sdr.generator.ramp_generator_l" connect="file_write">
    <property name="enable" value="true"/>
    <property name="message_length" value="1024"/>
    <property name="start_amplitude" value="-64"/>
    <property name="stop_amplitude" value="64"/>
    <property name="step_size" value="2"/>
    <property name="discontinuity_on_amplitude_change" value="false"/>
    <property name="discontinuity_on_step_size_change" value="false"/>
  </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 ramp_generator_l are:

  • Setting message_length to 0 or greater than the ocpi_max_bytes_output/sample_size_bytes will result in undefined behaviour.

Testing

Tested platforms: None

Component testing not completed.