pg060-floating-point
pg060-floating-point
Operator v7.1
Chapter 1: Overview
Navigating Content by Design Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Core Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Unsupported Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Licensing and Ordering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Chapter 5: C Model
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Unpacking and Model Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
C Model Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Compiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Appendix A: Upgrading
Migrating to the Vivado Design Suite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Upgrading in the Vivado Design Suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Appendix B: Debugging
Finding Help on Xilinx.com . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Debug Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Simulation Debug. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
AXI4-Stream Interface Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
° Comparison Supported
N/A
S/W Driver
° Reciprocal
Reciprocal square root Tested Design Flows(2)
°
Absolute value Vivado® Design Suite
° Design Entry
System Generator for DSP
° Natural logarithm
For supported simulators, see the
Simulation
° Exponential Xilinx Design Tools: Release Notes Guide.
Overview
• Hardware, IP, and Platform Development: Creating the PL IP blocks for the hardware
platform, creating PL kernels, subsystem functional simulation, and evaluating the
Vivado timing, resource and power closure. Also involves developing the hardware
platform for system integration. Topics in this document that apply to this design
process include:
° Port Descriptions
° Clocking
° Resets
° C Model
Core Overview
The Xilinx Floating-Point Operator core allows a range of floating-point arithmetic
operations to be performed on FPGA. The operation is specified when the core is
generated, and each operation variant has a common interface. This interface is shown in
Figure 2-1.
Unsupported Features
See Standards.
Product Specification
Standards
IEEE-754 Support
The Xilinx® Floating-Point Operator core complies with much of the IEEE-754 Standard
[Ref 1]. The deviations generally provide a better trade-off of resources against
functionality. Specifically, the core deviates in the following ways:
• Non-Standard Wordlengths
• Denormalized Numbers
• Rounding Modes
• Signaling and Quiet NaNs
Non-Standard Wordlengths
The Xilinx Floating-Point Operator core supports a different range of fraction and exponent
wordlength than defined in the IEEE-754 Standard.
Basic Formats:
• binary16 (Half Precision Format) – Uses 16 bits, with an 11-bit fraction and 5-bit
exponent.
• binary32 (Single Precision Format) – Uses 32 bits, with a 24-bit fraction and 8-bit
exponent.
• binary64 (Double Precision Format) – Uses 64 bits, with a 53-bit fraction and 11-bit
exponent.
• binary128 (Quadruple Format) – not supported
• Uses up to 80 bits.
• Exponent width of 4 to 16 bits.
Denormalized Numbers
The exponent limits the size of numbers that can be represented. It is possible to extend the
range for small numbers using the minimum exponent value (0) and allowing the fraction to
become denormalized. That is, the hidden bit b 0 becomes zero such that
b 0 . b 1 b 2 … b p – 1 < 1 . Now the value is given by:
we – 1
– 2 – 2
s
v = ( –1 ) 2 0.b 1 b 2 … b w – 1
f
These denormalized numbers are extremely small. For example, with single precision the
– 126
value is bounded v < 2 . As such, in most practical calculation they do not contribute to
the end result. Furthermore, as the denormalized value becomes smaller, it is represented
with fewer bits and the relative rounding error introduced by each operation is increased.
The Xilinx Floating-Point Operator core does not support denormalized numbers for most
operators. In FPGAs, the dynamic range can be increased using fewer resources by
increasing the size of the exponent (and a 1-bit increase for single precision increases the
256
range by 2 ). If necessary, the overall wordlength of the format can be maintained by an
associated decrease in the wordlength of the fraction.
To provide robustness, the core treats denormalized operands as zero with a sign taken
from the denormalized number. Results that would have been denormalized are set to an
appropriately signed zero.
The exception to the above rules is the absolute value operator, which propagates
denormalized operands to the output.
The support for denormalized numbers cannot be switched off on some processors.
Therefore, there might be very small differences between values generated by the
Floating-Point Operator core and a program running on a conventional processor when
numbers are very small. If such differences must be avoided, the arithmetic model on the
conventional processor should include a simple check for denormalized numbers. This
check should set the output of an operation to zero when denormalized numbers are
detected to correctly reflect what happens in the FPGA implementation.
Rounding Modes
Only the default rounding mode, Round to Nearest (as defined by the IEEE-754 Standard
[Ref 1]), is supported on most operators. This mode is often referred to as Round to Nearest
Even, as values are rounded to the nearest representable value, with ties rounded to the
nearest value with a zero least significant bit. The accumulator operator only supports
Round Towards Zero. The float-to-fixed operator uses Round to Nearest which differs from
the behavior of the C language when casting floating-point values to integers.
Accuracy of Results
Compliance to the IEEE-754 Standard requires that elementary arithmetic operations
produce results accurate to half of one Unit in the Last Place (ULP). The Xilinx Floating-Point
Operator satisfies this requirement for the multiply, add/subtract, fused multiply-add,
divide, square-root and conversion operators.
Performance
Latency
The latency of most operators can be set between 0 and a maximum value that is
dependent upon the parameters chosen. The maximum latency of the Floating-Point
Operator core for all operators can be found on the Vivado Integrated Design Environment
(IDE).
The maximum latency of the divide and square root operations is Fraction Width + 4, and
for compare operation it is two cycles. The float-to-float conversion operation is three
cycles when either fraction or exponent width is being reduced; otherwise it is two cycles. It
is two cycles, even when the input and result widths are the same, as the core provides
conditioning in this situation. For more information, see Cycles per Operation.
Resource Utilization
For details about performance, visit Performance and Resource Utilization.
Port Descriptions
X-Ref Target - Figure 2-1
s_axis_a_tvalid m_axis_result_tvalid
s_axis_a_tready m_axis_result_tready
s_axis_a_tdata m_axis_result_tdata
s_axis_a_tuser m_axis_result_tuser
s_axis_a_tlast m_axis_result_tlast
s_axis_b_tvalid
s_axis_b_tready
s_axis_b_tdata
s_axis_b_tuser
s_axis_b_tlast
s_axis_c_tvalid
s_axis_c_tready
s_axis_c_tdata
s_axis_c_tuser
s_axis_c_tlast
s_axis_operation_tvalid
s_axis_operation_tready
s_axis_operation_tdata
s_axis_operation_tuser
s_axis_operation_tlast
aclk
aresetn
aclken
X13146
All AXI4-Stream port names are lower case, but for ease of visualization, upper case is used
in this document when referring to port name suffixes, such as TDATA or TLAST.
A Channel (s_axis_a_tdata)
Operand A input.
B Channel (s_axis_b_tdata)
Operand B input.
C Channel (s_axis_c_tdata)
Operand C input.
aclk
All signals are synchronous to the aclk input.
aclken
When aclken is deasserted, the clock is disabled, and the state of the core and its outputs
are maintained.
aresetn
When aresetn is asserted, the core control circuits are synchronously set to their initial
state. Any incomplete results are discarded, and m_axis_result_tvalid is not
generated for them. While aresetn is asserted m_axis_result_tvalid is
synchronously deasserted. The core is ready for new input one cycle after aresetn is
deasserted, at which point slave channel tvalids are asserted. aresetn takes priority
over aclken. If aresetn is required to be gated by aclken, then this can be done
externally to the core.
IMPORTANT: aresetn must be driven low for a minimum of two clock cycles to reset the core.
The following flag signals provide exception information. Additional detail on their
behavior can be found in the IEEE-754 Standard. The exception flags are not presented as
discrete signals in Floating-Point Operator v7.1, but instead are provided in the RESULT
channel m_axis_result_tuser subfield. For more details, see Output Result Channel.
The accumulator operator adds two non-standard exception flags: Accumulator Input
Overflow, and Accumulator Overflow. For more information about these flags, see
Accumulator Design Guidelines.
UNDERFLOW
Underflow is signaled when the operation generates a non-zero result which is too small to
be represented with the chosen precision. The result is set to zero. Underflow is detected
after rounding.
Note: A number that becomes denormalized before rounding is set to zero and underflow signaled.
OVERFLOW
Overflow is signaled when the operation generates a result that is too large to be
represented with the chosen precision. For most operators, the output is set to a correctly
signed ∞ .
Due to its different rounding mode, the accumulator operator sets the output to the target
format's largest finite number with the sign of the pre-rounded result.
INVALID_OP
Invalid general-computational or signaling-computational operations are signaled when
the operation performed is invalid. According to the IEEE-754 Standard [Ref 1], the
following are invalid operations:
1. Any operation on a signaling NaN. (This is not relevant to the core as all NaNs are
treated as Quiet NaNs).
2. Addition or subtraction of infinite values where the sign of the result cannot be
determined. For example, magnitude subtraction of infinities such as (+ ∞ ) +(- ∞ ).
3. Multiplication, or fused multiply-add, where 0 × ∞ .
4. Division where 0/0 or ∞ / ∞ .
5. Square root if the operand is less than zero. A special case is sqrt(-0), which is defined
to be -0 by the IEEE-754 Standard.
6. When the input of a conversion precludes a faithful representation that cannot
otherwise be signaled (for example NaN or infinity).
7. Logarithm if the input is less than 0. A special case is log(-0) which is defined to be - ∞ .
When an invalid operation occurs, the associated result is a Quiet NaN. In the case of
floating-point to fixed-point conversion, NaN and infinity raise an invalid operation
exception. If the operand is out of range, or an infinity, then an overflow exception is raised.
By analyzing the two exception signals it is possible to determine which of the three types
of operand was converted. (See Table 2-4.)
When the operand of a Floating-point to fixed-point conversion is a NaN, the result is set
to the most negative representable number. When the operand is infinity or an
out-of-range floating-point number, the result is saturated to the most positive or most
negative number, depending upon the sign of the operand.
Note: Floating-point to fixed-point conversion does not treat a NaN as a Quiet NaN, because NaN
is not representable within the resulting fixed-point format, and so can only be indicated through an
invalid operation exception.
The absolute value operator does not signal an invalid operation when a Signaling NaN is
input, as it is not a general computational or a signaling computational operation.
Note: The fused multiply-add operator does not signal an invalid operation when
0 × ∞ + Quiet NaN is performed.
DIVIDE_BY_ZERO
DIVIDE_BY_ZERO is asserted when a divide operation is performed where the divisor is zero
and the dividend is a finite non-zero number. The result in this circumstance is a correctly
signed infinity.
Two parameters have been adopted for the purposes of generalizing the format employed
by the Floating-Point Operator core. These specify the total format width and the width of
the fractional part. For standard single precision types, the format width is 32 bits and
fraction width 24 bits. In the following description, these widths are abbreviated to w and
w f , respectively.
A floating-point number is represented using a sign, exponent, and fraction (which are
denoted as ’s,’ ’E,’ and b 0 .b 1 b 2 …b , respectively).
wf – 1
s E
The value of a floating-point number is given by: v = ( – 1 ) 2 b 0 .b 1 b 2 …b wf – 1
–i
The binary bits, b i , have weighting 2 , where the most significant bit b 0 is a constant 1. As
such, the combination is bounded such that 1 ≤ b 0 .b 1 b 2 …b p – 1< 2 and the number is said
to be normalized. To provide increased dynamic range, this quantity is scaled by a positive
or negative power of 2 (denoted here as E). The sign bit provides a value that is negative
when s = 1 , and positive when s = 0 .
s e f
Bit position w -1 w f - 1 wf - 2 0
wf -1
w
X13276-062617
The exponent field, e , employs a biased unsigned integer representation, whose value is
given by:
we – 1
i
e = ei 2
i=0
The index, i, of each bit within the exponent field is shown in Figure 3-1.
The signed value of the exponent, E , is obtained by removing the bias, that is,
we – 1
E = e – (2 – 1) .
In reality, w f is not the wordlength of the fraction, but the fraction with the hidden bit, b 0 ,
included. This terminology has been adopted to provide commonality with that used to
describe fixed-point parameters (as employed by Xilinx® System Generator™ for DSP).
Special Values
Several values for s , e and f have been reserved for representing special numbers, such
as Not a Number (NaN), Infinity ( ∞ ), Zero (0), and denormalized numbers (see
Denormalized Numbers for an explanation of the latter). These special values are
summarized in Table 3-1.
In Table 3-1 the sign bit is undefined when a result is a NaN. The core generates NaNs with
the sign bit set to 0 (that is, positive). Also, infinity and zero are signed. Where possible, the
sign is handled in the same way as finite non-zero numbers. For example, – 0 + ( – 0 ) = – 0 ,
– 0 + 0 = 0 and – ∞ + ( – ∞ ) = – ∞ . A meaningless operation such as – ∞ + ∞ raises an invalid
operation exception and produces a NaN as a result.
s integer fraction
X13277-062617
v = – ( b w – 1 ) 2 w – 1 – wf + b w – 2 …b w .b w …b 1 b 0
f f–1
w–2
w – 1 – wf i – wf
= – ( bw – 1 ) 2 + 2 bi
i=0
For example, a 32-bit signed integer representation is obtained when a total width of 32
and a fraction width of 0 are specified. Round to Nearest is employed within the conversion
operations. To provide for the sign bit, the width of the integer field must be at least 1,
requiring that the fractional width be no larger than w – 1.
The fixed-to-float operator also has the option to perform 32-bit and 64-bit signed and
unsigned integer conversions to convert standard software integer data formats to floating
point.
• Input MSB – The MSB of the largest number that can be accepted.
• LSB – The LSB of the smallest number that can be accepted. It is also the LSB of the
accumulated result.
• MSB – The MSB of the largest result. It can be up to 54 bits greater than the Input MSB.
These values can be set to fully support the chosen IEEE-754 format, as shown in Table 3-2,
allowing the accumulator to process any floating-point number and accumulate without
introducing any round-off error. For example, to fully accommodate Single Precision, the
Input MSB should be set to 127 and the LSB set to -149.
Table 3-2: MSB and LSB of the Largest and Smallest IEEE-754 Floating-Point Numbers
Format MSB LSB
Single 2 127 2 -149
Double 2 1023 2 -1074
Custom 2 (exponent_width-1)-1 2 (1-MSB)-(fractional_width-1)
Resource usage can be reduced if these parameters are set to match the bounds on the
dataset that is used with the accumulator. For example, if the largest value that will be
accumulated is 100,000 then the MSB can be set to 17, substantially reducing the width of
the accumulator.
The LSB controls the accuracy of the accumulator. Input values with an LSB smaller than the
LSB of the accumulator are truncated (Round Towards Zero) introducing a maximum error of
2LSB-1 per accumulation. In the worst case, the lower log2(n) bits of the accumulator are
incorrect after n such accumulations. If accuracy to 2x is required after n accumulations then
the LSB needs to be set to x – log 2( N ) . For example, if accuracy to 2 -16 is required after
1000 accumulations, the LSB needs to be set to – 16 – log 2( 1000 ) = – 26 .
The MSB of the accumulator sets the maximum value that can be accumulated. The set
value can be up to 54 bits greater than the Input MSB, which allows one number to be
accumulated every clock cycle for one year at 400 MHz. If the MSB is set to be greater than
the maximum value of the IEEE-754 format then the result can cause an IEEE-754 overflow
unless sufficient subtractions occur to bring it back into range (this is for a positive
accumulated value. For a negative accumulated value, sufficient additions need to occur.)
Denormalized Numbers
The accumulator is consistent with the other operators in its handling of denormalized
values. Denormalized numbers seen on the input are flushed to zero. Denormalized
numbers on the output are flushed to zero and the Underflow flag is set. However,
denormalized numbers generated in the accumulator are retained within the accumulator
to maintain accuracy.
Exceptions
The accumulator handles exceptions in order shown in Table 3-3. All exceptions except for
OVERFLOW and UNDERFLOW are unrecoverable.
Note: OVERFLOW and UNDERFLOW represent the state of the accumulated value after it has been
converted to a floating-point number. Following operations might bring the accumulator back into a
valid range so these exceptions are handled on a per-output basis. All other exceptions represent the
state of the accumulator itself and recovery is only possible by ending the accumulation.
After an unrecoverable exception occurs, the output value and flags remain set until a new
accumulation is started. The output value and flags can subsequently change if an
exception above it in the table occurs.
Example:
° The accumulator now outputs + ∞ with no flags until a new accumulation starts,
unless a higher priority exception occurs.
° From this point on OVERFLOW and UNDERFLOW are impossible, but any of the
exceptions above it in the table can still occur.
• Some time later, but within the same block, a - ∞ summand is seen on the A channel.
° The output value now changes to NaN and INVALID_OP is set as both + ∞ and - ∞
have been accumulated.
• Some time later, but within the same block, a NaN summand is seen on the A channel.
• It is the first summand after aresetn has been asserted and released.
• It is the first summand after s_axis_a_tlast has been asserted on a valid AXI
transfer.
When a new accumulation starts, the exceptions are cleared, the accumulator register is set
to zero, and the new summand is combined (added or subtracted) with zero.
Accumulator Primitive
The Accumulator Primitive operation is an alternative accumulator operation. The
Accumulator Primitive can be considered as an Add/Subtract operator with the result fed
back such that the output P = P +/- A. Due to the difference in internal precision, this
implementation can yield different results to the Accumulator operator and so is considered
to be a separate operator rather than as an alternative use of resources.
Clocking
The Floating-Point Operator core uses a single clock, called aclk. All input and output
interfaces and internal state are subject to this single clock.
Resets
The Floating-Point Operator core uses a single, optional, reset input called aresetn. This
signal is active-Low and must be asserted for a minimum of two clock cycles to ensure
correct operation. aresetn is a global synchronous reset which resets all control states in
the core; all data in transit through the core is lost when aresetn is asserted.
Protocol Description
AXI4-Stream Considerations
The conversion to AXI4-Stream interfaces brings standardization and enhances
interoperability of Xilinx IP LogiCORE™ solutions. Other than general control signals such as
aclk, aclken and aresetn, all inputs and outputs to and from the Floating-Point
Operator core are conveyed using AXI4-Stream channels. A channel consists of TVALID and
TDATA always, plus several optional ports and fields. In the Floating-Point Operator, the
optional ports supported are TREADY, TLAST and TUSER. Together, TVALID and TREADY
perform a handshake to transfer a message, where the payload is TDATA, TUSER and TLAST.
The Floating-Point Operator operates on the operands contained in the TDATA fields and
outputs the result in the TDATA field of the output channel. The Floating-Point Operator
does not use TUSER and TLAST inputs as such, but the core provides the facility to convey
these fields with the same latency as for TDATA. This facility is expected to ease use of the
Floating-Point Operator in a system. For example, the Floating-Point Operator might be
operating on streaming packetized data. In this example, the core could be configured to
pass the TLAST of the packetized data channel, thus saving the system designer the effort
of constructing a bypass path for this information. For further details on AXI4-Stream
interfaces see [Ref 15] and [Ref 16].
Note: The accumulator does use TLAST as an input. For more information, see TLAST in the
Accumulator and Accumulator Primitive Operators.
Basic Handshake
Figure 3-3 shows the transfer of data in an AXI4-Stream channel. TVALID is driven by the
source (master) side of the channel and TREADY is driven by the receiver (slave). TVALID
indicates that the value in the payload fields (TDATA, TUSER and TLAST) is valid. TREADY
indicates that the slave is ready to receive data. When both TVALID and TREADY are TRUE in
a cycle, a transfer occurs. The master and slave set TVALID and TREADY respectively for the
next transfer appropriately.
ACLK
TVALID
TREADY
TDATA D1 D2 D3 D4
TLAST L1 L2 L3 L4
TUSER U1 U2 U3 U4
Non-Blocking Mode
The term Non-Blocking means that lack of data on one input channel does not block the
execution of an operation if data is received on another input channel. The full flow control
of AXI4-Stream is not always required. Blocking or Non-Blocking behavior is selected using
the Flow Control parameter or Vivado® Integrated Design Environment field. The core
supports a Non-Blocking mode in which the AXI4-Stream channels do not have TREADY,
that is, they do not support back pressure. The choice of Blocking or Non-Blocking applies
to the whole core, not each channel individually. Channels still have the non-optional
TVALID signal, which is analogous to the New Data (ND) signal on many cores prior to the
adoption of AXI4-Stream interfaces. Without the facility to block dataflow, the internal
implementation is much simplified, so fewer resources are required for this mode.
RECOMMENDED: This mode is recommended when moving to this core version from a pre-AXI4-Stream
core with minimal change.
When all of the present input channels receive an active TVALID, an operation is validated
and the output TVALID (suitably delayed by the latency of the core) is asserted to qualify
the result. Operations occur on every enabled clock cycle and data is presented on the
output channel payload fields regardless of TVALID. This is to allow a minimal migration
from previous core versions. Figure 3-4 shows the Non-Blocking behavior for a case of an
adder with latency of one cycle.
IMPORTANT: For performance, aresetn is registered internally, which delays its action by a clock
cycle. The effect of this is that any transaction input in the cycle following the de-assertion of aresetn
is reset by the action of aresetn, resulting in an output data value of zero.
m_axis_result_tvalid is also inactive for this cycle.
aclk
s_axis_a_tvalid
s_axis_a_tdata A1 A2 A3 A4 A5 A6 A7 A8
s_axis_b_tvalid
s_axis_b_tdata B1 B2 B3 B4 B5 B6 B7 B8
m_axis_result_tvalid
Blocking Mode
The term Blocking means that operation execution does not occur until fresh data is
available on all input channels. The full flow control of AXI4-Stream aids system design
because the flow of data is self-regulating. Data loss is prevented by the presence of back
pressure (TREADY), so that data is only propagated when the downstream datapath is ready
to process the data.
The Floating-Point Operator has one, two or three input channels and one output channel.
When all input channels have validated data available, an operation occurs and the result
becomes available on the output. If the output is prevented from off-loading data because
TREADY is low then data accumulates in the output buffer internal to the core. When this
output buffer is nearly full the core stops further operations. This prevents the input buffers
from off-loading data for new operations so the input buffers fill as new data is input. When
the input buffers fill, their respective TREADYs are deasserted to prevent further input. This
is the normal action of back pressure.
The inputs are tied in the sense that each must receive validated data before an operation
is prompted. Therefore, there is an additional blocking mechanism, where at least one input
channel does not receive validated data while others do. In this case, the validated data is
stored in the input buffer of the channel.
After a few cycles of this scenario, the buffer of the channel receiving data fills and TREADY
for that channel is deasserted until the starved channel receives some data. Figure 3-5
shows both blocking behavior and back pressure for the case of an adder. The first data on
channel A is paired with the first data on channel B, the second with the second and so on.
This demonstrates the ‘blocking’ concept. The diagram further shows how data output is
delayed not only by latency, but also by the handshake signal m_axis_result_tready.
This is ‘back pressure’. Sustained back pressure on the output along with data availability on
the inputs eventually leads to a saturation of the core buffers, leading the core to signal that
it can no longer accept further input by deasserting the input channel TREADY signals. The
minimum latency in this example is 2 cycles, but it should be noted that in Blocking
operation latency is not a useful concept. Instead, as the diagram shows, the important idea
is that each channel acts as a queue, ensuring that the first, second, third data samples on
each channel are paired with the corresponding samples on the other channels for each
operation.
Note: The core buffers have a greater capacity than implied by the diagram.
X-Ref Target - Figure 3-5
aclk
s_axis_a_tvalid
s_axis_a_tready
s_axis_a_tdata A1 A2 A3 A4 A5 A6 A7
s_axis_b_tvalid
s_axis_b_tready
s_axis_b_tdata B1 B2 B3 B4 B5 B6 B7 B8
m_axis_result_tvalid
m_axis_result_tready
TDATA Packing
Fields within an AXI4-Stream interface are not given arbitrary names. Normally, information
pertinent to the application is carried in the TDATA field. To ease interoperability with
byte-oriented protocols, each subfield within TDATA which could be used independently is
first extended, if necessary, to fit a bit field which is a multiple of 8 bits. For example, say the
Floating-Point Operator is configured to have an A operand with a custom precision of 11
bits (5 exponent and 6 mantissa bits). The operand would occupy bits (10 : 0). Bits (15 : 11)
would be ignored. The bits added by byte orientation are ignored by the core and do not
result in additional resource use.
Input channels A, B, and C carry data for use in calculations in their TDATA fields. See
Figure 3-6.
X-Ref Target - Figure 3-6
A, B or C operand
A_Width
TDATA (MSB : 0)
X13147
Figure 3-7 illustrates how the previous example of a custom precision input with 11 bits
maps to the TDATA channel.
X-Ref Target - Figure 3-7
Exponent
Mantissa
Ignored
Sign
15:11 10 9:6 5:0
Figure 3-7: Custom Precision Input (11 bits) Mapped to TDATA Channel
TDATA Structure for OPERATION Channel
The OPERATION channel exists only when add and subtract operations are selected
together, or when a programmable comparator is selected. The binary encoded operation
code, as specified in Table 2-2, are 6 bits in length. However, due to the byte-oriented
nature of TDATA, this means that TDATA has a width of 8 bits.
X-Ref Target - Figure 3-8
OPERATION operand
6 bits
TDATA (7 : 0)
TLAST in All Operators Apart from the Accumulator and Accumulator Primitive
Operators
TLAST in AXI4-Stream is used to denote the last transfer of a block of data. The
Floating-Point Operator core operates on a per-sample basis where each operation is
independent of any other before or after. Because of this, there is no need for TLAST on a
Floating-Point Operator core.
The TLAST signal is supported on each channel purely as an optional aid to system design
for the scenario in which the data stream being passed through the Floating-Point Operator
core does indeed have some packetization, but which is not relevant to the core operation.
The facility to pass TLAST removes the burden of matching latency to the TDATA path, which
can be variable, through the Floating-Point Operator core.
TLAST is used in the accumulator to signal the last sample in a block of data. The next
sample received after the one with TLAST asserted is loaded into the accumulator to start a
fresh accumulation.
On the result channel, TLAST is used to signal the last result in a block of data. The result
with TLAST asserted represents the final accumulation of all of the data in the block.
TUSER
TUSER is for ancillary information that qualifies or augments the primary data in TDATA. The
TUSER signal is supported on each channel purely as an optional aid to system design for
the scenario in which the data stream being passed through the Floating-Point Operator
core does indeed have some ancillary field, but which is not relevant to the core operation.
The facility to pass TUSER removes the burden of matching latency to the TDATA path,
which can be variable, through the Floating-Point Operator core.
X-Ref Target - Figure 3-9
User field
User specified width
TUSER (MSB : 0)
TLAST Options
All Operators Apart from the Accumulator Operator
TLAST for each input channel is optional. When present, each input channel can be passed
through the Floating-Point Operator core. When more than one channel has TLAST enabled,
each input channel can pass a logical AND or logical OR of the TLASTs input. When no
TLASTs are present on any input channel, the output channel does not have TLAST either.
Accumulator Operator
TUSER Options
TUSER for each input channel is optional. Each has user-selectable width. These fields are
concatenated, without any byte-orientation or padding, to form the output channel TUSER
field. The TUSER field from channel A forms the least significant portion of the
concatenation, then TUSER from channel B, TUSER from channel C, and TUSER from channel
OPERATION.
For example, if channels A and OPERATION both have TUSER subfields with widths of 5 and
8 bits respectively, and no exception flag signals (for example, underflow) are selected, the
output TUSER is a suitably delayed concatenation of A and OPERATION TUSER fields, 13 bits
wide, with A in the least significant 5 bit positions (4 downto 0).
The internal structure of the RESULT channel TDATA subfield depends on the operation
performed by the core.
For numerical operations (for example, add, multiply) TDATA contains the numerical result
of the operation and is a single floating-point or fixed-point number. The result width is
sign-extended to a byte boundary if necessary. This is shown in Figure 3-10.
For Comparator operations, the result is either a 4-bit field (Condition Code) or a single bit
indicating TRUE or FALSE. In both cases, the result is zero-padded to a byte boundary, as
shown in Figure 3-11.
TUSER Subfield
The TUSER subfield is present if any of the input channels have an (optional) TUSER
subfield, or if any of the exception flags (underflow, overflow, invalid operation, divide by
zero, Accumulator Input Overflow and Accumulator Overflow) have been selected. The
formatting of the TUSER fields is shown in Figure 3-12.
If any field of TUSER is not present, fields in more significant bit positions move down to fill
the space. For example, if the overflow exception flag is selected, but the underflow
exception flag is not, the overflow exception flag result moves to the least-significant bit
position in the TUSER subfield.
No byte alignment is performed on TUSER fields. All fields present are immediately
adjacent to one another with no padding between them or at the most significant bit.
X-Ref Target - Figure 3-10
Result
Result width
TDATA (MSB : 0)
Result
1 bit or 4 bits
TDATA (7: 0)
INVALID OPERATION
ACCUMULATOR INPUT
DIVIDE BY ZERO
OPERATION
ACCUMULATOR
C channel B channel A channel
(1 bit, optional)
(1 bit, optional)
(1 bit, optional)
(1 bit, optional)
UNDERFLOW
(1 bit, optional)
(1 bit, optional)
OVERFLOW
OVERFLOIW
OVERFLOIW
channel
User field User field User field
User field
User specified User specified User specified User specified
width, optional width, optional width, optional width, optional
• Vivado Design Suite User Guide: Designing IP Subsystems using IP Integrator (UG994)
[Ref 8]
• Vivado Design Suite User Guide: Designing with IP (UG896) [Ref 6]
• Vivado Design Suite User Guide: Getting Started (UG910) [Ref 7]
• Vivado Design Suite User Guide: Logic Simulation (UG900) [Ref 10]
If you are customizing and generating the core in the Vivado IP Integrator, see the Vivado
Design Suite User Guide: Designing IP Subsystems using IP Integrator (UG994) [Ref 8] for
detailed information. IP Integrator might auto-compute certain configuration values when
validating or generating the design. To check whether the values change, see the
description of the parameter in this chapter. To view the parameter value, run the
validate_bd_design command in the Tcl console.
All fields are visible in the IP Integrator. These fields are set automatically:
• A Precision Type
• Exponent Width
• Fraction Width
You can customize the IP for use in your design by specifying values for the various
parameters associated with the IP core using the following steps:
For details, see the Vivado Design Suite User Guide: Designing with IP (UG896) [Ref 6] and
the Vivado Design Suite User Guide: Getting Started (UG910) [Ref 7].
If you are customizing and generating the core in the Vivado IP integrator, see Vivado
Design Suite User Guide: Designing IP Subsystems Using IP Integrator (UG994) [Ref 8] for
detailed information. Vivado Integrated Design Environment (IDE) might auto-compute
certain configuration values when validating or generating the design, as noted in this
section. You can view the parameter value after successful completion of the
validate_bd_design command.
The Floating-Point Operator core provides several tabs with fields to set the parameter
values for the particular instantiation required. This section provides a description of each
field.
• Core operation
• Wordlength
• Implementation optimizations, such as use of slices
• Optional pins
Component Name
The component name is used as the base name of the output files generated for the core.
Names must start with a letter and be composed using the following characters: a to z, 0 to
9, and “_”.
• Add/Subtract
• Accumulators
• Multiply
• Fused Multiply-Add
• Divide
• Reciprocal
• Square-root
When Float-to-float conversion is selected, and exponent and fraction widths of the input
and result are the same, the core provides a means to condition numbers, that is, convert
denormalized numbers to zero, and signaling NaNs to quiet NaNs.
When targeting a Versal ACAP device, unfused multiply-add and unfused multiply-acc
operators using the DSP Engines are available. The Multiply and Add/Subtract operators
may also target the native floating-point support of the DSP Engines.
The parameters in these tabs define the number of bits used to represent quantities. The
type of the operands and results depend on the operation requested. For fixed-point
conversion operations, either the operand or result is fixed-point. For all other operations,
the output is specified as a floating-point type.
There are also some further limits for specific cases which are enforced by the Vivado IDE:
• The exponent width (that is, Total Width-Fraction Width) should be chosen to support
normalization of the fractional part. This can be calculated using:
For example, a 24-bit fractional part requires an exponent of at least 6 bits (for example,
{ceil [log2 (27)]+1}).
• For conversion operations, the exponent width of the floating-point input or output is
also constrained by the Total Width of the fixed-point input or output to be a minimum
of:
A summary of the width limits imposed by exponent width is provided in Table 4-2.
• Accumulator MSB
• Accumulator LSB
• Input MSB
Optimizations Tab
Architecture Optimizations
For multiplication (double precision), addition/subtraction and Accumulator operations, it
is possible to specify a latency optimized architecture, or speed optimized architecture. The
latency optimized architecture offers reduced latency at the expense of increased resources.
Implementation Optimizations
• DSP Slice Usage allows the level of slice multiplier use to be specified.
• Block Memory Usage allows the level of Block Memory use to be specified.
A single block memory is also used for the half precision square root, reciprocal and
reciprocal square root implementations.
• Flow Control
° Blocking – When the core is configured to a Blocking interface, it waits for valid
data to be available on all input channels before performing a calculation. Back
pressure from downstream modules is possible.
° Resources – This option reduces the logic resources required by the AXI4-Stream
interface, at the expense of maximum achievable clock frequency.
° Unchecking this option removes TREADY signals from the RESULT channel,
disabling the ability for downstream modules to signal back pressure to the
Floating-Point Operator core and upstream modules.
supply. For the previous example, Xilinx recommends using latency=12 if the system clock
is > 0.5 * value in the resource and performance section on the Xilinx webpage for the IP
core. Other latency values of use are 6, 3, 2 and 1, though minimum may apply due to FIFOs
and feedback stages. Therefore, there is not much use in setting latency to 11 for this
reason.
Control Signals
Pins for the following global signals are optional:
• A Channel Options
° Enables TLAST and TUSER input fields for the A operand channel, and allows
definition of the TUSER field width.
• B Channel Options
° Enables TLAST and TUSER input fields for the B operand channel (when present),
and allows definition of the TUSER field width.
• C Channel Options
° Enables TLAST and TUSER input fields for the C operand channel (when present),
and allows definition of the TUSER field width.
• OPERATION Channel Options
° Enables TLAST and TUSER input fields for the OPERATION channel (when present),
and allows definition of the TUSER field width.
• Output TLAST Behavior
° When at least one TLAST input is present on the core, this option defines how the
m_axis_result_tlast signal should be generated. Options are available to pass
any of the input TLAST signals without modification, or to logically OR or AND all
input TLASTs.
User Parameters
Table 4-4 shows the relationship between the fields in the Vivado IDE and the User
Parameters (which can be viewed in the Tcl Console).
Notes:
1. Parameter values are listed in the table where the Vivado IDE parameter value differs from the user parameter value.
Such values are shown in this table as indented below the associated parameter.
• AddSub
• Accumulator
• Mult
• Fused Multiply-Add
• CMult (Constant Multiplier)
• Divide
• Reciprocal
• SquareRoot
• Reciprocal SquareRoot
• Absolute
• Logarithm
• Exponential
• Relational (provides compare operations)
• Convert (provides fixed to float, float to fixed, float to float)
• Accumulator Primitive
• Unfused Multiply-Add
• Unfused Multiply-Accumulate
See the System Generator for DSP User Guide (UG640) [Ref 9] for more information.
Output Generation
For details, see the Vivado Design Suite User Guide: Designing with IP (UG896) [Ref 6].
Required Constraints
This section is not applicable for this IP core.
Clock Frequencies
This section is not applicable for this IP core.
Clock Management
This section is not applicable for this IP core.
Clock Placement
This section is not applicable for this IP core.
Banking
This section is not applicable for this IP core.
Transceiver Placement
This section is not applicable for this IP core.
Simulation
For comprehensive information about Vivado simulation components, as well as
information about using supported third party tools, see the Vivado Design Suite User
Guide: Logic Simulation (UG900) [Ref 10].
C Model
The Xilinx® LogiCORE ™ IP Floating-Point Operator core bit accurate C model is a
self-contained, linkable, shared library that models the functionality of this core with finite
precision arithmetic. This model provides a bit accurate representation of the various
modes of the Floating-Point Operator v7.1 core, and it is suitable for inclusion in a larger
framework for system-level simulation or core-specific verification.
The C model is an optional output of the Vivado® Design Suite. For information about
generating IP source outputs, see Vivado Design Suite User Guide: Using the Vivado IDE
(UG893) [Ref 12].
Features
• Bit accurate with Floating-Point Operator core
• Available for 64-bit Linux and Windows platforms
• Supports all features of the Floating-Point Operator core
• Designed for integration into a larger system model
• Example C code showing how to use the C model functions
Overview
This product guide provides information about the Xilinx LogiCORE IP Floating-Point
Operator v7.1 bit accurate C model for 64-bit Linux and Windows platforms.
The model consists of a set of C functions that reside in a shared library. Example C code is
provided to demonstrate how these functions form the interface to the C model. Full details
of this interface are given in C Model Interface.
The model is bit accurate but not cycle-accurate; it performs exactly the same operations as
the core. However, it does not model the core latency or its interface signals.
Installation
Linux
• Unpack the contents of the ZIP file.
• Ensure that the directory where the
libIp_floating_point_v7_1_bitacc_cmodel.so, libgmp.so.11 and
libmpfr.so.4 files reside is included in the path of the environment variable
LD_LIBRARY_PATH.
Windows
• Unpack the contents of the ZIP file.
• Ensure that the directory where the
libIp_floating_point_v7_1_bitacc_cmodel.dll, libgmp.dll and
libmpfr.dll files reside is
a. included in the path of the environment variable PATH or
b. the directory in which the executable that calls the C model is run.
C Model Interface
The Floating-Point Operator C model has a C function based Application Programming
Interface (API), which is very similar to the APIs of other floating-point arithmetic libraries
MPIR (Multiple Precision Integers and Rationals) and MPFR (GNU Multiple Precision
Floating-point Reliable library). The C model uses these libraries internally and provides
functions to convert between their data types.
Note: MPIR [Ref 3] and MPFR [Ref 4] are free, open source software libraries, distributed under the
GNU Lesser General Public License. A compiled version of each library is provided with the C model.
MPIR is a compatible alternative to GMP (GNU Multiple Precision Arithmetic) [Ref 2] that provides
greater support for Windows platforms. MPIR and GMP can be used interchangeably.
The Application Programming Interface (API) of the C model is defined in the header file
floating_point_v7_1_bitacc_cmodel.h. The interface consists of data structures
and functions as described in the following sections.
Data Types
The C types defined for the Floating-Point Operator C model are shown in Table 5-3.
xip_fpo_prec_t and xip_fpo_exp_t are of type long for compatibility with MPFR, not
because they need a greater numerical range than provided by int.
The Floating-Point Operator C model functions use xip_fpo_t and xip_fpo_fix_t for
input and output variables. Users should use these types for all custom precision
floating-point and fixed-point variables. Defining this type as a one-element array of the
underlying struct means that when a user declares a variable of this type, the memory for
the struct members is automatically allocated, and you can pass the variable as-is to
functions with no need to add a * to pass a pointer, and it is automatically passed by
reference. This is the same method as used by MPIR [Ref 3] and MPFR [Ref 4].
xip_fpo_t is an IEEE-754 compatible floating-point type, except that signaling NaNs and
denormalized numbers are not supported. If a signaling NaN is stored in an xip_fpo_t
variable, the value becomes a quiet NaN. Similarly, denormalized numbers are converted to
zero (with an underflow exception, if appropriate).
The C model API also provides versions of its operation functions for single and double
precision, using standard C data types float and double respectively. This provides an
easy use model for applications that do not require custom precision.
Because there is no standard C data type to model half precision (binary16) data, the
custom precision variant of each C model function should be used with appropriately
defined xip_fpo_t variables to describe a half precision datapath.
Functions
There are several C model functions accessible to you.
Information Functions
The Floating-Point Operator C model information functions are shown in Table 5-4.
Initialization Functions
The Floating-Point Operator C model initialization functions are shown in Table 5-5. Most
functions have variants to handle floating-point and fixed-point variables.
xip_fpo_t x, y, z;
xip_fpo_init2 (x, 11, 53); // double precision
xip_fpo_inits2 (7, 17, y, z, (xip_fpo_ptr) 0); // custom precision
// perform operations
xip_fpo_set_prec (8, 24, y); // change to single precision
// more operations
xip_fpo_clears (x, y, z, (xip_fpo_ptr) 0);
Assignment Functions
The Floating-Point Operator C model assignment functions are shown in Table 5-6. Most
functions have variants to handle both floating-point and fixed-point variables. Functions
are provided for assigning Floating-Point Operator C model variables from MPIR and MPFR
variables for ease of use alongside these existing libraries.
Notes:
1. Any exceptions that occur are signaled in the return value.
When assigning to a fixed-point variable, if overflow occurs, the result is saturated and the return value is the
largest representable fixed-point number of the correct sign. Converting a NaN returns the most negative
representable fixed-point number and the invalid operation exception is signaled in the return value.
The base is a value between 2 and 62 or zero. The string is a representation of numeric data
to be read and stored in the floating-point variable. The whole string must represent a valid
floating-point number.
The form of numeric data is a non-empty sequence of significand digits with an optional
decimal point, and an optional exponent consisting of an exponent prefix followed by an
optional sign and a non-empty sequence of decimal digits. A significand digit is either a
decimal digit or a Latin letter (62 possible characters), with A = 10, B = 11, ..., Z = 35; case
is ignored in bases less or equal to 36, in bases larger than 36, a = 36, b = 37, ..., z = 61. The
value of a significant digit must be strictly less than the base. The decimal point can be
either the one defined by the current locale or the period (the first one is accepted for
consistency with the C standard and the practice, the second one is accepted to allow the
programmer to provide numbers from strings in a way that does not depend on the current
locale). The exponent prefix can be e or E for bases up to 10, or @ in any base; it indicates
a multiplication by a power of the base. In bases 2 and 16, the exponent prefix can also be
p or P, in which case the exponent, called binary exponent, indicates a multiplication by a
power of 2 instead of the base (there is a difference only for base 16); in base 16 for example
1p2 represents 4 whereas 1@2 represents 256.
If the argument base is 0, then the base is automatically detected as follows. If the
significand starts with 0b or 0B, base 2 is assumed. If the significand starts with 0x or 0X,
base 16 is assumed. Otherwise base 10 is assumed.
Note: The exponent (if present) must contain at least a digit. Otherwise, the possible exponent
prefix and sign are not part of the number (which ends with the significand). Similarly, if 0b, 0B, 0x
or 0X is not followed by a binary/hexadecimal digit, then the subject sequence stops at the character
0, thus 0 is read.
Note: There is an optional sign for all data, even NaN. For example, -@nAn@(This_Is_Not_17) is
a valid representation for NaN in base 17.
If the whole string cannot be parsed into a floating-point or fixed-point number, then an
invalid operation exception is signaled. In this case, rop might have changed. Overflow or
underflow can occur if the string is parsed to a floating-point or fixed-point number that is
too large or too small to represent in the floating-point or fixed-point precision of the
variable.
Conversion Functions
The Floating-Point Operator C model conversion functions are shown in Table 5-7. Most
functions have variants to handle both floating-point and fixed-point variables.
Functions that convert to a standard C data type return the converted result as that data
type. Any exceptions that occur are ignored. Functions that convert to GMP or MPFR data
types place the result in the first argument and return exception flags, as with most
Floating-Point Operator C model functions.
xip_fpo_get_str
The function xip_fpo_get_str has the same usage as the MPFR function
mpfr_get_str. n_digits is either zero or the number of significant digits output in the
string; in the latter case, n_digits must be greater or equal to 2. The base can vary from 2 to
62. If the input number is an ordinary number, the exponent is written through the pointer
exp (for input 0, the exponent is set to 0).
The generated string is in the base specified by base. Each string character is either a
decimal digit or a Latin letter (62 possible characters). For base in the range 2 to 36, decimal
digits and lowercase letters are used, with a = 10, b = 11, … z = 35. For base in the range 37
to 62, digits, uppercase, and lowercase letters are used, with A = 10, B = 11, ..., Z = 35, a =
36, b = 37, ..., z = 61.
The generated string is a fraction, with an implicit radix point immediately to the left of the
first digit. For example, the number –3.1416 would be returned as "–31416" in the string
and 1 written at exp. The value is rounded to provide n_digits of output, using round to
nearest even: if op is exactly in the middle of two consecutive possible outputs, the one with
an even significand is chosen, where both significands are considered with the exponent of
op. For an odd base, this might not correspond to an even last digit: for example with 2
digits in base 7, (14) and a half is rounded to (15) which is 12 in decimal, (16) and a half is
rounded to (20) which is 14 in decimal, and (26) and a half is rounded to (26) which is 20 in
decimal.
If n_digits is zero, the number of digits of the significand is chosen large enough so that
re-reading the printed value with the same precision recovers the original value of op. More
precisely, in most cases, the chosen precision of str is the minimal precision m depending
only on p = PREC(op) and b that satisfies the above property, that is,
m = 1 + ceil(p × log(2)/log(b)), with p replaced by p – 1 if b is a power of 2.
If str is a null pointer, space for the significand is allocated using the GMP/MPIR current
allocation function which is malloc() by default, and a pointer to the string is returned. To
free the memory used by the returned string, you must use xip_fpo_free_str.
If str is not a null pointer, it should point to a block of storage large enough for the
significand, that is, at least max(n_digits + 2, 7) if n_digits > 0, or xip_fpo_sizeinbase (op,
base) + 2 otherwise. The extra two bytes are for a possible minus sign, and for the
terminating null character, and the value 7 accounts for -@Inf@ plus the terminating null
character.
A pointer to the string is returned, unless there is an error, in which case a null pointer is
returned.
xip_fpo_fix_get_str
The function xip_fpo_fix_get_str has the same usage as the GMP/MPIR function
mpz_get_str. The base can vary from 2 to 62.
The generated string is in the base specified by base. Each string character is either a
decimal digit or a Latin letter (62 possible characters). For base in the range 2 to 36, decimal
digits and lowercase letters are used, with a = 10, b = 11, … z = 35. For base in the range 37
to 62, digits, uppercase, and lowercase letters are used, with A = 10, B = 11, ..., Z = 35, a =
36, b = 37, ..., z = 61.
The generated string is either an integer value with no radix point, or a fraction with an
explicit radix point. All significant digits are returned, but no leading or trailing zeros are
returned. No rounding is carried out.
If str is a null pointer, space for the significand is allocated using the current allocation
function, and a pointer to the string is returned. To free the memory used by the returned
string, you must use xip_fpo_fix_free_str.
If str is not a null pointer, it should point to a block of storage large enough for the result,
that being xip_fpo_fix_sizeinbase (op, base) + 2. The extra two bytes are for a
possible minus sign, and the terminating null character.
Operation Functions
The Floating-Point Operator C model functions that model operations of the core are
shown in Table 5-8. In addition to functions using xip_fpo_t and xip_fpo_fix_t type
arguments to provide custom precision, alternative versions of functions using standard C
data types float and double are also provided to make it easy for customers who do not
need custom precision. For fixed to float and float to fixed functions, float and double to
and from int are provided. For float to float functions, all combinations of float and
double are provided: where these data types are the same, the function provides a means
to condition numbers (convert signaling NaNs to quiet NaNs, convert denormalized
numbers to zero).
Notes:
1. Only supported for xip_fpo_t operands with IEEE-754 half precision (exponent=5, mantissa=11) or IEEE-754 single
precision (exponent=8, mantissa=24) or double precision (exponent=11, mantissa=53).
For all functions, the result is guaranteed to match exactly the numerical output of the
Floating-Point Operator v7.1 core, and the returned exceptions are guaranteed to match
exactly the signaled exceptions of the Floating-Point Operator v7.1 core, for identical
inputs.
No direct C function is provided for Unfused Multiply Add, Unfused Multiply accumulator
and Accumulator Primitive. This is because these operations are simply combinations of
existing multiply and addition operations.
When the operand and result variables do not meet constraints of the Floating-Point
Operator v7.1 core, an operation not supported exception is returned. In this case, no other
exception bits are set in the return value, and the result variable is not modified.
xip_fpo_condcode functions set the 4 least significant bits of their integer result to a
condition code, which has the encoding shown in Table 5-9. Encodings not shown are
reserved and are not returned by the functions.
For all comparison functions, the sign of zero is ignored, such that –0 = +0.
If the operand and result variable do not meet this condition, an operation not supported
exception is returned and the result variable is not modified.
Compiling
Compilation of user code requires access to the
floating_point_v7_1_bitacc_cmodel.h header file and the header files of the MPIR
and MPFR dependent libraries, gmp.h and mpfr.h. The header files should be copied to a
location where they are available to the compiler. Depending on the location chosen, the
include search path of the compiler might need to be modified.
Linking
To use the C model, the user executable must be linked against the correct libraries for the
target platform.
Note: The C model uses MPIR and MPFR libraries. It is also possible to use GMP or MPIR, and MPFR
libraries from other sources, for example, compiled from source code. For details, see Dependent
Libraries.
Linux
The executable must be linked against the following shared object libraries:
• libgmp.so.11
• libmpfr.so.4
• libIp_floating_point_v7_1_bitacc_cmodel.so
Using GCC, linking is typically achieved by adding the following command line options:
This assumes the shared object libraries are in the current directory. If this is not the case,
the -L. option should be changed to specify the library search path to use.
Using GCC, the provided example program run_bitacc_cmodel.c can be compiled and
linked using the following command:
Windows
The executable must be linked against the following dynamic link libraries:
• libgmp.dll
• libmpfr.dll
• libIp_floating_point_v7_1_bitacc_cmodel.dll
• libgmp.lib
• libmpfr.lib
• libIp_floating_point_v7_1_bitacc_cmodel.lib
Using Microsoft Visual Studio, linking is typically achieved by adding the import libraries to
the Additional Dependencies entry under the Linker section of Project Properties.
Dependent Libraries
The C model uses MPIR and MPFR libraries. They are governed by the GNU Lesser General
Public License. You can obtain source code for the MPIR and MPFR libraries from
https://www.xilinx.com/products/design-tools/guest-resources.html . Pre-compiled MPIR and
MPFR libraries are provided with the C model, using the following versions of the libraries:
• MPIR 2.6.0
• MPFR 3.1.2
Because MPIR is a compatible alternative to GMP, the GMP library can be used in place of
MPIR. It is possible to use GMP or MPIR and MPFR libraries from other sources, for example,
compiled from source code.
GMP and MPIR in particular, and MPFR to a lesser extent, contain many low level
optimizations for specific processors. The libraries provided are compiled for a generic
processor on each platform, using no optimized processor-specific code. These libraries
work on any processor, but run more slowly than libraries compiled to use optimized
processor-specific code. For the fastest performance, compile libraries from source on the
machine on which you run the executables.
Source code and compilation scripts are provided for the versions of MPIR and MPFR that
were used to compile the provided libraries. Source code and compilation scripts for any
version of the libraries can be obtained from the GMP [Ref 2], MPIR [Ref 3] and MPFR [Ref 4]
web sites. Microsoft Visual Studio project files for compiling MPFR on Windows can be
obtained from the website of Brian Gladman [Ref 5].
Note: If compiling MPIR using its configure script (for example, on Linux platforms), use the
--enable-gmpcompat option when running the configure script. This generates a libgmp.so
library and a gmp.h header file that provide full compatibility with the GMP library. This
compatibility is required by the MPFR compilation scripts.
Note: Some Windows compilers, for example Microsoft Visual Studio versions prior to 2010, do not
have full support for the C99 standard of the C programming language. The MPFR library contains
functions that use the C99 types intmax_t and uintmax_t (for example, functions with _sj and
_uj suffixes). When MPFR is compiled, it checks if these types are present, and excludes these
functions if not. The C model requires these functions in MPFR. Therefore, when compiling MPFR
using a Windows compiler without C99 support, include the provided mpfr_nt_stdint.h header
file, which defines the types intmax_t and uintmax_t. Using Microsoft Visual Studio, this header
file can be included without modifying source code by adding it to the Force Includes entry under
the Advanced sub-section of the C/C++ section of Project Properties.
Example
The run_bitacc_cmodel.c file contains example code to show basic operation of the C
model. Part of this example code is shown here. The comments assist in understanding the
code.
This code calculates e, the base of natural logarithms, in the given precision. The Taylor
Series expansion for the exponential function e x is:
2 3 n
x x x x x
e = 1 + ---- + ---- + ---- + … + ---- + …
1! 2! 3! n!
To calculate e, set x = 1:
x 1 1 1 1
e = 1 + ---- + ---- + ---- + … + ---- + …
1! 2! 3! n!
This code calculates terms iteratively until the accuracy of e no longer improves.
#include <stdio.h>
#include "floating_point_v7_1_bitacc_cmodel.h"
int main()
{
xip_fpo_exp_t exp_prec, mant_prec;
// The algorithm will work for any legal combination
// of values for exp_prec and mant_prec
exp_prec = 16;
mant_prec = 64;
printf("Using Taylor Series expansion to calculate e, the base of natural
logarithms, in %d-bit mantissa precision\n", mant_prec);
int i, done;
xip_fpo_t n, fact, one, term, e, e_old;
xip_fpo_exc_t ex;
xip_fpo_exp_t exp;
char * result = 0;
double e_d;
// 0th term
i = 0;
xip_fpo_set_ui (fact, 1);
xip_fpo_set_ui (e, 1);
// Are we done?
ex |= xip_fpo_equal (&done, e, e_old);
} while (!done);
// Free up memory
xip_fpo_clears (n, fact, one, term, e, e_old, xip_fpo_ptr) 0);
xip_fpo_free_str (result);
return 0;
}
Test Bench
This chapter contains information about the test bench provided in the Vivado® Design
Suite.
Compile the netlist and the demonstration test bench into the work library (see your
simulator documentation for more information on how to do this). Then simulate the
demonstration test bench. View the test bench signals in your simulator's waveform viewer
to see the operations of the test bench.
The demonstration test bench drives the core input signals to demonstrate the features and
modes of operation of the core. The operations performed by the demonstration test bench
are appropriate for the configuration of the generated core, and are a subset of the
following operations:
1. An initial phase where the core is initialized and no operations are performed.
2. Perform a single operation, and wait for the result.
3. Perform 100 consecutive operations with incrementing data.
4. Perform operations while demonstrating the AXI4-Stream control signals’ use and
effects.
5. If aclken is present: Demonstrate the effect of toggling aclken.
6. If aresetn is present: Demonstrate the effect of asserting aresetn.
7. Demonstrate the handling of special floating-point values (NaN, zero, infinity).
For instructions on simulating your core, see the Vivado Design Suite User Guide: Logic
Simulation (UG900) [Ref 10].
For instruction on implementing your core, see Vivado Design Suite User Guide:
Implementation (UG904) [Ref 11].
Upgrading
This appendix contains information about migrating a design from ISE® to the Vivado®
Design Suite, and for upgrading to a more recent version of the IP core. For customers
upgrading in the Vivado Design Suite, important details (where applicable) about any port
changes and other impact to user logic are included.
In the Vivado Design Suite, you can update an existing XCO or XCI file from versions 4.0, 5.0,
6.0, 6.1, 6.2 and 7.0 to Floating-Point Operator, v7.1.
IMPORTANT: For v4.0 and v5.0 the upgrade mechanism alone does not create a core compatible with
v7.1. Floating-Point Operator v7.1 has parameters additional to v4.0 and v5.0 for AXI4-Stream support.
Floating-Point Operator v7.1 is backwards compatible with v6.1, v6.2, and v7.0 both in terms
of parameters and ports. Figure A-1 shows the changes to user parameters from versions
4.0, 5.0, 6.0, 6.1, 6.2, and 7.0 to version 7.1. For clarity, user parameters with no changes are
not shown.
Parameter Changes
Table A-1: XCO/XCI Parameter Changes from v4.0, v5.0, v6.0, v6.1, v6.2, and v7.0 to v7.1(1)
Version 4.0 and 5.0 Version 7.1 Notes
C_Has_CE Has_ACLKEN Renamed only
C_Has_SCLR Has_ARESETn Renamed only. While the sense of the
aresetn signal has changed (now
active-Low), this XCO parameter
determined whether or not the pin exists
and has not changed.
C_Latency C_Latency Depending on the AXI4-Stream Flow
Control options selected (Blocking/
NonBlocking), a minimum latency greater
than previous core versions might be
imposed.
Flow_Control New as of version 6.0
Axi_Optimize_Goal New as of version 6.0
Has_RESULT_TREADY New as of version 6.0
Has_A_TLAST New as of version 6.0
Has_A_TUSER New as of version 6.0
A_TUSER_Width New as of version 6.0
Has_B_TLAST New as of version 6.0
Has_B_TUSER New as of version 6.0
B_TUSER_Width New as of version 6.0
Has_OPERATION_TLAST New as of version 6.0
Has_OPERATION_TUSER New as of version 6.0
OPERATION_TUSER_Width New as of version 6.0
RESULT_TLAST_Behv New as of version 6.0
Has_C_TLAST New as of version 6.2
Has_C_TUSER New as of version 6.2
C_TUSER_Width New as of version 6.2
C_Has_ACCUM_INPUT_OVERFLOW New as of version 6.2
C_Has_ACCUM_OVERFLOW New as of version 6.2
C_Accum_Msb New as of version 6.2
C_Accum_Lsb New as of version 6.2
C_Accum_Input_Msb New as of version 6.2
Notes:
1. Parameters in v6.0, v6.1, v6.2, v7.0, and v7.1 are unchanged except for the additions required for new operators.
Port Changes
Table A-2 details the changes to port naming, additional or deprecated ports and polarity
changes from v4.0, v5.0, v6.0, v6.1, v6.2, and v7.0 to v7.1.
Table A-2: Port Changes from v4.0, v5.0, v6.0, v6.1, v6.2, and v7.0 to v7.1(1)
Versions Version 7.1 Notes
4.0 and 5.0
CLK aclk Rename only
CE aclken Rename only
SCLR aresetn Rename and change of sense (now active-Low).
Must now be asserted for at least two clock
cycles to effect a reset.
A(N-1:0) s_axis_a_tdata (byte (N)-1:0) byte (N) is to round N up to the next multiple of
8
B(N-1:0) s_axis_b_tdata (byte (N)-1:0) byte (N) is to round N up to the next multiple of
8
OPERATION(5 : 0) s_axis_operation_tdata (7 : 0)
RESULT(R-1:0) m_axis_result_tdata (byte (R)-1:0) byte (R) is to round R up to the next multiple of
8.
OPERATION_ND Deprecated Nearest equivalents are
s_axis_<operand>_tvalid
OPERATION_RFD Deprecated Nearest equivalents are
s_axis_<operand>_tready
RDY Deprecated Nearest equivalent is m_axis_result_tvalid
UNDERFLOW Deprecated Exception signals are now subfields of
m_axis_result_tuser. See Figure 3-12 for data
OVERFLOW Deprecated
structure.
INVALID_OP Deprecated
DIVIDE_BY_ZERO Deprecated
s_axis_a_tvalid TVALID (AXI4-Stream channel handshake signal)
for each channel
s_axis_b_tvalid
s_axis_c_tvalid
s_axis_operation_tvalid
m_axis_result_tvalid
s_axis_a_tready TREADY (AXI4-Stream channel handshake
signal) for each channel.
s_axis_b_tready
s_axis_c_tready
s_axis_operation_tready
m_axis_result_tready
Table A-2: Port Changes from v4.0, v5.0, v6.0, v6.1, v6.2, and v7.0 to v7.1(1) (Cont’d)
Versions Version 7.1 Notes
4.0 and 5.0
s_axis_a_tlast TLAST (AXI4-Stream packet signal indicating the
last transfer of a data structure) for each
s_axis_b_tlast
channel. The Floating-Point Operator does not
s_axis_c_tlast use TLAST, but provides the facility to pass
TLAST with the same latency as TDATA.
s_axis_operation_tlast
m_axis_result_tlast
s_axis_a_tuser(E-1:0) TUSER (AXI4-Stream ancillary field for
application-specific information) for each
s_axis_b_tuser(F-1:0)
channel. The Floating-Point Operator does not
s_axis_c_tuser(G-1:0) use TUSER, but provides the facility to pass
TUSER with the same latency as TDATA.
s_axis_operation_tuser (H-1:0)
m_axis_result_tuser (I-1:0)
Notes:
1. Ports in v6.0, v6.1, v6.2, v7.0, and v7.1 are unchanged except for the additions required for new operators and new
precision support for existing operators.
Other Changes
No change.
Debugging
This appendix includes details about resources available on the Xilinx® Support website
and debugging tools.
Documentation
This product guide is the main document associated with the Floating-Point Operator. This
guide, along with documentation related to all products that aid in the design process, can
be found on the Xilinx Support web page or by using the Xilinx Documentation Navigator.
Download the Xilinx Documentation Navigator from the Downloads page. For more
information about this tool and the features available, open the online help after
installation.
Answer Records
Answer Records include information about commonly encountered problems, helpful
information on how to resolve these problems, and any known issues with a Xilinx product.
Answer Records are created and maintained daily ensuring that users have access to the
most accurate information available.
Answer Records for this core can be located by using the Search Support box on the main
Xilinx support web page. To maximize your search results, use proper keywords such as:
• Product name
• Tool message(s)
• Summary of the issue encountered
A filter search is available after results are returned to further target the results.
Technical Support
Xilinx provides technical support in the Xilinx Support web page for this LogiCORE™ IP
product when used as described in the product documentation. Xilinx cannot guarantee
timing, functionality, or support if you do any of the following:
• Implement the solution in devices that are not defined in the documentation.
• Customize the solution beyond that allowed in the product documentation.
• Change any section of the design labeled DO NOT MODIFY.
To contact Xilinx Technical Support, navigate to the Xilinx Support web page.
Debug Tools
There are many tools available to address Floating-Point Operator core design issues. It is
important to know which tools are useful for debugging various situations.
The Vivado logic analyzer is used with the logic debug LogiCORE IP cores, including:
See Vivado Design Suite User Guide: Programming and Debugging (UG908) [Ref 14].
C Model Reference
See Chapter 5, C Model in this guide for tips and instructions for using the provided
C-Model files to debug your design.
Simulation Debug
When the Floating-Point Operator core is configured to use Non-Blocking mode, any
transaction input in the cycle following the deassertion of aresetn is lost. For more
information, see Non-Blocking Mode in the AXI4-Stream Considerations section.
Xilinx Resources
For support resources such as Answers, Documentation, Downloads, and Forums, see Xilinx
Support.
• From the Vivado® IDE, select Help > Documentation and Tutorials.
• On Windows, select Start > All Programs > Xilinx Design Tools > DocNav.
• At the Linux command prompt, enter docnav.
Xilinx Design Hubs provide links to documentation organized by design tasks and other
topics, which you can use to learn key concepts and address frequently asked questions. To
access the Design Hubs:
• In the Xilinx Documentation Navigator, click the Design Hubs View tab.
• On the Xilinx website, see the Design Hubs page.
Note: For more information on Documentation Navigator, see the Documentation Navigator page
on the Xilinx website.
References
These documents provide supplemental material useful with this product guide:
Revision History
The following table shows the revision history for this document.