We have a I2C master and slave agent and associated UVCs. I have driver implemented different tasks like driving the address, read and write the data etc. Is it a good idea to implement these tasks inside interface. If yes, what are the pros and cons of implementing these tasks inside interface rather than at Bus driver?
I can think of cons here -
-
As interface is module, your tasks/functions will be static in nature. Whereas using task/function in Driver is dynamic and memory allocation for these are in run-time.
-
To make use of other concepts like callback(Injecting Errors), polymorphism(Extending functionality) etc. you’ll need Driver implementation for task/function.
Basically whatever advantages can be achieved from OOPs might not be applicable if you are going for ‘Interface’ implementation for tasks.
In reply to suryamudgal:
Implementing your methods inside an interface allows you take advantage of simulation acceleration hardware such as Veloce, etc. It also helps you to encapsulate your pin wiggling functionality all in one place and allow all transaction level interactions to stay in the class based world.
As the previous poster pointed out, you will lose out on the ability to override the function by extending a class. However, if you put in callback methods, you can still change the behavior based on configuration, etc.