Divider (divider_s)
Divides two integer values together.
Design
Divides two short values together generating a quotient and a remainder. The division method can be selected from: truncated (C/C++ standard method), and floored (Python // operator).
The mathematical representation of the implementation is given in (103).
\(x[n]\) and \(y[n]\) are the input values.
\(z[n]\) is the output values.
\(r[n]\) is the remainder values.
In (103), all outputs are converted to integer representations.
A block diagram representation of the implementation is given in Figure 143:.
Figure 143: Divider implementation.
Interface
<?xml version="1.0"?>
<componentspec>
<property name="method" type="enum" initial="true" writable="false" enums="floor,truncate" default="truncate"
description="Division definition to use"/>
<port name="input" producer="false" protocol="short_timed_sample-prot"/>
<port name="denominator" producer="false" protocol="short_timed_sample-prot"/>
<port name="output" producer="true" optional="true" protocol="short_timed_sample-prot"/>
<port name="remainder" producer="true" optional="true" protocol="short_timed_sample-prot"/>
</componentspec>
Ports
Inputs:
input: Numerator samples port.Protocol:
short_timed_sample-protOptional:
False
denominator: Denominator samples port.Protocol:
short_timed_sample-protOptional:
False
Outputs:
output: Quotient samples port.Protocol:
short_timed_sample-protOptional:
True
remainder: Remainder samples port.Protocol:
short_timed_sample-protOptional:
True
Opcode Handling
Division is only applied to the sample opcode messages. All other opcode messages received on input are passed through this component to both output ports. All messages with a non-sample opcode received on denominator are discarded.
Sample message lengths received on input are preserved on the output. Sample message lengths received on denominator are ignored.
Properties
method: Division definition to use.Type:
enumAllowed values:
['floor', 'truncate']
Access:
Parameter:
FalseWritable:
FalseInitial:
TrueVolatile:
False
Default value:
truncate
Implementations
Example Application
<?xml version="1.0"?>
<application done="file_write">
<instance component="ocpi.core.file_read" name="numerator">
<property name="filename" value="input.bin"/>
</instance>
<instance component="ocpi.core.file_read" name="denominator">
<property name="filename" value="denominator.bin"/>
</instance>
<instance component="ocpi.comp.sdr.math.divider_s" name="divider">
<property name="method" value="truncate"/>
</instance>
<instance component="ocpi.core.file_write" name="quotient">
<property name="filename" value="output.bin"/>
</instance>
<instance component="ocpi.core.file_write" name="remainder">
<property name="filename" value="remainder.bin"/>
</instance>
<connection>
<port instance="numerator" name="output"/>
<port instance="divider" name="input"/>
</connection>
<connection>
<port instance="denominator" name="output"/>
<port instance="divider" name="denominator"/>
</connection>
<connection>
<port instance="divider" name="output"/>
<port instance="quotient" name="input"/>
</connection>
<connection>
<port instance="divider" name="remainder"/>
<port instance="remainder" name="input"/>
</connection>
</application>
Dependencies
The dependencies to other elements in OpenCPI are:
There is also a dependency on:
ieee.std_logic_1164
ieee.numeric_std
Limitations
Limitations of divider_s are:
In order to keep compatibility between HDL and RCC, division by zero does not raise any exceptions, but instead returns the following:
If division method is
floor: 0 or -1 on the Quotient port (depending upon the sign ofinput), andinputis passed as the remainder.If division method is
truncate: 1 or -1 on the Quotient port (depending upon the sign ofinput), andinputis passed as the remainder.
Testing
Tested platforms: None
Component testing not completed.