Leverage on the built-in callback inside vmm_atomic_gen and be productive with DVE features for VMM debug
Posted by Srinivasan Venkataramanan on 7th February 2010
Srinivasan Venkataramanan, CVC Pvt. Ltd.
Rashmi Talanki, Sasken
John Paul Hirudayasamy, Synopsys
During a recent Verification environment creation for a customer we had to tap an additional copy/reference of the generated transaction to another component in the environment without affecting the flow. So one producer gets more than one consumer (here 2 consumers). As a first time VMM coder the customer tried using “vmm_channel::peek” on the channel that was connecting GEN to BFM. Initially it seemed to work, but with some more complex code being added across the 2 consumers for the channel, things started getting funny – one of the consumers received the transactions more than once for instance.
The log file looked like:
@ (N-1) ns the transaction was peeked by Master_BFM 0.0.0
@ (N-1) ns the transaction was peeked by Slave_BFM 0.0.0
.
.(perform the task)
.
@N ns the Master_BFM get the transaction 0.0.0
@N ns the transaction was peeked by Slave_BFM 0.0.0
@N ns the transaction was peeked by Master_BFM 0.0.1
@N ns the transaction was peeked by Slave_BFM 0.0.1
With little reasoning from CVC team, the customer understood the issue quickly to be classical race condition of 2 consumers waiting for same transaction. What are the options, well several indeed:
1. Use vmm_channel::tee() (See our VMM Adoption book http://systemverilog.us/vmm_info.html for an example)
2. Use callbacks – a flexible, robust means to provide extensions for any such future requirements
3. Use vmm_broadcaster
4. Use the new VMM 1.2 Analysis Ports (See a good thread on this: http://www.vmmcentral.org/vmartialarts/?p=860 )
The customer liked the callbacks route but was hesitant to move towards the lengthy route of callbacks – for few reasons (valid for first timers).
1. Coding callbacks takes more time than simple chan.peek(), especially the facade class & inserting at the right place
2. She was using the built-in `vmm_atomic_gen macro to create the generator and didn’t know exactly how to add the callbacks there as it is pre-coded!
Up for review, we discussed the pros and cons of the approaches and when I mentioned about the built-in post_inst_gen callback inside the vmm_atomic_gen she got a pleasant surprise – that takes care of 2 of the 4 steps in the typical callbacks addition step as being recommended by CVC’s popular DR-VMM course (http://www.cvcblr.com/trng_profiles/CVC_DR_VMM_profile.pdf).
Step-1: Declaring a facade class with needed tasks/methods
Step-2: Inserting the callback at “strategic” location inside the component (in this case generator)
This leaves only the Steps 3 & 4 for the end user – not bad for a robust solution (especially given that the Step-4 is more of formality of registration). Now that the customer is convinced, it is time to move to coding desk to get it working. She opened up vmm.sv and got trapped in the multitude of `define vmm_atomic_gen_* macros with all those nice looking “ \ “ at the end – thanks to SV’s style of creating macros with arguments. Though powerful, it is not the easiest one to read and decipher – again for a first time SV/VMM user.
Now comes the rescue in terms of well proven DVE – the VCS’s robust GUI front end. Its macro expansion feature that works as cleanly as it can get is at times hard to locate. But with our toolsmiths ready for assistance at CVC, it took hardly a few clicks to reveal the magic behind the `vmm_atomic_gen(icu_xfer). Here is a first look at the atomic gen code inside DVE.
Once the desired text macro is selected, DVE has a “CSM – Context Sensitive Menu” to expand the macro with arguments. It is “Show à Macro”, as seen below in the screenshot.
With a quick bang go on DVE – the Macros expander popped up revealing the nicely expanded, with all class name argument substituted source code for the actual atomic_generator that gets created by the one liner macro. Along with clearly visible were the facade class name and the actual callback task with clear argument list (something that’s not obvious by looking at standard vmm.sv).
Now, what’s more – in DVE, you can bind such “nice feature” to a convenient hot-key if you like (say if you intend to use this feature often). Here is the trick:
Add the following to your $HOME/.synopsys_dve_usersetup.tcl
gui_set_hotkey -menu “Scope->Show->Macro” -hot_key “F6″
Now when you select a macro and type “F6” – the macro expands, no rocket science, but a cool convenient feature indeed!
Voila – learnt 2 things today – the built-in callback inside the vmm_atomic_gen can save more than 50% of coding and can match up to the effort (or the lack of) of using simple chan.peek(). The second one being DVE’s macro expansion feature that makes debugging a real fun!
Kudos to VMM and the ever improving DVE!
Posted in Callbacks, Debug, Reuse, Stimulus Generation, VMM, VMM infrastructure | No Comments »
Avinash Agrawal, Corporate Applications, Synopsys