Output minimum or maximum input value
Simulink / Math Operations
HDL Coder / Math Operations
The MinMax block outputs either the minimum or the maximum element or elements of the inputs. You choose whether the block outputs the minimum or maximum values by setting the Function parameter.
The MinMax block ignores any input value that is NaN
,
except when every input value is NaN
. When all
input values are NaN
, the output is NaN
, either as a scalar or the value of each output vector element.
Port_1
— Input signalProvide an input signal from which the block outputs the maximum or minimum values.
When the block has one input port, the input must be a scalar or a vector. The block outputs a scalar equal to the minimum or maximum element of the input vector.
When the block has multiple input ports, all nonscalar inputs must have the same dimensions. The block expands any scalar inputs to have the same dimensions as the nonscalar inputs. The block outputs a signal having the same dimensions as the input. Each output element equals the minimum or maximum of the corresponding input elements.
To support matrix input, you must set the Number of input ports parameter to an integer greater than one. All nonscalar inputs must have the same dimensions.
Data Types: half
| single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
Port_N
— N-th input signalProvide an input signal from which the block outputs the maximum or minimum values.
When the block has multiple input ports, all nonscalar inputs must have the same dimensions. The block expands any scalar inputs to have the same dimensions as the nonscalar inputs. The block outputs a signal having the same dimensions as the input. Each output element equals the minimum or maximum of the corresponding input elements.
To provide more than one input signal, set the Number of input ports to an integer greater than 1.
Data Types: half
| single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
Port_1
— Minimum or maximum values of inputsWhen the block has one input, the output is a scalar value, equal to the minimum or maximum of the input elements. When the block has multiple inputs, the output is a signal having the same dimensions as the input. Each output element equals the minimum or maximum of the corresponding input elements.
Data Types: half
| single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
Function
— Specify minimum or maximummin
(default) | max
Specify whether to apply the function min
or
max
to the input.
Block Parameter:
Function |
Type: character vector |
Values:
'min' | 'max' |
Default:
'min' |
Number of input ports
— Specify number of input ports1
(default) | positive integer
Specify the number of inputs to the block.
Block Parameter:
Inputs |
Type: character vector |
Values:
positive integer |
Default:
'1' |
Enable zero-crossing detection
— Enable zero-crossing detectionon
(default) | BooleanSelect to enable zero-crossing detection. For more information, see Zero-Crossing Detection.
Block Parameter:
ZeroCross |
Type: character vector, string |
Values: 'off' |
'on' |
Default: 'on' |
Sample time
— Specify sample time as a value other than -1
-1
(default) | scalar | vectorSpecify the sample time as a value other than -1. For more information, see Specify Sample Time.
This parameter is not visible unless it is explicitly set to a value other than
-1
. To learn more, see Blocks for Which Sample Time Is Not Recommended.
Block Parameter:
SampleTime |
Type: character vector |
Values: scalar or vector |
Default:
'-1' |
Require all inputs to have the same data type
— Inputs must have the same data typeoff
(default) | on
Select this check box to require that all inputs have the same data type.
Block Parameter:
InputSameDT |
Type: character vector |
Values:
'off' | 'on' |
Default:
'off' |
Output minimum
— Minimum output value for range checking[]
(default) | scalarLower value of the output range that Simulink® checks.
Simulink uses the minimum to perform:
Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters) for some blocks.
Simulation range checking (see Specify Signal Ranges and Enable Simulation Range Checking).
Automatic scaling of fixed-point data types.
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
Output minimum does not saturate or clip the actual output signal. Use the Saturation block instead.
Block Parameter:
OutMin |
Type: character vector |
Values: '[ ]' |
scalar |
Default: '[ ]' |
Output maximum
— Maximum output value for range checking[]
(default) | scalarUpper value of the output range that Simulink checks.
Simulink uses the maximum value to perform:
Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters) for some blocks.
Simulation range checking (see Specify Signal Ranges and Enable Simulation Range Checking).
Automatic scaling of fixed-point data types.
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Note
Output maximum does not saturate or clip the actual output signal. Use the Saturation block instead.
Block Parameter:
OutMax |
Type: character vector |
Values: '[ ]' |
scalar |
Default: '[ ]' |
Output data type
— Specify the output data typeInherit: Inherit via internal
rule
(default) | Inherit: Inherit via back
propagation
| double
| single
| half
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| <data type expression>
Choose the data type for the output. The type can be inherited, specified directly, or
expressed as a data type object such as
Simulink.NumericType
.
Click the Show data type assistant
button to display the Data Type Assistant,
which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant.
Block Parameter:
OutDataTypeStr |
Type: character vector |
Values: 'Inherit: Inherit via internal
rule' | 'Inherit: Inherit via back
propagation' | 'single' |
'half' |
'int8' | 'uint8' |
'int16' | 'uint16' |
'int32' | 'uint32' |
'int64' | 'uint64' |
'fixdt(1,16,0)' |
'fixdt(1,16,2^0,0)' | '<data
type expression>' |
Default: 'Inherit:
Inherit via internal rule' |
Lock output data type setting against changes by the fixed-point tools
— Prevent fixed-point tools from overriding Output data typeoff
(default) | on
Select this parameter to prevent the fixed-point tools from overriding the Output data type you specify on the block. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).
Block Parameter:
LockScale |
Type: character vector |
Values:
'off' | 'on' |
Default:
'off' |
Integer rounding mode
— Rounding mode for fixed-point operationsFloor
(default) | Ceiling
| Convergent
| Nearest
| Round
| Simplest
| Zero
Specify the rounding mode for fixed-point operations. For more information, see Rounding (Fixed-Point Designer).
Block parameters always round to the nearest representable value. To control the rounding of a block parameter, enter an expression using a MATLAB® rounding function into the mask field.
Block Parameter:
RndMeth |
Type: character vector |
Values:
'Ceiling' | 'Convergent' | 'Floor' | 'Nearest' | 'Round' | 'Simplest' |
'Zero' |
Default:
'Floor' |
Saturate on integer overflow
— Method of overflow actionoff
(default) | on
Specify whether overflows saturate or wrap.
Action | Rationale | Impact on Overflows | Example |
---|---|---|---|
Select this check box ( |
Your model has possible overflow, and you want explicit saturation protection in the generated code. |
Overflows saturate to either the minimum or maximum value that the data type can represent. |
The maximum value that the |
Do not select this check box ( |
You want to optimize efficiency of your generated code. You want to avoid overspecifying how a block handles out-of-range signals. For more information, see Troubleshoot Signal Range Errors. |
Overflows wrap to the appropriate value that is representable by the data type. |
The maximum value that the |
When you select this check box, saturation applies to every internal operation on the block, not just the output, or result. Usually, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.
Block Parameter: SaturateOnIntegerOverflow |
Type: character vector |
Values:
'off' | 'on' |
Default: 'off' |
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.
This block has multi-cycle implementations that introduce additional latency in the generated code. To see the added latency, view the generated model or validation model. See Generated Model and Validation Model (HDL Coder).
Architecture | Additional cycles of latency | Description |
---|---|---|
default Tree | 0 | Generates a tree structure of comparators. |
Cascade | 1, when block has a single vector input port. | This implementation is optimized for latency * area, with medium speed. See Cascade Architecture Best Practices (HDL Coder). |
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
|
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
|
InstantiateStages | Generate a VHDL® |
SerialPartition | Specify partitions for Cascade-serial implementations as a vector of the lengths of each partition. The default setting uses the minimum number of stages. See also SerialPartition (HDL Coder). |
Note
To enable the LatencyStrategy setting for the
MinMax block, you must specify
Tree
as the HDL
Architecture.
Native Floating Point | |
---|---|
LatencyStrategy | Specify whether to map the blocks in your design to
|