|
|
|

|
|
|
|
|
|

|
|
 |
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. |
|
|

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

|
|
|
|
|
|

|
|
 |
Example - String Literals
|
|
|

|
|
|
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
|
|
|

|
|
 |
Simulator Output
|
|
|

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

|
|
|

|
|
|

|
|
|
|
|
|

|
|
|
|
|
|

|
|
Copyright © 1998-2025 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|