Home Specman / e 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 :

» Using Constrained-Random Verification with Legacy Testbenches

One of SystemVerilog's noticeable features is that it is basically a "design language" that has been extended with verification capabilities. This might be an advantage or not, depending on who you're asking, but obviously, if you only want to use a...

» The Big Picture

Great verification engineers know the secret - if they want to be successful they must also understand the essence of the entire chip design flow, from concept to working samples. Here are some great videos that will help you see the big picture a...

» The Cost Of Verification

We spend about one third of our lives in bed, right? doesn’t it make sense then to buy a good bed and not a cheap one? The same can be said for your verification tools as you spend so much of your project time on verification. Buying cheaper tools...

» To Do List 2010

Introducing Philip Americus - a new guest blogger here on Think Verification. Phil is an ASIC veteran who's worked with every phase of ASIC design - from initial concept to tapeout, with an emphasis on verification, including management of both HW...

» Inside The Verifiers Cubicle

Have you ever watched ? You know, the show where James Lipton hosts famous actors in front of a small audience of students? Remember? Anyway, this is actually one of my favorite shows on TV (and there aren’t that many really). Towards the end of...

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.