HDL Counter
Forward and backward counting over a given range of numbers.
blockType: SubSystem
Path in the library:
|
Description
Block HDL Counter simulates a Free-running
, Count limited
and Modulo
hardware counter that supports signed and unsigned integers and fixed-point data types. The counter outputs its value for the current point in time.
The counter counts from an initial value to a threshold value based on the values of the parameters Counter type, Count to value, и Word length. The counter output data type depends on the parameters Counter output data is, Word length, и Fraction length.
Ports
Input
#
rst
—
reset signal
scalar
Details
Input signal, used to determine when the counter is reset by the unit.
Data types |
|
Complex numbers support |
No |
#
load
—
load signal
scalar
Details
Load input signal. When a logical 1
is input, the counter takes the value arrived at port load_val.
Data types |
|
Complex numbers support |
No |
#
load_val
—
load signal at logical 1
on port load
scalar
Details
Signal to write to the counter when a logical 1
is applied to the load port.
Data types |
|
Complex numbers support |
No |
#
enb
—
activation signal
scalar
Details
An input signal that determines whether the counter should count up from the previous value.
-
When this signal is
1
, the counter continues counting up or down depending on the direction. -
When this signal is
0
, the counter keeps the previous value.
Data types |
|
Complex numbers support |
No |
#
dir
—
count direction signal
scalar
Details
An input signal that determines whether to read up or down. This port is associated with a parameter Step value to determine the count direction.
-
The value
1
is by default, which causes the counter to increment. The value of the parameters Step value is added to the current counter value to calculate the next value. -
The value
0
- which causes the counter to decrease. Parameters value Step value is subtracted from the current counter value to calculate the next value.
Data types |
|
Complex numbers support |
No |
Output
#
count
—
current counter value
scalar
Details
The current value of the counter, specified as a scalar.
Data types |
|
Complex numbers support |
No |
#
count_hit
—
indicator that the counter has reached the limit value
scalar
Details
A counter limit indicator returned as a scalar with a boolean value.
-
A value of
1
indicates that the counter has reached its limit. -
A value of
0
indicates that the counter has not reached its limit.
This port will only output correct values when a logical 1
is received on the dir port, otherwise the output values may not be correct
Data types |
|
Complex numbers support |
No |
Parameters
Parameters
#
Counter type —
counter type
Free running
| Count limited
| Modulo
Details
A counter behaviour that determines which hardware counter to model: free-running, constrained or modular. Defined as:
-
Free running
(By default) - the counter continues to increment or decrement by the parameter value Step value until reset. -
Count limited
- the counter increases or decreases by the parameter value Step value until it is exactly equal to the value of the parameters. Count to value. If the value Step value is such that the count value is not exactly equal to the parameter value . Count to value, it may continue counting up to a threshold value, which is determined by the parameters Word length. -
Modulo
- the counter is incremented or decremented by the value of the parameters Step value*until it reaches the value of the parameters. *Count to value. If the value Step value is such that the value of the counter is not exactly equal to Count to value, then the counter rolls up to a value that is determined by the value of the roll step.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
# Initial value — counter value after reset
Details
The value to which the counter is reset.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
# Step value — step value for counting
Details
The value added to the counter at each time reference.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
# Count to value — counter threshold
Details
In usage of the Count limited
mode, if the counter value is exactly equal to the value of the parameters Count to value*then the counting starts again from the value *Initial value.
If the count value exceeds Count to value, the counter continues counting up to a threshold value, which depends on the parameters . Word length.
In usage of Modulo
mode, if the counter reaches a value of , the counter restarts from a value determined by the convolution step value. *Count to value*The counter restarts from a value determined by the value of the convolution step.
Dependencies
To use this parameter, set the parameters Count limited
or Modulo
to Counter type to Count limited
or Modulo
.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
#
Count from —
rule for calculating the initial counter value
Initial value
| Specify
Details
Select the rule that will select the initial counter value to which the counter will return when the threshold value is reached. This rule is valid for the Count limited
and Free-running
counter modes. In `Modulo' mode, after reaching the threshold value, the counter may take a convolution step value that is different from the initial counter value.
-
If the
Specify
mode is selected, the parameters Count from value is the initial value after the counter reaches the threshold value.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
# Count from value — initial counter value
Details
The value of the counter after it reaches the threshold value when the parameters are set to Specify
. Count from is set to Specify
.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
#
Counter output data is —
output characterisation
Unsigned
| Signed
Details
Defines the signability of the input data.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
# Word length — counter word length
Details
The number of bits, including the sign bit, for an integer counter; the length of the integer portion of the fixed-point data.
If the parameters value Counter output data is is set to Unsigned
mode, the minimum possible value Word length is 1
; in Signed
mode the minimum possible value is 2
. The maximum possible value of parameters Word length is 125
.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
# Fraction length — fractional length of the counter
Details
The fractional length for a fixed-point data type.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |