2
\$\begingroup\$

I'm trying to define a string in VHDL with a pair of double quotes in the string itself. However I am unable to do so because the IDE (Xilinx ISE 14.7) only recognizes what's in-between the first pair of double quotes as the string. Is there some kind of delimiter or escape character I can use?

Here's the string definition:

constant AT_WKMOD       : string(1 to 15):="AT+WKMOD="SMS""&CR;

If I try:

constant AT_WKMOD       : string(1 to 15):="AT+WKMOD=/"SMS/""&CR;

It does the same thing. The last thing I tried was:

constant AT_WKMOD       : string(1 to 15):="AT+WKMOD=\"SMS\""&CR;

Which gives the following error upon synthesis:

Non-printing character is not allowed in extended identifier.

\$\endgroup\$
  • 1
    \$\begingroup\$ IEEE Std 1076-2008 15.7 String literals "A string literal has a value that is a sequence of character values corresponding to the graphic characters of the string literal apart from the quotation mark itself. If a quotation mark value is to be represented in the sequence of character values, then a pair of adjacent quotation marks shall be written at the corresponding place within the string literal. ... The length of a string literal is the number of character values in the sequence represented." \$\endgroup\$ – user8352 Mar 17 '19 at 7:45
  • 3
    \$\begingroup\$ constant AT_WKMOD: string (1 to 15) := "AT+WKMOD=""SMS""" & CR; \$\endgroup\$ – user8352 Mar 17 '19 at 7:54
  • \$\begingroup\$ @user8352 Thank you! That worked. \$\endgroup\$ – Simeon R Mar 17 '19 at 9:07
  • 1
    \$\begingroup\$ Apart from doubling the quotes (the right method) you can always create a string by concatenation, "AT+WKMOD=" & '"' & "SMS" & '"' & CR; as you are already doing with CR. Note '"' is a character literal, i.e. a " enclosed in a pair of 's \$\endgroup\$ – Brian Drummond Mar 17 '19 at 12:52
5
\$\begingroup\$

Since answers should be written as answers and not comments, I'll summarize here:

IEEE Std 1076-2008, section 15.7 - String literals

A string literal has a value that is a sequence of character values corresponding to the graphic characters of the string literal apart from the quotation mark itself. If a quotation mark value is to be represented in the sequence of character values, then a pair of adjacent quotation marks shall be written at the corresponding place within the string literal. ... The length of a string literal is the number of character values in the sequence represented."

For example:

constant AT_WKMOD: string (1 to 15) := "AT+WKMOD=""SMS""" & CR;

As an alternative, you can always create a string by concatenation, "AT+WKMOD=" & '"' & "SMS" & '"' & CR; as you are already doing with CR. Note '"' is a character literal, i.e. a " enclosed in a pair of 's.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.