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


Tutorials



CASTING



The cast_assign() system function assigns values to variables that might not ordinarily be valid because of type checking rules.
Syntax : function integer cast_assign(scalar dest_var, scalar source_exp [,CHECK]);

When the cast_assign() system function is called without CHECK, the function assigns the source expression to the destination variable. If the assignment is illegal, a fatal runtime error occurs. When the cast_assign() system function is called with CHECK specified, the function makes the assignment and returns a 1 if the casting is successful. If the casting is unsuccessful, the function does not make the assignment and returns a 0.


EXAMPLE:
class base {

virtual task pri(){
printf(" BASE CLASS STATEMENT\n");
}
}

class EX_1 extends base {
task pri(){
printf(" EX1 CLASS STATEMENT\n");
}
}


program main{
base b;
EX_1 e1;


b = new();
if(cast_assign(e2,b))
printf("casting done \n");
else
printf(" casting failed \n");
e2.pri();
printf(" END OF SIMULATION \n");
}


RESULTS:

casting done
BASE CLASS STATEMENT
END OF SIMULATION

Index
Introduction
Data Types
Linked List
Operators Part 1
Operators Part 2
Operators Part 3
Operator Precedence
Control Statements
Procedures And Methods
Interprocess
Fork Join
Shadow Variables
Fork Join Control
Wait Var
Event Sync
Event Trigger
Semaphore
Regions
Mailbox
Timeouts
Oop
Casting
Randomization
Randomization Methods
Constraint Block
Constraint Expression
Variable Ordaring
Aop
Predefined Methods
String Methods
Queue Methods
Dut Communication
Functional Coverage

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