Real Divide HDL Optimized
Libraries:
Fixed-Point Designer HDL Support /
Math Operations
Description
The Real Divide HDL Optimized block outputs the result of dividing the real scalar num by the real scalar den, such that y = num/den.
Examples
Implement Hardware-Efficient Real Divide HDL Optimized
How to use the Real Divide HDL Optimized block.
Customize Output Value of Real Divide HDL Optimized Block When Denominator Is Zero
Use the divideByZero port to customize the value of the block output when division by zero occurs.
Limitations
Data type override is not supported for the Real Divide HDL Optimized block.
Ports
Input
num — Numerator
scalar | vector | matrix
Numerator, specified as a real-valued scalar, vector, or matrix. num and den must have the same dimensions.
Slope-bias representation is not supported for fixed-point data types.
Data Types: single
| double
| fixed point
den — Denominator
scalar | vector | matrix
Denominator, specified as a real-valued scalar, vector, or matrix. num and den must have the same dimensions.
Slope-bias representation is not supported for fixed-point data types.
Data Types: single
| double
| fixed point
validIn — Whether input is valid
Boolean
scalar
Whether input is valid, specified as a Boolean scalar. This control signal
indicates when the data from the num and
den input
ports are valid. When this value is 1
(true
),
the block captures the values at the input ports num and
den. When this value is 0
(false
),
the block ignores the input samples.
Data Types: Boolean
Output
y — Output computed by dividing inputs
real scalar
Output computed by dividing num by den, such that y = num/den, returned as a real scalar.
Tips
The data type at the output port y is specified by the Output datatype parameter.
Data Types: single
| double
| fixed point
divideByZero — Whether the value at output is the result of division by zero
Boolean
scalar
Since R2024b
Whether the value at the y output
port is the result of a division by zero operation, returned as a Boolean scalar. When
the value of this signal is 1
(true
), the
corresponding output value at the y port is the result of division by
zero. When the value of this signal is 0
(false
), the corresponding output value at the y port
is the result of division by a nonzero value.
See Division by Zero Behavior for a description of the default divide by zero behavior.
Dependencies
To enable this port, select the Show divide by zero port parameter.
Data Types: Boolean
validOut — Whether output data is valid
Boolean
scalar
Whether the output data is valid, returned as a Boolean scalar. When the value of
this control signal is 1
(true
), the block has
successfully computed the output at port y. When
this value is 0
(false
), the output data is not
valid.
Data Types: Boolean
Parameters
Output datatype — Data type of the output
fixdt(1,18,10)
(default) | single
| double
| fixdt(1,16,0)
| <data type expression>
Data type of the output y,
specified as fixdt(1,18,10)
, single
,
double
, fixdt(1,16,0)
, or as a user-specified
data type expression. The type can be specified directly or expressed as a data type
object, such as Simulink.NumericType
.
In R2024b: Unsigned data types are supported for this parameter.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
To get the block parameter value
programmatically, use the get_param
function.
Parameter: | OutputType |
Values: | fixdt(1,18,10) (default) | single | double | fixdt(1,16,0) | <data type expression> |
Data Types: | char | string |
Example: set_param(gcb,"OutputType","fixdt(1,16,0)")
Show divide by zero port — Whether to show the divideByZero
port
off
(default) | on
Since R2024b
Select this parameter to show the divideByZero port.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
To get the block parameter value
programmatically, use the get_param
function.
Parameter: | dbzPort |
Values: | 0 (false) (default) | 1 (true) |
Data Types: | logical |
Example: set_param(gcb,"dbzPort",1)
Automatically select CORDIC maximum shift value based on input word length — Automatically select CORDIC maximum shift value based on input word length
on
(default) | off
Since R2024b
Automatically select the CORDIC maximum shift value based on input word length. When
this parameter is selected, the default CORDIC maximumShiftValue
is
equal to wl - 1
, where wl = max(num.WordLength +
~issigned(num), den.WordLength + ~issigned(den))
.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
To get the block parameter value
programmatically, use the get_param
function.
Parameter: | autoMaximumShiftVal |
Values: | on (default) | off |
Data Types: | char | string |
Example: set_param(gcb,"autoMaximumShiftVal","off")
CORDIC maximum shift value — Maximum shift value of hyperbolic vectoring CORDIC
wl - 1
(default) | 10
| positive integer-valued scalar
Since R2024b
Maximum shift value of hyperbolic vectoring CORDIC, specified as a positive
integer-valued scalar. The default value for this parameter is wl -
1
, where wl = max(num.WordLength + ~issigned(num), den.WordLength +
~issigned(den))
.
Dependencies
To enable this parameter, clear the Automatically select CORDIC maximum shift value based on input word length parameter.
Tips
See Customizable Pipelining for more information.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
To get the block parameter value
programmatically, use the get_param
function.
Parameter: | maximumShiftValue |
Values: | 10 (default) | positive integer-valued scalar |
Data Types: | char | string |
Example: set_param(gcb,"maximumShiftValue","10")
Number of iterations per pipeline register — Number of CORDIC iterations to perform per pipeline stage
1
(default) | positive integer-valued scalar
Since R2024b
Number of CORDIC iterations to perform per pipeline stage, specified as a positive integer-valued scalar.
See Customizable Pipelining for more information. See How to Interface with the Real Divide HDL Optimized Block and Hardware Resource Utilization for more information and examples showing how this parameter impacts latency and hardware resource utilization.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
function.
To get the block parameter value
programmatically, use the get_param
function.
Parameter: | nIterPerReg |
Values: | 1 (default) | positive integer-valued scalar |
Data Types: | char | string |
Example: set_param(gcb,"nIterPerReg","2")
More About
Tips
The blocks Divide by Constant HDL Optimized, Real Divide HDL Optimized, and Complex Divide HDL Optimized all perform the division operation and generate optimized HDL code.
Real Divide HDL Optimized and Complex Divide HDL Optimized are based on a CORIDC algorithm. These blocks accept a wide variety of inputs, but will result in greater latency.
Divide by Constant HDL Optimized accepts only real inputs and a constant divisor. Use of this block consumes DSP slices, but will complete the division operation in fewer cycles and at a higher clock rate.
Algorithms
CORDIC
CORDIC is an acronym for COordinate Rotation DIgital Computer. The Givens rotation-based CORDIC algorithm is one of the most hardware-efficient algorithms available because it requires only iterative shift-add operations (see More About). The CORDIC algorithm eliminates the need for explicit multipliers.
Division by Zero Behavior
For fixed-point inputs when the denominator den
is zero:
If
num >= 0
, then the output y is equal toupperbound(OutputType)
.If
num < 0
, then the output y is equal tolowerbound(OutputType)
.
For floating-point inputs, the Real Divide HDL Optimized block follows IEEE® Standard 754.
Tip
Enable the divideByZero port to output a flag when the block is given zero as an input value for the divisor.
How to Interface with the Real Divide HDL Optimized Block
Because of its fully pipelined nature, the Real Divide HDL Optimized block is able to accept input data on any cycle, including consecutive cycles. To send input data to the block, the validIn signal must be true. When the block has finished the computation and is ready to send the output, it will change validOut to true for one clock cycle. For inputs sent on consecutive cycles, validOut will also be set to true on consecutive cycles. Both the numerator and the denominator must be sent together on the same cycle.
The latency depends on the input data type, the number of iterations per pipeline register, and the maximum shift value of hyperbolic vectoring CORDIC, as summarized in the table. In the table:
The word length of the inputs num and den can differ.
wl = max(num.WordLength + ~issigned(num), den.WordLength + ~issigned(den))
When the Automatically select CORDIC maximum shift value based on input word length is set to
on
, thenmaximumShiftValue = wl - 1
. When the Automatically select CORDIC maximum shift value based on input word length is set tooff
, thenmaximumShiftValue
is specified by the CORDIC maximum shift value parameter.
Input Type | Latency |
---|---|
Fixed point or scaled double |
|
Floating point | 0 |
Customizable Pipelining
The Real Divide HDL Optimized block uses fully pipelined architecture
that implements iterative normalization and a CORDIC-based division algorithm. If the inputs
num and den are
fixed-point or scaled double data types, the block uses multiple pipeline stages for
computation. The normalization requires nextpow2(num.WordLength)
iterations. The number of CORDIC iterations depends on the value of the CORDIC maximum shift
value parameter. A larger word length can provide higher resolution, but
requires more iterations to process. The Real Divide HDL Optimized block can
perform multiple iterations per pipeline stage, which results in lower latency at the cost
of a longer critical path in the generated HDL code.
For example, if num and den are signed and have 18-bit word
lengths, then normalization requires 5
iterations. If the Automatically select
CORDIC maximum shift value based on input word length parameter is selected,
the CORDIC maximum shift value is 18 - 1 = 17
and requires
17
iterations. The total number of iterations is 5 + 17 =
22
and the latency of the block is ceil((total number of
iterations)/nIterPerReg) + 1
. If the number of iterations per pipeline register
is set to 1
, then the block latency is 23
; if the
number of iterations per pipeline register is set to 2
, then the block
latency is 12
. If the number of iterations per pipeline register is
greater than the total number of required iterations, the block performs all iterations in
one pipeline stage and the total latency is minimized to 2
.
Hardware Resource Utilization
This block supports HDL code generation using the Simulink® HDL Workflow Advisor. For an example, see HDL Code Generation and FPGA Synthesis from Simulink Model (HDL Coder) and Implement Digital Downconverter for FPGA (DSP HDL Toolbox).
This example data was generated by synthesizing the block on a Xilinx® Zynq®-7000 xc7z045 SoC. The synthesis tool was Vivado® v2023.1.2.
The following synthesis results show the effect of the Number of iterations per pipeline register parameter on the latency and hardware resource utilization.
nIterPerReg = 1
These parameters were used for synthesis:
Input data type:
sfix18_en10
Output data type:
sfix18_en10
Input dimension: scalar
Automatically select CORDIC maximum shift value based on input word length:
on
Number of iterations per pipeline register:
1
Target frequency: 500 MHz
Latency for this configuration: 23
Resource | Usage | Available | Utilization (%) |
---|---|---|---|
Slice LUTs | 968 | 218600 | 0.44 |
Slice Registers | 823 | 437200 | 0.19 |
DSPs | 0 | 900 | 0.00 |
Block RAM Tile | 0 | 545 | 0.00 |
URAM | 0 | 0 |
Value | |
---|---|
Requirement | 2 ns (500 MHz) |
Data Path Delay | 1.74 ns |
Slack | 0.176 ns |
Clock Frequency | 548.25 MHz |
nIterPerReg = 2
These parameters were used for synthesis:
Input data type:
sfix18_en10
Output data type:
sfix18_en10
Input dimension: scalar
Automatically select CORDIC maximum shift value based on input word length:
on
Number of iterations per pipeline register:
2
Target frequency: 300 MHz
Latency for this configuration: 12
Resource | Usage | Available | Utilization (%) |
---|---|---|---|
Slice LUTs | 820 | 218600 | 0.38 |
Slice Registers | 449 | 437200 | 0.10 |
DSPs | 0 | 900 | 0.00 |
Block RAM Tile | 0 | 545 | 0.00 |
URAM | 0 | 0 |
Value | |
---|---|
Requirement | 3.3333 ns (300 MHz) |
Data Path Delay | 2.383 ns |
Slack | 0.943 ns |
Clock Frequency | 418.35 MHz |
nIterPerReg = 3
These parameters were used for synthesis:
Input data type:
sfix18_en10
Output data type:
sfix18_en10
Input dimension: scalar
Automatically select CORDIC maximum shift value based on input word length:
on
Number of iterations per pipeline register:
3
Target frequency: 200 MHz
Latency for this configuration: 9
Resource | Usage | Available | Utilization (%) |
---|---|---|---|
Slice LUTs | 794 | 218600 | 0.36 |
Slice Registers | 339 | 437200 | 0.08 |
DSPs | 0 | 900 | 0.00 |
Block RAM Tile | 0 | 545 | 0.00 |
URAM | 0 | 0 |
Value | |
---|---|
Requirement | 5 ns (200 MHz) |
Data Path Delay | 3.377 ns |
Slack | 1.616 ns |
Clock Frequency | 295.51 MHz |
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Slope-bias representation is not supported for fixed-point data types.
HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.
This block has one default HDL architecture.
General | |
---|---|
ConstrainedOutputPipeline | Number of registers to place at
the outputs by moving existing delays within your design. Distributed
pipelining does not redistribute these registers. The default is
|
In R2024b: FlattenHierarchy | Remove PWM Reference Generator block hierarchy from
generated HDL code. The default is |
InputPipeline | Number of input pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|
OutputPipeline | Number of output pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|
Supports binary-point scaled fixed-point data types only.
Version History
Introduced in R2021aR2024b: Custom pipelining, improved latency and resource utilization, optional divide by zero port
Several improvements have been made to the Real Divide HDL Optimized block:
Custom pipelining is supported via the new CORDIC maximum shift value and Number of iterations per pipeline register parameters.
The latency of this block has been reduced. Latency depends on the specified data type and pipeline configuration. See How to Interface with the Real Divide HDL Optimized Block for more information.
HDL resource utilization has been further optimized to require fewer hardware resources. See Hardware Resource Utilization for example synthesis results.
An optional divideByZero port has been added to output a flag when the corresponding output is a result of division by zero.
R2024b: Support for unsigned output
The Real Divide HDL Optimized block now supports unsigned data types for the Output datatype parameter.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)