<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>A Note on the Parsing of Complete VHDL-?OO2</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Dept. of Information Systems, Faculty of Information Technology, Brno University of Technology</institution>
          ,
          <addr-line>BoZetechova1, 612 66 Brno</addr-line>
          ,
          <country country="CZ">Czech Republic</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>eywords: computer languages</institution>
          ,
          <addr-line>EBNF, LALR, parsing, VHDL</addr-line>
        </aff>
      </contrib-group>
      <fpage>245</fpage>
      <lpage>248</lpage>
      <abstract>
        <p>The paper gives a brief view on the process of analysis and adapting formal description of the current version of the VHDL language, described by VHDL 1076-2002standard. The work searchesthe possibility to build the effective syntax analyser of the entire language by using automatic tools for parsers generation.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>VHDL is the acronym for VHSIC Hardware Description Language. It is a
language that can be used to describe the structure of digital circuits or even
behavior of the hardware designat the various levelsof abstraction. It is a powerful
language,but always restricted by the capabilities and aim of used tools.</p>
      <p>The fundamental motivation for the construction of the complete VHDL
parser is to be able to analyzearbitrary VHDL sourcecode without dependency
on the sourcetool. In past, there were introduced some methods (..S. [a]), but
only for very old version of VHDL standard. The concrete utilization is in
automatic or semi-automatic VHDL-based modules generation that representsthe
user components design.</p>
    </sec>
    <sec id="sec-2">
      <title>VHDL</title>
    </sec>
    <sec id="sec-3">
      <title>Language</title>
      <p>
        The VF{DL-2002 standard (see [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]) describing VHDL using EBI{F consists of
approximately 800 productions. Due to the repeated revisionsand extensiveness
of the description, the description is inconsistent on many places and contains
errors. Used extensions allow to describe VHDL language in an advantageous
and economical way, unfortunately the1, include both the syntax and also
semantic features in the actual syntax dcscription. These semantic features are
not supported by parser generatorsnor other tools for dealing with grammars.
      </p>
      <p>The forrn of the extension is given by italicized prefix of the nonterminal's
name.l'he prefix carriescrucialsernanticinforrnation.For example,nonterminals
type-name and subtypename are both syntactically equivalent to name, but
carry the semantic information about the context in which they were derived.
In this paper, call this extension semant'iccondi,t'ion.</p>
      <p>
        Semantic conditions are unusual in parsing theory (see [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] and/or [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]) and
turn up some questionsabout the reliition betweenpoor syntax and on the other
hand the semantic analysiswhen describing the VHDL language:
- Is it possible to describepoor VHDL syntax with context-free grammar?
- Is it possible to expressthe semantic conditions in current standard in
another way to obtain LALR grammar that can be simply processedby parser
generator tools?
- Is there any other way to parse entire VHDL?
      </p>
    </sec>
    <sec id="sec-4">
      <title>Experiments with Parsing</title>
      <p>In the case of our fundamental research,the existing EBNF description of the
VHDL-2002 languagehasbeentranscripted into the input grammar for the Bison
tool. The semantic conditions were left unchangedin this step.</p>
      <p>The second part of the transformation had to separate the syntax part of
the description from the semantic information. All nonterminals with italicized
prefixeswere renamedonto original nameswithout theseprefixes.In this moment
the grammar stopped to remember the context of transformed nonterminals, this
context has to be added later.</p>
      <p>The context had previously influencedthe selectionprocessof currently used
rule when deriving sentential form by parsing the input VHDL source. The
consequenceis that the transformed grammar became ambiguous due arisen
reduce/reduce conflicts. The basic task is to eliminate the ambiguity in the
grammar and simultaneously preserve the ability of the grammar to generate
the entire VHDL-2002. The grammar constructed by standard rewriting of the
EBNF contains 743 productions, 78 shif[/reduce conflicts and foremostly 579
reduce/reduceconflicts.</p>
      <p>The huge ambiguity in VHDL grammar is solved in two independent ways.
The former usesconditional building of syntax tree in the processof syntax
analysis. For making decisionabout the next advanceof its production there is used
some semantic knowledge acquired by the analysis of already processedsource
code. The latter way usesconsecutivemerging of all corresponding conflicting
syntactic categoriesinto one. This way consecutivelyeliminates ambiguities but
it alsoremovesthe original semantic dependenciesestablishedin the VHDL-2002
standard.</p>
      <sec id="sec-4-1">
        <title>3.1 Conditional Building of the Syntax Tbee</title>
        <p>This method of semantic conditions elimination utilizes inserting of new
auxiliary terminal symbols to the input of the parser.It means that the output of the
lexical analyser is not directly connectedto the input of the parser but there is an
A Noteon theParsingof CompleteVHDL-2002
auxiliary generator that they are connectedthrough. This generator is tightly
bound to the semantic analyser and syntactic analyser and during analysis it
inserts auxiliary terminals at the right placesin the input streani of tokens
(simplified schemaof such analyseris shown on the figure 1). The binding between
auxiliary generator and parser has to be created as special semantic actions in
the parser code.</p>
        <p>Legend: ----)- Common Dataflow</p>
        <p>- - L- Auxiliary Dataflow</p>
        <p>The auxiliary terrninals are inserted in the grammar immediately after
conflicting (really only after conflicting not all semantically conditioned)
nonterminals originalll' containing semantic conditions. Each inserted terminal has its
name deduced from this semantic condition. Consequentlyduring analysis, if it
is detected such a nonterminal is in progress,the auxiliary terminal generator
is activated. The decision whether insert an appropriate auxiliary terminal or
not is basedon the information provided by the semantic analyser.For example,
there is shorvna solution of conflicts in part of VHDL-2002 grammar containing
nonterminals type-rame and sub typename in the Example l.</p>
        <p>Erample 1. Solution of the typical reduce/reduceconflict in VHDL grammar.
The symbols -TYPE-and -SUBTYPEa-re the new auxiliary terminals.
subtype-declaration : SUBTYPE1d IS subtype_lndicatlon , ;,
subtype-indication =&gt; . .. :+ type_mark
type-mark : nane _TYPE_</p>
        <p>I name
-SUBTYPEreport-statement : REP0RTexpression t . tt
e x p r e s s i o n + . . . + prinary
primary : name
;
U</p>
        <p>There was eliminated all the reduce/reduceconflicts in the VHDL
grammar using this rnethod. But prnctical usability of this method has not been yet
verified becauseit needs a working basic semantic analyser providing sufficient
information to the auxiliary generator. However, the semantic analysis was not
the main focus of this researchphase and will be handled in the future.</p>
        <p>This method seemsto be a good candidatefor the constructionof a complete
analyser of VHDL, becauseit does not modify original form of VHDL grammar.
Therefore, it may be possible to use it as a base of an universal tool enabling
both simulation and synthesiswithout the need of separateworking with some
VHDL code for simulationsand another VHDL code for svnthesis.
3.2</p>
      </sec>
      <sec id="sec-4-2">
        <title>Creation of an Unambiguous Grammar</title>
        <p>It is certainly the best solution to use an unambiguous grammar as a base of
a parser. Thus, we are working on an unambiguous version of VHDL grammar.
Currently, we have solved about 500 reduce/reduce conflicts and 76 remain for
future work. As a result of this work, there should be an universally usableVHDL
grammar suitable as a baseof standalonesyntactic analyserof VHDL. Because
of the big number of modificationsin the grammar structure, it is supposedt.o
be too awkward as a baseof completeVHDL analyseror synthesistool.</p>
        <p>As in the first approach,here is one big problem too. The grammar is too
complex and eliminating of conflicts is very hard task. In addition, it is not
known whether it is possibleto describeentire VHDL using LALR grammar
or not. There are sonle additionat possibilities like for example generalized LR
parsing provided by Bisorr.but tiresepowerful analysershave generally very poor
performancein caseof complex languageswith many conflicts.
4</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Conclusions</title>
      <p>VHDL is a very complex language. It contains a number of semantic
enhancetnents in its standard syntax definition. From this fact follows that the process
of the universal VHDL parser creation is very hard task. Currently, we havi:
found some \^,'ayswhich may tend to achievethis goal. These ways were briefly
describedin this paper same as someopen problems.</p>
      <p>This work has been supported by MinistrV of Education, Youth and,Sports of
the CzechRepublic arant hISIV'IT2C06008 "Vi,rtual Laboratory of Microprocessor
TechnologyA ppli,cat,ion."</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>IEEE</given-names>
            <surname>Std</surname>
          </string-name>
          1076
          <article-title>-2002(Revision of IEEE Std 1076,2000 Edition)</article-title>
          , IEEE Std,
          <article-title>VHDL L anguage Reference ivlanual</article-title>
          , http :/ /stdsbbs.ieee.org/descr/ 10T6-
          <fpage>2002</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Alfred</surname>
            <given-names>V.</given-names>
          </string-name>
          <string-name>
            <surname>Aho</surname>
            , \lonica
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Lam</surname>
          </string-name>
          , Ravi Sethi, Jeffrey D. Ullman: Com,pi,lersP: r-tnciples, Techniques and rooLs,Addison-!!'esley,
          <year>2006</year>
          , ISBN 0-
          <fpage>321</fpage>
          -.l2gg
          <lpage>0</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Bisort</surname>
          </string-name>
          , GNU T)
          <article-title>a?-segrenerator, Ittp:f f www.gnrr</article-title>
          .org/softwarr:/bison
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Rodrrey</surname>
            <given-names>Farrorv</given-names>
          </string-name>
          , AIec G.
          <article-title>Stanculescu: A VHDL compiler basetlon at</article-title>
          ,tributegrammu,r nt'
          <source>ethorloLogyI.n: Proceedings of the AC\'I SIGPLAN</source>
          <year>1989</year>
          , Aclvl Press. New \brk, 19E9,pp.
          <fpage>120</fpage>
          -
          <lpage>130</lpage>
          ,ISSN 0302-
          <volume>13</volume>
          "
          <fpage>10</fpage>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>