Constant Integer
Generates a constant integer value in VHDL INTEGER type (32-bit signed). Supports hexadecimal (0x…), binary (0b…), and decimal input formats. Used for loop counters, array indices, generic parameters, and integer arithmetic in FPGA designs. Zero latency, pure combinational output.
Introduction
This block generates a constant integer value using the VHDL INTEGER
type. Unlike bit-vector constants, integers are treated as mathematical
values rather than binary patterns, making them ideal for:
- Loop counters and array indices
- Generic parameters and size calculations
- Arithmetic operations requiring signed integer math
- Control logic and state machine values
The component accepts values in multiple formats:
- Hexadecimal:
0xFF,0x1000,0xDEAD - Binary:
0b10101010,0b11110000 - Decimal:
255,-1024,3735928559
The output is a VHDL INTEGER type (32-bit signed, range: -2,147,483,648 to 2,147,483,647) with zero clock latency.
Pin Description
Constant integer output in VHDL INTEGER type (32-bit signed), always combinational (zero latency). Width: Fixed at 32 bits (VHDL INTEGER standard).
The output value is fixed at design time and remains constant during operation. Suitable for direct use in integer arithmetic or as generic parameters in VHDL generate statements.
Properties
Set the value of the constant. Use 0x
Default: 0
Functional description
The component implements a constant integer source in VHDL. The value is defined at compile time and hardwired into the design:
$$ \mathrm{CONST} = V $$
where $V$ is the user-specified integer constant value.
VHDL INTEGER type
The output uses the VHDL INTEGER type, which is:
- Signed 32-bit integer
- Range: $-2^{31}$ to $2^{31}-1$ (-2,147,483,648 to 2,147,483,647)
- Synthesis: Typically mapped to 32-bit
std_logic_vectorwith sign extension
This differs from std_logic_vector constants, which are unsigned bit patterns.
Use INTEGER when you need:
- Negative values with automatic sign handling
- Arithmetic operations (+, -, *, /) without manual type conversions
- Loop indices or array sizes in VHDL generate statements
Value formats
The component supports three input formats:
-
Hexadecimal (
0xprefix): Compact notation for large valuesValue: 0xFF → Integer: 255 Value: 0x1000 → Integer: 4096 Value: 0xFFFFFFFF → Integer: 4294967295 (converted to signed) -
Binary (
0bprefix): Explicit bit pattern specificationValue: 0b10101010 → Integer: 170 Value: 0b11110000 → Integer: 240 -
Decimal (no prefix): Standard integer notation
Value: 255 → Integer: 255 Value: -1024 → Integer: -1024 (negative values supported) Value: 1000000 → Integer: 1000000
Signed vs. unsigned interpretation
When using hexadecimal or binary notation, the component interprets values as unsigned during parsing, then converts to signed INTEGER:
Value: 0xFFFFFFFF (unsigned: 4,294,967,295)
INTEGER result: -1 (signed 32-bit interpretation)
For negative constants, use decimal notation:
Value: -100 → INTEGER: -100 (explicit negative)
Range limits
Values must fit within the 32-bit signed INTEGER range. Overflow behavior:
- Values > 2,147,483,647: Wrapped to negative (two’s complement)
- Values < -2,147,483,648: Compilation error or unpredictable behavior
For values outside this range, use a bit-vector constant instead.
Implementation details
The VHDL implementation declares a signal and assigns the constant:
vhdl
signal CONST : INTEGER := 0;
CONST <= <parsed_value>;
Depending on the input format:
- Hexadecimal: Parsed with
Convert.ToUInt32(value, 16) - Binary: Parsed with
Convert.ToUInt32(value, 2) - Decimal: Used directly as integer literal
Timing
The component is purely combinational with zero latency:
| Property | Latency (clock cycles) |
|---|---|
| Constant Integer | 0 |
The output is available immediately after FPGA configuration and does not depend on any clock signal.
Typical use cases
- Generic parameters: Define configurable design sizes (e.g., FIFO depth, data width)
- Loop counters: Provide constant iteration counts in
forloops - Array indices: Supply fixed addresses or offsets for memory/register access
- Arithmetic constants: Multipliers, divisors, or offsets in integer math
- State machine values: Define enumeration-like constants for FSM states
- Control thresholds: Comparison values for counters or threshold detectors
- Timeout values: Fixed delay counts for timers and watchdogs
Example configurations
Example 1: Loop counter maximum
Value: 1000
Use case: Maximum count for a loop or counter
Output: INTEGER = 1000
Example 2: Memory address offset
Value: 0x1000
Use case: Base address for memory-mapped registers
Output: INTEGER = 4096
Example 3: Negative offset
Value: -50
Use case: Signed offset for centering or calibration
Output: INTEGER = -50
Example 4: Binary mask size
Value: 0b1111
Use case: 4-bit mask or size parameter
Output: INTEGER = 15
INTEGER vs. BIT-VECTOR constants
| Feature | INTEGER Constant | Bit-Vector Constant |
|---|---|---|
| Type | Signed 32-bit | Unsigned N-bit |
| Width | Fixed 32 bits | Configurable |
| Negative values | Native support | Requires 2’s comp |
| Arithmetic | Direct (+, -, *) | Needs conversion |
| Bit manipulation | Limited | Full bitwise ops |
| Use case | Math, indices | Masks, patterns |
Choose INTEGER for mathematical values and BIT-VECTOR for bit patterns.