sv&uvm的踩坑案例

案例1:重载场景下对子类赋值失败

base_class(父类)和extend_class(子类)内部都有相同的变量int   var[$];

父类是参数化类,在test这一层通过uvm的工厂机制进行override(type)后,这个类在env这里被实例化,实例化名refm;

在test的run_phase阶段,赋值:env.refm.var.push_back(99);

发现并没有赋值到子类;把子类的var[$]删掉后,子类才能看到这个push进来的00;

另一个问题是,如果子类加了一个变量,再在test这里对这个变量赋值,会报编译错误,说没有在父类找到这个变量;所以推测,外面在赋值的时候其实是对父类已经声明的变量进行赋值。(需要先把父类句柄转换成子类的,就可以了;仿真查找变量,父类和子类其实在不同的内存空间;后面补充个图)(《system Verilog与功能验证》p141:在访问对象的过程中遵循一下规则:通过父类的对象去引用在子类中重写的属性或方法,结果只会调用父类的属性或方法;通过子类对象可以直接访向重写的属性或方法的在子类扩展过程中新增的属性和方法对于父类对象不可见龙子类可以通过super操作符访向父类中的属性和方法,以区分于本身重写的属性和方法。)

解决办法:code stye完善;父子类不能声明相同名字的变量;


案例2:phase退出,但是后面的phase挂住了;

在main phase阶段去调用寄存器模型的seq去执行一些检查;main phase退出后,在shutdown phase又去调用了这个seq,然后一直挂在seq这里;虽然main phase在tc这里退出去了,seq的线程也终止了,但是seq的状态是处于wait_rsp(pending)状态,这个状态并没有被“复位”;导致在shutdown phase再次调用这个seq时被挂住了(一直等不到main_phase阶段的响应?)

解决办法

有一些检查可以集中在shutdown phase,不在main phase进行;(不需要在两个地方都检查)


案例3

Question:
使用Systemverilog,在module中包含其他package出现如下错误:

Error: Unsupported Systemverilog construct

found ‘package’ inside module before ‘endmodule’. ‘package’ inside ‘module’ is not allowed.

Answer:
解决方法如下:
1、有可能是把 include package 写在了module 和 endmodule之间了;需要把 include package写在 module定义之前或endmodule之后;

2、还有一种是在其他模块中少了 endmodule 关键字,这样也会导致这个模块出现这个错误,但实际上不是该模块的问题;


作者: MonkeyPi
链接: https://makerinchina.cn/article_fc3dbcd7a8f2.html
来源: MakerInChina
著作权为原网站(https://makerinchina.cn)所有,转载请注明出处。

解决办法


案例4:一个用例是被包在package里面,里面不能直接使用force对dut内部信号进行操作。

因为package看不到top_tb的层次结构,所以会报错,路径问题。

解决办法:可以采用uvm_hdl_deposit的方式实现对dut内部信号的操作。


案例5:pre_abort调用导致死循环;

UVM可以设定报错多少个UVM_ERROR后(server.set_max_quit_count(200) ),退出仿真(好像也是通过调用UVM_FATAL实现的),然后会调用各个uvm组件的pre_abort方法,去打印一些信息来辅助debug;但是如果在pre_abort里面加了uvm_error且达到200个的话;会导致死循环,不停的进入pre_abort,出不来;

解决办法:pre_abort方法里面,避免报uvm_error


案例6:uvm_callback两次add,调用的地方使用是第一次add的callback。

随后遇到callback的调用问题,导致一直用的是复位前的share_cq_0的base_addr,之所以会这样是因为调用callback的地方一直在调用原来复位的scq_cb,而这个scq_cb又是指向复位前的scq,导致收到中断后,依旧走的是原来的callback,之所以会这样,应该是和uvm的callback机制有关系;可以看到复位后有两个callback,调用callback的地方一直是用的第一个callback(复位之前add的那个);

解决办法

所以考虑要把原来的callback删掉;

但是不好删,因为scq_cb句柄在一个function里面,tc看不到,就不能直接调用下面这个delete去删除旧的scq_cb;所以在rm里面声明了一个句柄保存上一个scq_cb的指针,然后再在tc里面删除;(也可以在rm里面的functuon删除:就是判断一下句柄是否非空;)

callback的打印:

Callbacks Classes

callback的使用流程可参考:UVM——Callback机制(作用、使用步骤实例)_uvm callback-CSDN博客 


案例7

解决办法


案例8

解决办法


案例5

解决办法


案例6

解决办法


案例7

解决办法


案例8

解决办法

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
VC技术内幕第五版.chm Introduction Like many of my colleagues in this industry, I learned Windows programming from Charles Petzold's Programming Windows—a classic programming text that is the bible to an entire generation of Windows programmers. When I set out to become an MFC programmer in 1994, I went shopping for an MFC equivalent to Programming Windows. After searching in vain for such a book and spending a year learning MFC the old-fashioned way, I decided to write one myself. It's the book you hold in your hands. And it's the book I would like to have had when I was learning to program Windows the MFC way. MFC, as you probably already know, is Microsoft's C++ class library for Windows programming. Programming Windows with MFC isn't a book about C++; rather, it's a book about writing 32-bit Windows applications in C++ using MFC rather than the Windows API as the chief means of accessing the operating system's essential features and services. It was written with two kinds of people in mind: Windows API programmers who want to learn MFC Programmers who have never before programmed Windows Whichever camp you fall into, I assume that you know the C++ programming language already and are comfortable with basic C++ idioms such as derived classes and virtual functions. If these assumptions are true, you're ready to begin climbing the hill that is MFC programming. Even veteran Windows programmers frequently find MFC code confusing the first time they see it, in part because of the presence of code created by the MFC code-generating wizards in Visual C++ and in part because of the countless lines of code hidden away in MFC classes such as CFrameWnd, CDocument, and CView. That's why this book takes a rather unusual approach to teaching MFC. It begins by having you write MFC code by hand (without the wizards) and by utilizing MFC 1.0-style application architectures—that is, applications that use neither documents nor views. Only after you've mastered the fundamentals and become acquainted with basic MFC classes such as CWnd and CWinApp do I introduce the wizards and teach you how to take advantage of MFC's document/view architecture. Along the way, you build a understanding from the ground up of the message-oriented nature of Windows and of key components of Windows itself, such as the Graphics Device Interface (GDI). I believe that this approach makes learning MFC not only less intimidating, but also more enjoyable. I think that you'll agree once you've worked your way through the book and can look back on the learning experience from the standpoint of a knowledgeable Windows programmer. Programming Windows with MFC is divided into four parts. Part I introduces the core tenets of MFC and Windows programming, beginning with a simple "Hello, MFC" application and introducing, one by one, menus, controls, dialog boxes, and other application building blocks. Part II builds on the foundation laid in Part I with a detailed look at the document/view architecture. In particular, Chapters 9, 10, and 11 reveal much of the "magic" behind documents and views and explain not only how to write basic document/view applications but also how to implement some not so basic features such as split-window views of a document and print previews. Part III covers some of the more advanced features of Windows and MFC—features such as color palettes, bitmap handling, and multiple threads of execution. In Part IV, you'll learn how MFC wraps its arms around COM, OLE, and ActiveX and how to write COM-enabled applications and software components. By the time you're finished with Chapter 21, you'll be well versed in the art of 32-bit Windows programming using MFC. And you'll have prodigious amounts of sample code to draw from when it's time to strike out on your own and write your first great Windows application. What's New in the Second Edition Those of you who read the first edition of this book will notice two rather obvious changes in the second edition. First, this edition contains seven new chapters. One is devoted to the MFC view classes; another covers the MFC collection classes; one introduces MFC file I/O and serialization mechanisms; and four cover the relationship between MFC and COM. MFC is not the general-purpose COM framework that the Active Template Library (ATL) is, but MFC makes certain types of COM programming exceptionally easy. For example, MFC greatly simplifies the task of writing ActiveX controls, and it makes writing Automation servers—programs that use COM to expose their functionality to scripting clients—a breeze. The second major change in this edition has to do with wizards. The first edition didn't cover the MFC wizards at all. The second edition uses hand-generated code in Chapters 1 through 3 but then shifts gears and begins using AppWizard and ClassWizard in Chapter 4. Why the change of heart? I still believe that code-generating wizards are an impediment to learning and should be used only by knowledgeable programmers, but I've also come to realize that in the real world, MFC programmers use the wizards. For certain tasks—writing ActiveX controls, for example—it doesn't make sense not to use the wizards. So after much deliberation, I decided I would be remiss not to cover them. Despite the new material regarding wizards, however, this is not—and never will be—a book about clicking buttons in AppWizard. After introducing a fundamental skill, such as how to write a message handler with ClassWizard, I thereafter let the source code do the talking and assume that you can figure out how the source code was created. Keep in mind that the wizards never do anything you can't do yourself, so it's perfectly feasible to type in every source code listing by hand if you'd like to. The downside to using wizards in a book that teaches MFC programming is that they produce code that isn't fit to publish. The first edition of this book included printed listings for each and every source code file. This one does not. It contains printed copies of relevant source code files and provides the others on CD. Why? Because printing a source code file that's 50 percent meat and 50 percent fat adds bulk to a book without adding content. Some of the code produced by the MFC AppWizard in Visual C++ 6.0 won't even compile. (For details, see Chapter 4.) I'm not very proud of the parts of my book that the wizards created, because those portions are littered with arbitrary blank lines, comments that lack consistent style, and unnecessary functions. For someone who takes pride in writing concise, readable sample code, wizard output is a bitter pill to swallow. Nevertheless, wizards represent the new world order in Windows programming, and they're something that you, I, and everyone else must get used to. It's a shame that the Visual C++ team won't give us real wizards to play with instead of the toys that they pass off as wizards today. Until they do, we must make do with what we have. What's On the CD The CD that accompanies this book contains source code and executables for all the sample programs presented in the book. All samples were written and compiled with Visual C++ 6.0 and MFC 6.0 and tested on various Win32 platforms. Unless otherwise noted, all are compatible with Windows 98, Windows NT 4.0, and Windows 2000. Most are also compatible with Windows 95 and Windows NT 3.51. You can copy the contents of the CD to your hard disk by running the setup program found in the CD's root directory, or you can retrieve the files directly from the CD's \Code directory. The \Code directory contains one subdirectory for each chapter of the book—Chap01, Chap02, and so on. Inside these subdirectories you'll find the sample programs. Each set of source code files is accompanied by a release-build EXE as well as a Visual C++ workspace (DSW) file that you can open with Visual C++'s Open Workspace command. From Me to You (and You to Me) From the day in 1995 when I began writing the first edition of Programming Windows with MFC, my goal has been to provide C++ programmers with the same kind of timeless, irreplaceable resource that Programming Windows is to C programmers. Whether I've achieved that goal, I'll let you be the judge. I want to know what you think about Programming Windows with MFC, and I particularly want to hear from you if you find mistakes. You can reach me by sending mail to jeffpro@msn.com or by visiting my Web site at www.prosise.com. At that site you'll find up-to-date information regarding the book, a list of errata, and information about other projects that I'm working on. Later this year, I plan to post a brand new chapter on MFC DLLs that you can read and comment on online. With the huge volume of computer books vying for buyers' attention in bookstores today, I know that you could have chosen any number of MFC books besides this one. I thank you for purchasing Programming Windows with MFC, and I sincerely hope you conclude that your money was well spent. Enjoy! Jeff Prosise March 12, 1999

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值