At the heart of the counter block is a
32-bit count register. This register can either be loaded statically before counting
commences, or dynamically at run time. The operation of the counter submodule is
determined by the inputs described below. Note that each of the inputs can be
connected to the outputs of any of the other blocks in the CLB tile. These
connections are made by configuring the static switch block.
The counter inputs are:
- RESET: This is the
highest priority input and takes precedence over all other inputs. The input
is level sensitive and as long as the input remains high, the counter resets
to 0 on the next clock cycle.
- MODE_0: This input is
an enable for the counter. The counter begins counting (up or down depending
on the MODE_1 setting) only when this input is high. If this input is low,
then no counting takes place.
- MODE_1: This input is
the direction control for the counter. If this input is high, then the
counter increments on every clock cycle where MODE_0 is high. If this input
is low, then the counter decrements on every clock cycle where MODE_0 is
high. The counter wraps around to 0x0000 0000 after 0xFFFF FFFF when
counting up. The counter wraps around to 0xFFFF FFFF after 0x0000 0000 when
counting down. The only exception to this is when an EVENT occurs at exactly
the same time, causing a different value to be loaded into the counter.
- EVENT: This input is
defined for the purpose of triggering actions in the counter based on
certain events. The event can be any of the outputs of the other blocks or
an external input to the tile. The counter’s static control inputs define
the behavior of the counter on an active event. An active event is defined
as a rising edge on the EVENT input. The counter can be configured to
perform one of the following actions:
- Load a predefined
32-bit value from the LOAD VALUE register into the count
register
- Shift the contents of
the counter register left or right by a predefined amount between 0
and 31
- Add or subtract a
predefined 32-bit value. Addition and subtraction are treated as
32-bit unsigned operations and there is no saturation.
Note that the effect
of a rising edge on the EVENT input only lasts for one cycle. On the
next cycle, the counter operation continues based on the MODE_0, MODE_1,
and RESET inputs.
MATCH1 REF and MATCH2 REF are 32-bit
reference values that are used to generate the MATCH1 and MATCH2 outputs. The MATCH1
output becomes active high whenever the counter register value matches the 32-bit
MATCH1 REF value. MATCH2 behaves in a similar manner in relation to the MATCH2 REF
register. The reference values for MATCH1 and MATCH2 can either be setup once before
the start of operation, or can be modified dynamically. The High Level Controller
can load desired values into the MATCH1 REF and MATCH2 REF registers.
Note that the counter load and match
registers are not memory-mapped. For more information, see Section 11.5.2.
The three logic outputs of the counter
block are:
- ZERO: This output goes
high whenever the counter register is 0.
- MATCH1: This output
goes high whenever the counter register is equal to the MATCH1 REF input
register.
- MATCH2: This output
goes high whenever the counter register is equal to the MATCH2 REF input
register.
The operation of the counter block is
controlled by the CFG_MISC_CTRL register. The following three bits of this register
are relevant for each counter. The “x” below refers to the counter instance; 0, 1,
or 2. For more information, see the CLB_MISC_CONTROL register description located in
Section 11.10.
- COUNT_EVENT_CTRL_x: This bit
defines whether the counter performs an addition or a shift on an event. A value
of 0 means that on an event, the counter loads the static value; 1 means an
add/shift operation is performed. This bit must be 0 for indirect loads and HLC
loads of the counter to take effect.
- COUNT_ADD_SHIFT_x. 1 means add, 0
means shift.
- COUNT_DIR_x. 1 means left shift
or add. 0 means right shift or subtract.
Table 11-11 shows the logical operation of the counter block in terms of the inputs and
control register bits. Count up and down modes are the normal operation with EVENT =
0. The operations on the CNTVAL register are:
Load: CNTVAL = EVENT_LOAD_VAL
Shift right: CNTVAL = CNTVAL >>
EVENT_LOAD_VAL
Shift left: CNTVAL = CNTVAL <<
EVENT_LOAD_VAL
Subtract: CNTVAL = CNTVAL -
EVENT_LOAD_VAL
Add: CNTVAL = CNTVAL +
EVENT_LOAD_VAL
Table 11-11 Counter Block Operating
Modes
| EVENT |
MODE_0 |
MODE_1 |
COUNT_EVENT_CTRL_x |
COUNT_ADD_SHIFT_x |
COUNT_DIR_x |
Action on CNTVAL |
| 0 |
0 |
0 |
X |
X |
X |
None |
| 0 |
0 |
1 |
X |
X |
X |
None |
| 0 |
1 |
0 |
X |
X |
X |
Count down |
| 0 |
1 |
1 |
X |
X |
X |
Count up |
| 1 |
X |
X |
0 |
X |
X |
Load |
| 1 |
X |
X |
1 |
0 |
0 |
Shift right |
| 1 |
X |
X |
1 |
0 |
1 |
Shift left |
| 1 |
X |
X |
1 |
1 |
0 |
Subtract |
| 1 |
X |
X |
1 |
1 |
1 |
Add |