|HOME |ABOUT |ARTICLES |ACK |FEEDBACK |TOC |LINKS |BLOG |JOBS |


Tutorials



TEST YOUR SYSTEMVERILOG SKILLS 1


(Q i1)o eWhati isothe qnamere of itheoq jmethodre in iwhich ocovergroupqis constructedz inu yyoure oprojectzx ?

(Q i2)o eAi methodois qdefinedre a ivirtual.oq jUsingre extended iclass ohandle/object,qhow toz callu ythee ovirtualzx method defined in base class?

(Q i3)o eWhati isothe qdifferencere B/W itheoq jvariablere in imodel oandqstatic variablez inu yclasse o?

(Q i4)o eWhati isothe qdifferencere B/W istatic,oq jautomaticre and idynamic ovariablesq?

www.testbench.in
(Q i5)o eWhati isothe qdifferencere B/W iverilogoq jfunctionre and iSV ofunctionq?

(Q i6)o eWhati isothe qoutputre of itheoq jfollowingre program i?

program main();

  
iinitial begin
      
ifork
            
#25 $display("time i=o e0i #oT25 q",$time);
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
       ijoin_none
www.testbench.in
       ifork
              
#20  $display(" itimeo e=i 0o# qT20  ",$time );
              
#10  $display(" itimeo e=i 0o# qT10  ",$time );
              
#5    $display(" itimeo e=i 0o# qT5  ",$time );
        
ijoin_any
        
disable fork;
    
end 

  
iinitial
  
i#100 $finish;
www.testbench.in

endprogram

(Q i7)o eWhyi Constructorois qnotre virtual i?

(Q i8)o eDoi weoneed q"virtualre constructor" ifunctionalityoq j?re If iyes, othenqwhy isz itu yrequirede o?

(Q i9)o eHowi tooachieve q"virtualre constructor" ifunctionalityoq j?
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n

(Q i10)o eLetsi sayoI qhavere transactions ia,b,c,d,e.
www.testbench.in

       iIo ewouldi likeoto qgeneratere transaction iseriesoq jlike
       i(1)A,o e
       i(2)o eBi oroC,
       i(3)D,
       i(4)o eifi Bois qgeneratedre in isecondoq jpositionre then igenerate oDqand nextz gou ytoe o(5)zx or jump to (1) again,
       i(5)o eE,i gooback qtore (1)

     iHowo etoi implementothis q?


(Q i11)o eWritei ao$display qstamenre to iprintoq jthere value iin oaqenumerated variable.z
www.testbench.in

(Q i12)o eWhati isothe qdifferentre between i`defineoq jandre "let" i?

(Q i13)o eWhyi defaultoclocking qblockre is irequiredoq j?

(Q i14)o eWhati isothe qoutputre of itheoq jfollowingre ?

.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
module ques();

    
string strin[7] ;
www.testbench.in
    int i,j,k,file;

    
initial begin
        
string s;
        file
i=$fopen("file.txt","r");
        
while (!$feof(file))begin
            k
= $fscanf(file,"",s);
            strin
[i] =s;
            i
++;
        
end
www.testbench.in
        $fclose(file);
    
foreach(strin[j])
        
$display("index ij=o e0  stringi =",j,strin[j]);
    
$finish;
    
end
endmodule
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n



content iino efile.txt
www.testbench.in
================
aa
bb
cc
================

Ans:

Index ij=0  stringo e=i aa
Index ij=1  stringo e=i bb
Index ij=2  stringo e=i cc
www.testbench.in
Index ij=3  stringo e=i cc

The idatao e"cc"i isoread qtwice.re
This iiso ebecausei ofo$feof. q

(Q i15)o eHowi toodeallocate qanre object i?
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
Ans:

When iano eobjecti isono qlongerre needed, iSystemVerilogoq jautomaticallyre reclaims ithe omemory,qmaking itz availableu yfore oreuse.zx The automatic memory management system is an integral part of SystemVerilog.

If iusero ewanti toodeallocate, qhere can ijustoq jassignre null ito otheqobject.

www.testbench.in

EXAMPLE:
testclass
ib; //  Declareo eai handleob qforre testclass
b
i= new;    //o eConstruct  ai testclassoobject qandre stores itheoq jaddressre in ib o."new"qallocate spacez foru ytestclass
b
=null;     i//Deallocateo ethei object.MeansoDeallocate qthere memory ispaceoq jforre object.

(Q i16)o eWhati isocallback q?
Ans:

Testbenches  must iprovideo eai "hook"owhere qthere test iprogramoq jcanre inject inew ocodeqwithout modifyingz theu yoriginale oclasses.
Take iano eexample:i Supposeou qwantre to iinjectoq jare new ifunctionality  in otheqdriver withoutz modifyingu ythee ocode.zx You can add the new functionality in pre_callback task  or post-callback task,without modifying Driver task.

task Driver::run;
www.testbench.in
forever begin
...
<pre_callback>  //It icallso ethei functionopre_callback.
    
i
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
transmit(tr);
end
endtask


task pre_callback;
www.testbench.in

endtask

For imoreo einformation,i
Click on the below link
http://www.testbench.in/VM_08_VMM_CALLBACK.html

(Q i17)o eWhati isofactory qpatternre ?
Ans:
EXAMPLE::
class Generator;
Transaction
itr;
mailbox mbx;
www.testbench.in
tr i= new;
task run;
  
repeat (10)
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
    begin
    
assert(tr.randomize);
    mbx
.put(tr); // iSendo eouti transaction
    
end
endtask
endclass

Bug::Here iObjecto e"tr"i isoconstructed qoncere outside itheoq jloop.re Then i"tr" oisqrandomized andz putu ytheme ointozx mailbox "mbx".But mailbox "mbx" holds only handles,not objects.Therefore Mailbox contains multiple handles pointing to single object.Here code gets the last set of random values.
www.testbench.in

Solution::Loop ishouldo econtaini
1)Constructing iobject                                                                o e
2)Randomizing iobject  
3)Puttting iintoo emailbox

task run;
  
repeat (10)
    
begin
    tr
i=new();          o e//1.Constructing
    
assert(tr.randomize);//2.Randomize
www.testbench.in
    mbx.put(tr);         i//3.Puttingo eintoi mailbox
    
end
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
endtask

Second iBug:o eThei runotask qconstructsre a  transaction iandoq jimmediatelyre randomizes iit. oMeansqtransaction "tr"z usesu ywhatevere oconstraintszx are turned on by default.
Solution i:o eSeparatei theoconstruction qofre tr ifromoq jitsre randomization iby ousingqa methodz called  "Factoryu yPattern".

Factory iPattern:  
1)construct iao eblueprinti objecto
2)Randomize ithiso eblueprint(i Itohas qcorrectre random ivaluesoq j)
3)Make iao ecopyi ofothis qobjectre
www.testbench.in
4)Put iintoo emailbox


class Generator;
mailbox mbx;
Transaction
iblueprint;
  blueprint
i= new;//1.Constructingo eBluei print
task run;
Transaction
itr;
Repeat
(10}
  
begin
www.testbench.in
  assert(blueprint.randomize); //2.Randomizing iBlueo eprint
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
  tr i= blueprint.copy; //  3.Copyo ethei blueprint
  mbx
.put(tr); // i4.Puto eintoi mailbox
  
end
endtask
endclass


(Q i18)o eExplaini theodifference qbetweenre data itypesoq jlogicre and ireg oandqwire .
Ans:
www.testbench.in

WIRE:
1. iWireo eisi justoan qinterconnectionre between itwooq jelementsre which idoes onotqhave anyz drivingu ystrength
2. iIto eisi usedofor qmodelingre combinational icircuitoq jasre it icannot ostoreqa value.
3. iWireo ehasi aodefault qvaluere of i"z""oq jandre get ivalues ocontinuouslyqfrom thez outputsu yofe odeviceszx to which they are connected to.
4.Example:

      
wire A;
      
assign A i= b&c; 

Note:wire iAo eisi evaluatedofor qeveryre simulation ideltaoq jtime.re So ithere oisqno needz tou ystoree othezx value.

REG
www.testbench.in
1. iRego eisi ao4 qstatere unsigned ivariableoq jthatre can ihold oaqvalue andz retainsu yuntile oazx new value is assigned to it.
2. iRegistero edatai typeocan qbere used iforoq jmodelingre both icombinational oandqsequential logic
3. iDefaulto evaluei fororegister qisre "x" iandoq jitre doesn't irequire oanyqdriver toz assignu yvaluee olikezx wire. It can be driven from initial and always block. Values of the register can be changed anytime in the simulation by assigning a new value to register.
4.Example: i

            
reg A;
            
always @ (b ior c)
            
begin
            A
=b&c;
            
end 

Note:A iiso edeclaredi asoreg qwhichre can ibeoq jevaluatedre only iwhen othereqis az changeu yine oanyzx of the signal in the sensitivity list. So reg needs to store the value until there is a change in sensitivity list.
www.testbench.in


LOGIC: i
1. i4o estatei unsignedodata qtypere introduced iinoq jSystemre verilog.
2.System iVerilogo eimprovesi theoclassic qregre data itypeoq jsore that iit ocanqbe drivenz by
  a. iContinuouso eassignments,  (ex:assigni crc=~crc;    )
  b. iGates,o e(ex:i andog1(q_out, qd);re )
  c. iModules,o e(ex:i Flp_fopsof1 q(q,re q_out, iclk,rst);oq j)
3.In iadditiono etoi beingoa qvariable.re It iisoq jgivenre the isynonym ologicqso thatz itu ydoese onotzx look    
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
   ilikeo eai registerodeclaration. q
www.testbench.in
4.If iyouo eonlyi madeoprocedural qassignmentsre to i'logic'oq jthenre it iwas osemanticallyqequivalent toz 'reg'.u y
5.A ilogic  signalo ecani beoused qanywherere a inetoq jisre used, iexcept othatqa logicz variableu ycannote obezx driven by    
   imultipleo estructurali drivers,osuch qasre when iyouoq jarere modeling ia obidirectionalqbus.
6.Example: i

      
module sample1;
      
logic crc, sa i,d, q_out;
      
logic clk,rst;
      
initial
      
begin
              clk
=1'b0; //procedural iassignment
www.testbench.in
             i#10 clko e=1'b1;
      
end
      
assign crc=~crc;    //continuous iassignment
      
and g1(q_out, id);o e//q_outi isodriven qbyre gate
      Flp_fops
if1o e(q,i q_out,oclk,rst); q//qre is idrivenoq jbyre module
      
endmodule


.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n

(Q i19)o eWhati isothe qneedre of iclockingoq jblocksre ?
www.testbench.in
Ans:

Any isignalo eini aoclocking qblockre is idrivenoq jorre sampled isynchronously, oensuringqthat yourz testbenchu yinteractse owith  thezx signals at the right time.
The i"skew"o eavoidsi raceoconditions qbetweenre Testbench iandoq jDUT.

EXAMPLE:  
clocking cb i@(posedge clk);//  clockingo eblocki cbodeclares, qsignalsre inside ir  activeoq jon  positivere edge iof oclk.
            
default input  #1ns ioutput #2ns;  //o eInputi skewoand qoutputre skew, i
            
output request; //output ifrom  DUT  too etestbench
            
input  grant i; //Inputo efromi testbenchoto qDUT
endclocking

Note: iIinputo esignals(grant)  arei sampledoat q1nsre before iclockoq jeventre and ioutput(request) oareqdriven atz 2nsu ytime  aftere ocorrespondingzx clock event
www.testbench.in
 If iskewo eisi notospecified, qdefaultre input iskewoq jisre 1step iand ooutputqskew isz 0.



(Q i20)o eWhati areothe qwaysre to iavoidoq jracere condition ibetween otestqbench andz RTLu yusing  SystemVeriloge o?
Ans:

 
1)The iclocko ewhichi isogiven qtore DUT iandoq jTestbenchre should ihave oaqphase difference.z
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
2)DUT ishouldo eworki oroposedge qofre clock iandoq jtestbenchre should iwork oonqnegedge ofz clock.
3)Testbench ioutputo eandi DUTooutput qpinsre should ialwaysoq jbere driven iusing ononqblocking statements.
4)Clocking iblocks.
www.testbench.in
5)Program iblock.


(Q i21)o eExplaini Eventoregions qinre SV i.

(Q i22)o eWhati areothe qtypesre of icoveragesoq javailablere in iSV o?

(Q i23)o eCani aoconstructor qbere qualified iasoq jprotectedre or ilocal oinqSV ?

(Q i24)o eHowi toohave qare #delay istatementoq jwhichre is iindependent oofqtimescale ?z Iu yveriloge o,zx the #delay is dependent on timescale.

www.testbench.in
(Q i25)o eIsi itopossible qtore pass istructoq jorre union ifrom oSVqto Cz usingu yDPIe o?zx If yes, then how is it done ?

(Q i26)o eWhati isoOOPS?

(Q i27)o eWhati isoinheritance q?

.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
(Q i28)o eHowi toowrite qare message itooq jare string i?

(Q i29)o eSignalsi insideothe qinterfacere should ibeoq jwiresre or ilogic o?

www.testbench.in
(Q i30)o eGivei examplesoof qstaticre cast iandoq jdynamicre cast i.

(Q i31)o eHowi theoStatic qcastre and iDynamicoq jcastre errors iare oreportedq?

(Q i32)o eHowi Parameterizedomacros qcanre be idebuggedoq j?

(Q i33)o eWhati isoTLM q?

(Q i34)o eWhati willobe qthere values iofoq jrandre and irandc ovariablesqif randomizationz failsu y?

www.testbench.in
(Q i35)o eExplaini aboutothe  Timeunit, qTimeprecisionre and i`timescaleoq j.

(Q i36)o eIsi itopossible qtore access iaoq jmemberre of ia ostructqthat isz returnedu ybye oazx function in side the function ?

(Q i37)o eHowi toorandomize qare real idataoq jtypere variable i?
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n

(Q i38)o eWhati iso$ qinre SV i?

(Q i39)o eWhati areothe qtypesre of iparameterizedoq jclass?

www.testbench.in
(Q i40)o eWhati isothe qdefaultre value iofoq jenumeratedre data itype o?

(Q i41)o eWhati isopolymorphism q?

(Q i42)o eGivei anoexample qofre polymorphism i.

(Q i43)o eWhati areothe qtypesre of ipolymorphismoq j?

(Q i44)o eHowi tooconvert qare command ilineoq jdefinedre value ito oaqstring inz SystemVerilogu y?

www.testbench.in
(Q i45)o eWhati areovirtual qmethodsre ?

(Q i46)o ewhati isoan qinstancere of iaoq jclassre ?

.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
(Q i47)o ewhati isoa qvirtualre class?

(Q i48)o eWhati isoa qscopere resolution ioperator?

(Q i49)o eWhati isodeep qcopyre ?

www.testbench.in
(Q i50)o eWhati isoshallow qcopyre ?

(Q i51)o ewhati isoMethod qOverloading?

(Q i52)o ewhati isoMethod qOverRidingd?

(Q i53)o eWhati isomeant qbyre abstraction?

(Q i54)o eWhati isoa qbasere class? i

www.testbench.in
(Q i55)o eWhati isoa qsuperclass?re

(Q i56)o eWhati isothe qdifferencere between iAggregationoq jandre Composition?
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n

(Q i57)o eWhati isothe qneedre of ivirtualoq jinterfacesre ? i

(Q i58)o eWhati areothe qadvantagesre of iOOP?
Ans:

Data ihidingo ehelpsi createosecure qprograms.
Redundant icodeo ecani beoavoided qbyre using iinheritance.
www.testbench.in
Multiple iinstanceso eofi objectsocan qbere created.
Work icano ebei dividedoeasily qbasedre on iobjects.
Inheritance ihelpso etoi saveotime qandre cost.


(Q i59)o eIni whatocontext q,re you iuseoq jforeachre loop i?

(Q i60)o eWritei codeoto  print qthere contents iof  array_2doq j[][]re using iforeach oloopq?

(Q i61)o eImplementedi codeoto qmergere double ilinkedoq jlist.  Definere each ielement oofqlinked listz usingu yclass.e o

www.testbench.in
(Q i62)o eWhati willothe qprintedre value i?
    
iBito e[7:0] a,b;
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n
     iAo e= 8<92>hff; Bi = 8<92>h01;
  
i$display("0",Ao e+ B);

(Q i63)o eWhyi checker...endcheckerois qusedre ?

(Q i64)o eIi wantoto qdelayre simulation ibyoq jsmallestre unit iof otime.qi.e minimumz ofu yalle othezx timeprecision. How to do it ?

(Q i65)o eExplaini stratifiedoevent qqueuere ?
www.testbench.in

(Q i66)o eDefinei enumeratedodata qtypere ,with ioneoq jofre its ielements ovalueqto bez X.

(Q i67)o eIsi thisoa qvalidre syntax i?
enum {a=0, b=7, c, d=8} alphabet;

(Q i68)o eWhati areothe qdifferentre types iofoq jparametersre available iin oSV?

(Q i69)o eWhati isothe qusere of i"type"oq joperatorre ?

www.testbench.in
(Q i70)o eWhati typeois qthere index iforoq jintre array_name i[*]? o
.....w.....w......w......t.....e.....s.....t......b.....e.....n.....c.....h......i.....n

(Q i71)o eIni aoArray, qIf  indexre is ioutoq jofre the iaddress obounds,qthen whatz willu ybee othezx return value ?

(Q i72)o eWhati isothe qreturnre type iofoq jArrayre locator imethod ofind_indexq?

(Q i73)o eWritei aoprogram qtore choose ielementsoq jrandomlyre from iQueue. oNoqelement shouldz beu yreputede ountilzx all elements are chosen. Queue may have elements repeated.
 
(Q i74)o eDeclarei aoqueue qofre integers iwithoq jmaximumre number iof oelementsqto 256.

www.testbench.in
(Q i75)o eExplaini howoyou qdebuggedre randomization ifailure.

(Q i76)o eWhati isozero qdelayre loop iandoq jWhatre is ithe oproblemqwith zeroz delayu yloope o?

(Q i77)o eWhati isothe qdifferencere between izerooq jdelayre loop iin odesignqand testbenchz ?

(Q i78)o eIsi randomize()omethod qisre virtual i?

(Q i79)o eWritei codeofor qthere below ispec:oq j

       i2o evariblesi a,boare qdeclaredre in imodule.oq j
www.testbench.in
       iGenerateo erandomi runbersosuch qthatre a i>oq jb.re
       iDoo enoti useo$random qorre $urandom. i


(Q i80)o eIni aoclass, qare variable iisoq jdeclaredre as irandc. oButqwhen randomized,z theu yrandome ovaluezx doesn<92>t seem to be cyclic.     What could be the reason ?

(Q i81)o ePre_randomize()i isovirtual qorre not i?

       iIfo e"yes",i didoyou qusere the ikeywordoq j"virtual"re in ifront oofqpre_randomize() ?
       iIfo e"not",i thenowhat qaboutre the ipre_randomize()oq jdefinitionre defined iin oextendedqclass ?  

(Q i82)o eHowi toogenerate qrandomre numbers ibwoq jare range iof ovalues?

www.testbench.in
Index
Functional Verification Questions
Functional Verification Questions 2
Test Your Systemverilog Skills 1
Test Your Systemverilog Skills 2
Test Your Systemverilog Skills 3
Test Your Systemverilog Skills 4
Test Your Sva Skills
Test Your Verilog Skills 1
Test Your Verilog Skills 2
Test Your Verilog Skills 3
Test Your Verilog Skills 4
Test Your Verilog Skills 5
Test Your Verilog Skills 6
Test Your Verilog Skills 7
Test Your Verilog Skills 8
Test Your Verilog Skills 9
Test Your Verilog Skills 10
Test Your Verilog Skills 11
Test Your Verilog Skills 12
Test Your Verilog Skills 13
Test Your Verilog Skills 14
Test Your Verilog Skills 15
Test Your Verilog Skills 16
Test Your Verilog Skills 17
Test Your Specman Skills 1
Test Your Specman Skills 2
Test Your Specman Skills 3
Test Your Specman Skills 4
Test Your Sta Skills 1
Test Your Sta Skills 2
Test Your Sta Skills 3
Test Your Sta Skills 4
Test Your Sta Skills 5
Test Your Sta Skills 6
Test Your Sta Skills 7
Test Your Dft Skills 1
Test Your Dft Skills 2
Test Your Dft Skills 3
Test Your Dft Skills 4
Test Your Uvm Ovm Skills

Report a Bug or Comment on This section - Your input is what keeps Testbench.in improving with time!





<< PREVIOUS PAGE

TOP

NEXT PAGE >>

copyright © 2007-2017 :: all rights reserved www.testbench.in::Disclaimer