Friday, March 02, 2012

Data Declarations - Examples

Data Declarations - Examples

Examples for Data Declarations

Ethernet

Example using Casting

//casting the datatypes in System Verilog for Ethernet packet

module type_casting_example();
int data = 0
initial
begin
$display("********--------***When data is int type, o/p is*****--------********");
$monitor("\n@%g Time cycle, packet = %d, int type",$time,data );
#1 data = shortint'( 7.3 * 1.3);
$display("\n***--Now the packet is changed to shortint type, though Real values are used*****");
#2 $display("\n********--------********--------*********--------********--------*********");
#1 $finish;
end
endmodule

Output in VCS

********--------***When data is int type, o/p is*****--------*******
@0 Time cycle, packet = 0, int type

******--Now the packet is changed to shortint type, though Real values are used*****
@1 Time cycle, packet = 9, int type
********--------********--------*********--------********--------*********

No comments:

Post a Comment

Popular Posts