The CLB is responsible for detecting
the encoder's response and then clocking the SPI to receive the data. First consider
the duty and frequency of the clock. Figure 2-14 shows the CLB logic which generates the SPI clock. The corresponding simulation
waveform is shown in Figure 2-15.
The first step is to generate a clock (called SPI_CLOCK) with the specificed
frequency and duty. In the generation of SPI_CLOCK:
- TILE3_COUNTER_1: is responsible
for the duty and frequency (width) of the clock. The time between the high
transition and the low transition of the SPI_CLOCK is measured in the number of
CLB clocks. The following match signals are used:
- zero match: corresponds
to the low transition of the clock
- match1: corresponds to
the high transition of the clock
- match2: corresponds to
the width of the clock
- TILE3_FSM_1: Generates the clock
edges based on the COUNTER_1 match values: match1 and zero match
- TILE3_LUT_0: Resets the counter when the clock width has been reached as
indicated by the COUNTER_1 match2 output
The second step is to align the clock
with the received data. This is required for the SPI to receive the encoder's
response correctly. There are two challenges to aligning the clock:
- The response can arrive at
any time due to cable propagation delay as described in Section 2.3.1.1.
- The encoder can also delay
the acknowledgment, ACK, to request additional processing time as described
in Section 2.3.1.2.
To align the clock, LUT_0 monitors the
RESPONSE signal for a rising edge. The first rising edge corresponds to the START
bit after the acknowledge (ACK) bit. When this edge is detected, LUT_0 resets
COUNTER_1 which aligns the SPI_CLOCK to the response.
The third step is to generate the CLB_SPI_CLOCK based on the internal SPI_CLOCK. As
shown in Figure 2-15:
- SPI_CLOCK is generated for a longer duration then required for the SPI to
receive the response
- CLB_SPI_CLOCK only outputs the number of clocks required to receive the
response
This is achieved by using TILE4_FSM_2 to generate a SPI_CLOCK_OUTPUT_ENABLE
signal. This signal is used by the OUTLUT to allow/block the SPI_CLOCK as
required.