quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif String Literals

A string literal is enclosed in quotes and has its own data type. A string literal must be contained in a single line unless the new line is immediately preceded by a \. Non-printing and other special characters are preceded with a backslash. String literals can also be cast to a packed or unpacked array. SystemVerilog added following special string characters.

   

space.gif

  • \v vertical tab
  • \f form feed
  • \a bell
  • \x02 hex number
   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example - String Literals
   

space.gif


  1 `timescale 1ns/100ps
  2 module string_literals ();
  3 
  4 string  a;
  5 
  6 initial begin
  7   $display ("@ %gns a = %s", $time, a);
  8   a = "Hello Deepak";
  9   $display ("@ %gns a = %s", $time, a);
 10    #1  a = "Over writing old string";
 11   $display ("@ %gns a = %s", $time, a);
 12    #1  a = "This is multi line comment \
" 13           and this is second line";
" 14   $display ("@ %gns a = %s", $time, a);
 15    #1  $finish;
 16 end
 17 
 18 endmodule
You could download file string_literals.sv here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulator Output
   

space.gif

  @ 0ns a =
  @ 0ns a = Hello Deepak
  @ 1ns a = Over writing old string
  @ 2ns a = This is multi line comment
            and this is second line
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com