Square Scaled (square_scaled_s)

Squares input values and right shifts the result.

Design

Square an the values in a sample opcode message and then right shift the result of the square operation.

The mathematical representation of the implementation is given in (99).

(99)\[y[n] = \lfloor \frac{x[n] * x[n]}{2^N} \rfloor\]

In (99):

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

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

  • \(N\) is the number of bit the result of the square is right shifted by.

A block diagram representation of the implementation is given in Figure 146:.

Block diagram outlining square scaled implementation.

Figure 146: Square scaled implementation.

Interface

<?xml version="1.0"?>
<componentspec>
  <property name="scale_output" type="uchar" parameter="true" writable="false" default="16" description="Number of bits the result of the square operation is right shifted by."/>
  <port name="input" producer="false" protocol="short_timed_sample-prot"/>
  <port name="output" producer="true" protocol="short_timed_sample-prot"/>
</componentspec>

Ports

Inputs:

  • input: Primary input samples port.

    • Protocol: short_timed_sample-prot

    • Optional: False

Outputs:

  • output: Primary output samples port.

    • Protocol: short_timed_sample-prot

    • Optional: False

Opcode Handling

The square and scaling is only applied to values in a sample opcode message. All other opcodes messages received are passed through this component without any effect.

Properties

  • scale_output: Number of bits the result of the square operation is right shifted by. Setting scale_output to the default value of 15 ensures that the output never overflows for full scale 16-bit input values.

    • Type: uchar

    • Access:

      • Parameter: True

      • Writable: False

      • Initial: False

      • Volatile: False

    • Default value: 16

Implementations

Example Application

<?xml version="1.0"?>
<application done="file_write">
  <instance component="ocpi.core.file_read" connect="square_scaled_s">
    <property name="filename" value="input.bin"/>
  </instance>
  <instance component="ocpi.comp.sdr.math.square_scaled_s" connect="file_write">
    <property name="scale_offset" value="15"/>
  </instance>
  <instance component="ocpi.core.file_write">
    <property name="filename" value="output.bin"/>
  </instance>
</application>

Dependencies

The dependencies to other elements in OpenCPI are:

  • None

There is also a dependency on:

  • ieee.std_logic_1164

  • ieee.numeric_std

Limitations

Limitations of square_scaled_s are:

  • None.

Testing

Tested platforms: None

Component testing not completed.