Electronics > FPGA

VCD file identifier length


My apologies for asking here, but since VCD is defined as a part of Verilog it seems the best place.

VCD identifier codes are popularly considered to be single characters. However the 2005 version of the IEEE Verilog spec includes an example where they are two characters:

--- Code: (plain) ---...
b10zx1110x11100 (k
b1111000101z01x {2

--- End code ---

The EBNF spec reads as

--- Code: (plain) ---scalar_value_change ::=
value identifier_code

vector_value_change ::=
b binary_number identifier_code
| B binary_number identifier_code
| r real_number identifier_code
| R real_number identifier_code

identifier_code ::=
{ ASCII character }

vcd_declaration_vars ::=
$var var_type size identifier_code reference $end

vcd_declaration_vars ::=
$var var_type size identifier_code reference $end

--- End code ---

Can anybody confirm that multi-character identifiers are valid, i.e. that the EBNF should read as

--- Code: (plain) ---identifier_code ::=
 ASCII_character { ASCII_character }

--- End code ---

(where ASCII_character is predefined) and does this vary with different versions of the spec? Are there any conventions dictated by the first character etc.?

I've previously written a parser assuming single-character identifiers, but find myself in a position where being able to use two or possibly more would be a big advantage.


In the text box describing VCD file syntax in IEEE 1364-2005 chapter 18, I see

identifier_code ::= { ASCII character }

just as you noted.  With apologies for being tedious, let's break this down based on Section 1.3, Syntactic Description.

* "Lowercase words, some containing embedded underscores, are used to denote syntactic categories. For example: module_declaration." This applies to identifier_code.
* "The formal syntax of the Verilog HDL is described using Backus-Naur Form (BNF)."  That means ::= is the symbol derivation rule.
* "Braces ({}) enclose a repeated item unless it appears in boldface, in which case it stands for itself. The item may appear zero or more times; the repetitions occur from left to right as with an equivalent left-recursive rule."  So I take that as a yes. { ASCII character } means zero or more ASCII characters in sequence.  In this case, I would hope they intended one or more ASCII characters in sequence...I also see the example you're referring to with the 2-character identifier code.

IEEE 1364-2001 is the same in regards to the above, and it too has an example with a 2-character identifier code.

IEEE 1364-1995 has similar contents in the Syntactic Description section and contains the example with a 2-character identifier code, but it lacks the line

identifier_code ::= { ASCII character }

in the text box describing the VCD file syntax.  So maybe that's the standard body's attempt to clarify that multiple characters are allowed in identifier codes.  IEEE 1364-1995 also contains the paragraph quoted below, which appears to be unchanged in the 2001 and 2005 versions of the standard.

--- Quote ---The value change dumper generates character identifier codes to represent variables. The identifier code is a code composed of the printable characters that are in the ASCII character set from ! to ~ (decimal 33 to 126).
--- End quote ---

I just wrote a program that dumps output to a VCD file, and I used two-character identifier codes in order to be able to output more than 94 different variables.  GTKWave had no problem with the file that I generated.  I just did the "Excel Columns" thing but with ASCII values 33–126, if that makes sense: !!, !", !#, etc.  There does not appear to be anything in the standard constraining the first character.  Indeed, I wish it would be more explicit on these points.  For example, is there a maximum identifier length?  Granted, I only skimmed tiny portions of the standard that seemed relevant to your question and may have missed one or more things.

Maybe the popular conception of single character identifier codes is down to most people needing 94 or fewer variables coupled with either "good enough" philosophy, not reading the standard, or simply not thinking about it.

Thanks for that, I think we're in broad agreement: there's a glitch in the specs which can trip the unwary.

Apropos identifier lengths and considering the age of the technology, my suspicion is that records were originally intended to fit on 80-column cards, possibly with a 72-column restriction so that the final 8 could be used for a sequential number. It certainly wouldn't be the first time that I've come across that sort of thing, and while I don't claim vast experience one company I've been involved with had a history of using netlists as their primary design record reaching as far back as the mid 1960s, hence https://homepage.divms.uiowa.edu/~jones/cards/collection/GardnerDenverWireWrapsalmon.jpg etc.



--- Quote from: MarkMLl on August 14, 2023, 04:48:32 pm ---VCD identifier codes are popularly considered to be single characters...

--- End quote ---

I routinely have VCD files generated with two character identifier codes, and have seen this for a long time (ie, like 20+ years).
A single character can only handle 94 unique identifiers; most of my project simulations have more than that.
With two characters you get 94^2 or 8836 identifiers. A couple hundred is the most I have ever seen in a VCD.
I have personally never seen a three character ID code generated but I see no reason that it could not be three or four or more characters.


[0] Message Index

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod