Shallow vs. Deep Copy in Pyhton Testbench Environments
Testbench environments can be of two types: in-order execution and out-of-order execution.
A) In-order execution involves the Driver Class applying new stimuli generated by the Generator class to the Device Under Test (DUT) using a decorator. The Driver Class then waits for the Monitor to receive the response, and the Scoreboard compares it with golden data. Only after all these steps are complete for the current transaction is a new stimuli generated. In this scenario, both shallow copy and deep copy can work because the verification environment is held until the current transaction is processed.
B) Out-of-order execution differs in that the Generator doesn't wait for the Monitor and Scoreboard to finish with the current transaction before generating the next one. This necessitates having independent objects for each transaction to prevent them from being overwritten by subsequent stimuli. Therefore, deep copy is the preferred method here to create these independent objects.
Deep copy works well for both in-order and out-of-order execution, making it the more versatile choice for all testbench environments. This eliminates the need to worry about the specific type of environment and simplifies the verification process.
Python offers both shallow and deep copy methods to meet user-specific needs for implementing in-order or out-of-order execution environments. Here is code snippet how to do shallow and deep copy in Python.



