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 (92).
In (92):
\(x[n]\) is the input values.
\(y[n]\) is the output values.
\(b\) is the base value, this is set by the
baseproperty.\(N\) is the output scale power, this is set by the
scale_outputproperty.
A block diagram representation of the implementation is given in Figure 140:.
Figure 140: 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-protOptional:
False
Outputs:
output: Primary output samples port.Protocol:
ushort_timed_sample-protOptional:
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:
floatAccess:
Parameter:
TrueWritable:
FalseInitial:
FalseVolatile:
False
Default value:
10
scale_output: output scale factor, the output is multiplied by \(2^{scale_output}\).Type:
ucharAccess:
Parameter:
FalseWritable:
TrueInitial:
FalseVolatile:
False
Default value:
0
Implementations
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.