A one-shot is a logic circuit with two states, of which only one is stable. This post explains how to describe this circuit in high-level synthesis.
It has an input called a trigger and an output representing the state.
The one-shot is in its stable state initially. When it receives a rising edge on its trigger input, it goes to its unstable state for a predefined period of time (e.g., tw) and returns to the stable state automatically. The following timing diagram shows this behaviour. As can be seen, a pulse with tw width will appear on the output on the rising edge of the trigger input.
There are two types of the one-shot circuit:
The Nonretriggerable one-shot ignores all the writing edges received during its unstable state.
However, the retriggerable one-shot starts the unstable state whenever it receives a rising edge on the trigger input, even during the unstable state.
It is easy to use HLS to describe a one-shot circuit. The following code implements a retriggerable one-shot. The top function has three arguments; one input called the trigger, another input called duration that receives the number of clocks that the circuit should spend in its unstable state and finally, an output named Q that represents the state of the circuit.
Lines 24-50 describe a two-state state machine implementing the one-shot functionality. Lines 26 and 36 detect the rising edge on the trigger input.
The following figure shows the waveforms after RTL/C Cosimulation in Vitis-HS.