Home SystemVerilog How To Validate Type-Casting In OVM-e

Search

How To Validate Type-Casting In OVM-e PDF Print E-mail
User Rating: / 0
PoorBest 
Thursday, 24 December 2009 16:37

Before type-casting an e variable ("as_a"), we often want to check the validity of the operation (this is quite similar in concept to $cast in SystenVerilog). The reason is simple, in case the casting operation failed we would end up with a fatal error at run-time that otherwise could have been avoided. But how?

 

Here's one elegant way to do it:

type ttt: [E1=3, E2=10];
extend sys {
 run() is also {
 var x: byte = 3; // try x=7 too
  if x.as_a(ttt) in all_values(ttt) then { out( *** X IS IN RANGE *** ) };
 };
 };

In this small example we were trying to convert (type-cast) x from byte to ttt. The method all_values() returns a list of all possible scalar types (in our case - for type ttt). Try this code with x=3 and with x=7 and see what happens.

 

 
More articles :

» Coverage Driven Thoughts

In today’s short post what I’ll try to do is share with you some of the recent trends and ideas that deal with coverage. I won’t go into much technical detail today in order not to wear you (and myself) out, but really - if I want to be more...

» Verification Documents - Love Them, Hate Them, But You Can't Ignore Them

Verification Plan (or Test Plan) and Coverage Plan are two documents that specify the features to be tested in the verification process. The first document usually lists the DUT features that need to be covered and the latter - the coverage points...

» Read/Write Registers From Everywhere

Here’s something for the less experienced verifiers out there. I’ve been asked to help with this issue several times in the past so I guess some of you will find it useful.

» Top Level Verification - What's The Big Deal?

How to attack your chip from the top? Why is it so difficult to put together a good top level verification plan? Here are a few ideas.

» VMM Hackers Guide - Default Behavior For Your BFM

Here's a short tutorial on how to implement a default behavior for your BFM using VMM. Some protocols require constant activity on their interface even when you don't have any data to transmit. This means you must have a mechanism that drives idle...

Add comment


Security code
Refresh

Copyright © 2017 Think Verification - Tips & Insights on ASIC Verification. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.