SystemVerilog中的program和module有什么区别?
在传统的verilog验证环境中,测试激励也往往封装在module里。测试module用来产生激励,发送到DUT待测实例的端口上,也可以接收DUT的输出,并做结果比对。在systemverilog中,多了一个program,作用和module有些类似,是专门用来编写测试bfm/monitor的。
按照 IEEE Std 1800-2012 § 3.4 & § 24的描述,program和module有几点不同:
- cannot cannot contain always procedures, primitive instances, module instances, interface instances (virtual interface and port interface is allowed), or other program instances.
- specifies scheduling in the Reactive region. This prevents race conditions.
- has an extra system task $exit, which terminates the program instances that calls it. The simulation will terminate when all program instances have exited.
除了一些使用上的限制外,自动退出机制需要额外注意。
在systemverilog中,可以采用基于class的测试代码来取代program。因为program是源于Vera的历史包袱(https://blogs.mentor.com/verificationhorizons/blog/2009/05/07/programblocks/)有着众多的不方便。
总的来说,轻量级的验证环境,用program是比较合适的。复杂一些的还是需要基于面向对象的方法。