A common asynchronous protocol is the simple, four-phase handshake. Data is transferred once per complete handshake operation, which involves four phases.
Simple transactor code to convert the pin-level implementation so that software can call it can be implemented as follows:
putbyte(char d)
{
wait_until(!ack);
data = d;
settle();
req = 1;
wait_until(ack);
req = 0;
}
char getbyte()
{
wait_until(req); // NB: wait_until not in SystemC 2.0
char r = data; // See full code on web site, practical section.
ack = 1;
wait_until(!req);
ack = 0;
return r;
}
Other forms of transactor keep their own thread and make up-calls to user callbacks for each transaction.