12-05-2024 09:32 AM - edited 12-05-2024 09:41 AM
Hi,
I was annoyed with the unclear specification of the NI 4-Wire handshaking protocol for usage inside single cycle timed loops.
Being used to the excellent AXI4-Stream protocol spec, I tried to provide a similar quality spec for the NI protocol:
In-official description of NI 4-Wire handshake protocol
For a connection from node A to a downstream node B:
ready for input
: out std_logic
ready for input
is asserted if and only if the downstream node B can accept data on the next clock cycle.input valid
to be asserted before asserting B.ready for input
.ready for input
is usually a combinational output (inside SCTLs), often driven via combinatorial logic from B.input valid
.ready for input
without B.input valid
being asserted is unspecified.ready for output
: in std_logic
ready for output
is asserted if and only if the downstream node B can accept data during the current clock cycle. ready for input
as source, i.e., it is a registered version of B.ready for input
.output valid
: out std_logic
output valid
is asserted if and only if the upstream node A presents new valid data at its output AND if a handshake has been completed with the downstream node B via the assertion of A.ready for output
during the current clock cycle. output valid
is usually a combinational output with a direct combinatorial path from A.ready for output
.output valid
usually reacts to A.ready for output
, it is not clearly specified that it must only be asserted during/after the assertion of A.ready for output
, although examples imply this behavior. output valid
without receiving A.ready for output
and holding it asserted until A.ready for output
is received may also be possible, but is not recommended.input valid
: in std_logic
input valid
is asserted if and only if the upstream node A provides new valid data AND completes/accepts the handshake for the current clock cycle, offered by B.ready for input
on the previous clock cycle. input valid
during the current clock cycle if and only if B.ready for input
was asserted on the previous clock cycle. input valid
is asserted without having had B.ready for input
asserted on the previous clock cycle. Thus, asserting B.input valid
without an assertion of B.ready for input
on the previous clock cycle may be considered a protocol error.Common wiring for Node A -> Node B
A.output valid
-> B.input valid
A.ready for output
<- feedback-node <- B.ready for input
(A.data out
-> B.data in
)
Please feel free to provide improvements or list corner cases.
A gotcha I found myself is the Global initialize
setting of Feedback Nodes, which often has to be changed to Initialize on Compile or Load
if an initial value is wired to them and they are placed inside sub-VIs.