Loading simulator…
1. Phase and SCK Generation
The phase T flip-flop toggles only on an enabled half-tick event.
T_Phase = Enable·Half_Tick
The serial clock is generated by
SCK = CPOL ⊕ Phase
Resetting Phase to 0 therefore returns SCK to the idle level selected by CPOL.
2. SPI Edge-Decoding Block
The two phase-transition events are:
``text Idle_to_Active = Enable·Half_Tick·Phase' Active_to_Idle = Enable·Half_Tick·Phase
`CPHA` assigns them to their protocol actions through:
```text
Sample_Edge = CPHA'·Idle_to_Active + CPHA·Active_to_Idle
Change_Edge = CPHA·Idle_to_Active + CPHA'·Active_to_Idle
This shared logic supports all four modes:
CPOL selects the physical SCK edge directionCPHA selects whether that edge samples or changes data.3. Transfer-Start and First-Bit Preload Block
An Enable_PREV flip-flop records the previous enable value.
The transfer-start pulse is:
Transfer_Start = Enable·Enable_PREV'
Combining this event with the normal change event gives:
TX_Load = Change_Edge + CPHA'·Transfer_Start
For CPHA = 0, TX_Load preloads the first tx_reg_bit before the first sample edge.
For CPHA = 1, the preload term is disabled and the first bit loads on the first Change_Edge.
4. MOSI Enable-and-Hold Register
The MOSI register loads tx_reg_bit only while TX_Load is HIGH.
Its hold behavior can be expressed as
MOSI_Next = TX_Load·tx_reg_bit + TX_Load'·MOSI
MOSI therefore changes only at the required change event, apart from the intentional CPHA = 0 preload.
5. MISO Sampling Register
The RX register loads the direct MISO input only on Sample_Edge.
Its hold behavior is:
rx_reg_bit_Next = Sample_Edge·MISO + Sample_Edge'·rx_reg_bit
Between sample events, the previously captured bit remains observable.
6. Reset and Transfer Completion
The digital input nRESET asynchronously clears Phase, Enable_PREV, the MOSI storage, and rx_reg_bit.
The transfer sequence must complete the return edge before clearing Enable, leaving Phase = 0 and SCK = CPOL.