In verification activity, many times the requirement comes to choose
specific value of enum variable from command line in either randomization of
transaction class or configuring agent.
System Verilog provides support to pass value of variable of type
int/bit/logic/string from command line using $value$plusargs function but it
does not direct support to pass value of enum variable from command line.
In earlier version of UVM (uvm 1.1d and prior), we can achieve this by
passing string value from command line and manually converting it into enum by writing
code in TB.
Let’s go through example how we can achieve this,
-------------------------------------------------------------------------
-------------------------------------------------------------------------
In UVM 1.2 provides inbuilt facility to convert string into enumerated
value.
In UVM 1.2 library contains uvm_enum_wrapper#(T) class and this class
contains from_name() function.
from_name() function try to convert any string passed as argument into enumerated
value.
If any matching enumerated value found then this function returns 1 else
it returns 0.
-------------------------------------------------------------------------
-------------------------------------------------------------------------
Let’s go through example,
-------------------------------------------------------------------------
-------------------------------------------------------------------------
In above approach from_name() function can convert only one string at a
time.
Now think about scenario where to randomize variable of enum user wants
to select from multiple values. But above approach works fine only with one
string value.
UVM provides uvm_split_string() function which splits the
string based on a delimiter and returns a queue with sub string.
-------------------------------------------------------------------------
-------------------------------------------------------------------------
Now after getting queue of substring from uvm_split_string() function, user can pass one one element of substring queue to from_name() function
in some loop and convert it into enumerated value.
Let’s go through example to understand this better,
-------------------------------------------------------------------------
-------------------------------------------------------------------------
Reference:
I know this if off topic but I'm looking into starting my own blog and was curious what all is needed to get setup? I'm assuming having a blog like yours would cost a pretty penny? I'm not very web savvy so I'm not 100% positive. Any suggestions or advice would be greatly appreciated. waterjet cutting edmonton
ReplyDeleteI am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.
ReplyDeletePhp projects with source code
Online examination system in php
Student management system in php
Php projects for students
Free source code for academic
Academic projects provider in nashik
Academic project free download
Very useful. Thank you.
ReplyDeleteIamlinkfeeder
ReplyDeleteIamlinkfeeder
Iamlinkfeeder
Iamlinkfeeder
Iamlinkfeeder
Iamlinkfeeder
Iamlinkfeeder
Iamlinkfeeder
Iamlinkfeeder
Iamlinkfeeder