passByReference

Pass By Reference

Passing by reference is a very emotive issue.

Here we ONLY address the issue of the transaction CONTAINERS, not the data they pass.

The emphasis of the interoperability level is to provide the fastest possible interoperable interface. Safety is left to the convenience level, with the one proviso that the interoperability level must not preclude a safe model.

Both nb_transact and b_transact operate "over" a transaction. nb_transact additionally operates over a timing.

The transaction is "in existence" from the beginning of the communication involving it from a master to a slave until that communication is fully terminated back to the master.

The life span is from Master back to Master.

For a timing object, the object encodes the protocol (and the timing of that protocol) which exists to transmit the transaction between a paired set of initiators and targets.

The life span is from Initiator back to Initiator.

In either case, if one of the models (or another third party) would like to "listen in" and possibly record some of the communication, then they must build another object with a different life span which is better suited to their needs.

Given these life spans, it is perfectly reasonable that the container holding information about the transaction is held, and owned by the master port. Likewise the container holding timing information is held by the initiator port.


Other implementations

The alternative implementation is to pass by value, rather than by reference. These implementations are functionally equivalent so long as the return value is assigned to the initial transaction.

In the case of most transaction level modelling, each attribute in the transaction is written to by a single master or slave (the exception would be a bus that allowed multiple writes, and adopted some other protocol to resolve which one arrived back at the master).

Hence, in effect, while the actual code of writing the result back to the initial transaction need not be present, the result should be the amalgam of the initially sent transaction (which would have un-initialised fields in it) and the values written into those un-initialised fields.

So, there would be no conflict in writing the result back to the initial transaction.

Hence, pass by value and pass by reference for the transaction containers are the same. In other words, a sufficiently aware compiler could translate a pass by value version into a pass by reference version.

But there is a larger cost in pass by value (as it involved more data copies).