Logarithm (log_us)

Calculates the logarithm to a base of all input sample values.

Design

The logarithm of the input value is taken to a base value, this is then scaled by a factor of two before the output is rounded to the nearest integer.

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

(94)\[y[n] = (2^N) log_b(x[n])\]

In (94):

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

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

  • \(b\) is the base value, this is set by the base property.

  • \(N\) is the output scale power, this is set by the scale_output property.

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

Block diagram outlining logarithm implementation.

Figure 142: Logarithm implementation.

If the input is set to 0 this is converted to a 1 before the log operation is performed.

Interface

<?xml version="1.0"?>
<componentspec>
  <property name="base" type="float" parameter="true" writable="false" default="10" description="Base of the logarithm."/>
  <property name="scale_output" type="uchar" writable="true" default="0"
    description="output scale factor, the output is multiplied by :math:`2^{scale_output}`."/>
  <port name="input" producer="false" protocol="ushort_timed_sample-prot"/>
  <port name="output" producer="true" protocol="ushort_timed_sample-prot"/>
</componentspec>

Ports

Inputs:

  • input: Primary input samples port.

    • Protocol: ushort_timed_sample-prot

    • Optional: False

Outputs:

  • output: Primary output samples port.

    • Protocol: ushort_timed_sample-prot

    • Optional: False

Opcode Handling

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

Properties

  • base: Base of the logarithm.

    • Type: float

    • Access:

      • Parameter: True

      • Writable: False

      • Initial: False

      • Volatile: False

    • Default value: 10

  • scale_output: output scale factor, the output is multiplied by \(2^{scale_output}\).

    • Type: uchar

    • Access:

      • Parameter: False

      • Writable: True

      • Initial: False

      • Volatile: False

    • Default value: 0

Implementations

  • log_us (HDL)

    Pipelined HDL implementation of logarithm, allowing one input and one output every FPGA clock cycle, with a delay of 24 clock cycles through the pipeline.

  • log_us (RCC)

Example Application

<?xml version="1.0"?>
<application done="file_write">
  <instance component="ocpi.core.file_read" connect="log_us">
    <property name="filename" value="input.bin"/>
  </instance>
  <instance component="ocpi.comp.sdr.math.log_us" connect="file_write">
    <property name="base" value="10.0"/>
    <property name="scale_output" value="0"/>
  </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 log_us are:

  • Base values less than or equal to one are not supported.

Testing

Tested platforms: None

Component testing not completed.