DVCon US 2018 论文分享

写在前面:此篇论文是DVCon US 2018年的一篇论文:UVM Verification Environment Based on Software Design Patterns,主要介绍了在开发UVM验证环境中使用软件设计模式方法,论文相关的重点在本文里给出标记。本文介绍原文中备忘录模式的应用。

  • Abstract

Software design pattern is a technique utilized to tackle a commonly occurring problem in the software development. As a significant part of work done by verification engineers includes coding in an object-oriented language,such as SystemVerilog, many of the encountered challenges are suitable to be resolved applying certain design patterns.Their incorporation into the code provides many benefits, contributing to the code reusability and maintainability, andtherefore improving the overall code quality. Several practical examples appropriate for employing design patterns arepresented in the paper.

《验证芯发现》:软件开发中的设计模式提供了一种解决问题的思路,systemverilog也支持面向对象开发的特性,此篇文章把设计模式的思路运用到验证环境的设计开发中,提升了代码的复用性、可维护性,进而全面提升代码质量

  • Memento(备忘录模式)

Memento is a behavioral software design pattern used to capture the state of an object and restore the object into its previous state. In the software development context,it provides the undo mechanism in the applications,promoting the data hiding and not violating the encapsulation principle. In the verification environment, it is utilized to model the "restore" feature.The device is implemented using multiple power domains -PD1 and PD2, as shownin Figure 1. While PD2 is in operational Run Mode(RM), the block configuration is defined in the appropriate register. When the PD2 enters the low-power mode(LPM), the configuration register behaves as read-only andreading the register results in read value isolation. During the LPM, the RM configuration is stored within always-on PD1.Upon the PD2 LPM exit, the content of the configuration register is restored to the value before the LPM entry.Memento is a good candidate to model the content reversal.

《验证芯发现》:备忘录模式用于存储对象状态,以便程序能够恢复对象的历史状态,备忘录模式可以保持对象的封装性不受破坏。软件备忘录模式一个实际例子就是经常使用的撤销操作(ctrl+z),能够撤销成功,就需要首先备份对象的历史记录,然后再恢复历史信息。文章中给出一个多电源域的设计:两个电源域PD1和PD2,PD1可以认为是一个AO区(always-on),PD2有两种工作模式:工作模式和低功耗模式。当PD2进入低功耗模式前,其配置会存储到PD1中;当PD2恢复到工作模式时,会加载低功耗模式前的配置信息。

The Memento state design pattern defines three main components:

  1. Memento - Represents a container class for the content to be saved and restored.In the example shown in Figure Appendix-1, Memento class contains a single configuration register,with corresponding get/set methods.

  2. Originator - Uses the Memento class to save the current state it is in, as shown in Figure Appendix-2.

  3. Caretaker - Requests from the Originator to save its state. It is aware of all saved states and can request a certain state to be restored, as shown in Figure Appendix-3.

《验证芯发现》:备忘录模式主要包含三个角色:Memento、Originator 和CaretakerMemento用于存储对象的状态;Originator可以创建或恢复一个Memento,上图类中的save_state_to_memento和get_state_from_memnto方法;Caretaker负责管理好备忘录,如上图类中的add和get方法。三者的UML类图如下:

The save and restore operations are demonstrated in Figure 2, with the corresponding log output in Figure 3:

《验证芯发现》:上述的过程如下:

  • run mode,在工作模式下调用Originator的set_state方法设置当前工作状态;

  • LPM Entry,调用Originator的save_state_to_memento方法,创建一个备忘录,并使用Caretaker的add方法记录当前状态对象,并调用Originator的set_state方法设置当前工作状态为低功耗模式。

  • LPM Exit,使用Caretaker的get方法,获取想要恢复的备忘录对象,然后使用Originator的get_state_from_memnto方法,从备忘录中恢复状态信息;


验证芯发现icon-default.png?t=M85Bhttps://mp.weixin.qq.com/s?__biz=Mzg3ODczNDg0NA==&mid=2247483778&idx=1&sn=5768d0328c15d0193d50fb6888e1e4e9&chksm=cf0e7d11f879f407e7c8991884f3621d790d96208ae5233afdf9231298b41ea0b62c225e43c8&token=1266482168&lang=zh_CN#rd 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值