<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8479933371391943026</id><updated>2011-12-14T15:33:11.402-08:00</updated><title type='text'>v2kparse</title><subtitle type='html'>All about a Verilog V200x parser project hosted at SourceForge: http://v2kparse.sourceforge.net/</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8479933371391943026.post-1095330174165826661</id><published>2009-12-30T11:16:00.001-08:00</published><updated>2009-12-30T11:45:20.050-08:00</updated><title type='text'>Latest version includes (Synopsys) Liberty File parser</title><content type='html'>I (finally) uploaded an update &lt;a href="https://sourceforge.net/projects/v2kparse"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The most interesting new feature is support for Liberty Files (aka., .lib files).&lt;br /&gt;Upon download, note a slight rearrangement of the directory structure:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    slf/ --- files related to parsing of Synopsys Liberty Files&lt;br /&gt;    ssi/ --- files related to Simple Serialization Interface&lt;br /&gt;    v2k/ --- files related to Verilog parser&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There is also an additional option &lt;code&gt;&lt;b&gt;--gen_xref&lt;/b&gt;&lt;/code&gt; which can be used to generate a module cross reference.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&gt; &lt;b&gt;v2k/bin/analyze&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Usage: analyze --flatten? (--tcl out.tcl)? (--rb out.rb)? (--outf out.f)?&lt;br /&gt;               --only_used? --exit_on_err? (--verbose n)? --abs_paths?&lt;br /&gt;               (--redefn n)? (-E -C?)?&lt;br /&gt;               topModule vlogOpts+&lt;br /&gt;&lt;br /&gt;    --flatten     : stop after flattening .f files.&lt;br /&gt;                  : Useful with "--outf" to capture flat .f&lt;br /&gt;                  : for subsequent processing.&lt;br /&gt;    --tcl out.tcl : dump details in tcl format to "out.tcl".&lt;br /&gt;    --rb  out.rb  : dump details in ruby format to "out.rb".&lt;br /&gt;    --outf out.f  : dump details into flat Verilog .f file "out.f"&lt;br /&gt;                      using only +incdir+, +define+ and file.v.&lt;br /&gt;    --only_used   : only dump files which contained a module&lt;br /&gt;                  :   definition required for linking "topModule".&lt;br /&gt;    --exit_on_err : exit status != 0 if any parse errors.&lt;br /&gt;                      And, no "out.tcl" generated if errors.&lt;br /&gt;    --verbose n   : Verbose messages during linking. "n" is:&lt;br /&gt;                      2 (most verbose) 1 (default); 0 (off).&lt;br /&gt;    --abs_paths   : Make/display all file/directory names absolute.&lt;br /&gt;                      Useful for debugging (the where of) include files.&lt;br /&gt;    --gen_xref    : Generate "topModule.refs.txt".&lt;br /&gt;                      Contains a cross-reference of module references.&lt;br /&gt;    -E            : dump pre-processed files to "file.v.E".&lt;br /&gt;                      Useful for debugging preprocessing issues.&lt;br /&gt;    -C            : do not discard comments when "-E" is specified.&lt;br /&gt;&lt;br /&gt;  vlogOpts is one of:&lt;br /&gt;    file.v&lt;br /&gt;    -f args.f&lt;br /&gt;    -v library.v&lt;br /&gt;    -y library_directory&lt;br /&gt;    +incdir+dir1(+dirn)*&lt;br /&gt;    +define+d(=val)?(+dn(=valn)?)*&lt;br /&gt;    +no_defn+mod1(+modn)*       : specify "mod1" as undefined&lt;br /&gt;                                  (a priori) so no link error.&lt;br /&gt;    +slf+f1.lib(+fi.lib)*       : specify Synopsys Liberty File "f1.lib".&lt;br /&gt;&lt;br /&gt;  NOTE: a .f file can contain entries of the form "${VAR}/foo.v"&lt;br /&gt;        to specify that the value of the environment variable "VAR"&lt;br /&gt;        be used (i.e., replace ${VAR} with ENV['VAR'], in ruby parlance)&lt;br /&gt;        during .f file processing.  This is useful to root file/directory&lt;br /&gt;        locations using an environment variable, rather than hardcoding&lt;br /&gt;        in .f files themselves.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The &lt;CODE&gt;&lt;B&gt;+slf+&lt;/B&gt;&lt;/CODE&gt; option can be used to pass .lib files to resolve any (typically instantiated) library (leaf) or macro cells.&lt;br /&gt;&lt;br /&gt;If any of the &lt;CODE&gt;&lt;B&gt;+slf+&lt;/B&gt;&lt;/CODE&gt; file(s) are actually required to link the design, their filename(s) will be output into the &lt;CODE&gt;&lt;I&gt;out.tcl&lt;/I&gt;&lt;/CODE&gt; file specified using the &lt;CODE&gt;&lt;B&gt;--tcl&lt;/B&gt;&lt;/CODE&gt; option.  The tcl list variable &lt;CODE&gt;slf_used&lt;/CODE&gt; will be used.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8479933371391943026-1095330174165826661?l=v2kparse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/1095330174165826661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8479933371391943026&amp;postID=1095330174165826661' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/1095330174165826661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/1095330174165826661'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/2009/12/latest-version-includes-synopsys.html' title='Latest version includes (Synopsys) Liberty File parser'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8479933371391943026.post-630714828129905135</id><published>2009-03-25T09:59:00.000-07:00</published><updated>2009-03-28T13:12:05.250-07:00</updated><title type='text'>Unscheduled interruption (but a good one)</title><content type='html'>I have been adding a few fixes to the grammar and infrastructure: adding a symbol table and Simple Streaming Interface (SSI, as I call it): a file persistance mechanism.  Hopefully, I'll have these posted next week, in a very alpha-ish state.&lt;br /&gt;&lt;br /&gt;On the interrupt front: during my day job, I do a lot with synthesis and timing/design closure for large ASICs.  I have been looking a lot at design/RTL and netlist quality (QOR) and to the latter: do a lot of manipulation/querying in either the synthesis tool or static timing analyzer, since both those have excellent (Tcl-based) UIs for such.&lt;br /&gt;&lt;br /&gt;However, since those tools/licenses are very few and very $$$, it seemed natural to just strip down the v2kparse stuff for netlist-only type stuff.  I had done an earlier (C++) type project at this &lt;a href="http://nldb.sourceforge.net/"&gt;sourceforge project&lt;/a&gt; and decided to shift gears a bit.  So, I am in the process of revamping that project to use Java and Ruby: let's all say it together: &lt;a href="http://jruby.codehaus.org"&gt;JRuby&lt;/a&gt;!&lt;br /&gt;&lt;br /&gt;At this point, I have the (netlist) and parser infrastructure completed in &lt;a href="http://www.antlr.org"&gt;Antlr&lt;/a&gt; and Java, and have added a JRuby layer around it.  For example: to iterate over a full (hierarchical) module/netlist to find and print (inefficient) instances of sequential cells with constant clocks and/or constant async set/reset pins, you simply:&lt;br /&gt;&lt;br /&gt;&lt;P&gt;&lt;PRE&gt;&lt;br /&gt;#Find important reg pins tied to 0&lt;br /&gt;msg = ": pin tied 0"&lt;br /&gt;top_module.foreach_on_const_net(0) do |conns, val, inst_name|&lt;br /&gt;  conns.each do |conn|&lt;br /&gt;    if conn.isPin&lt;br /&gt;      pin = Pin.new(conn)&lt;br /&gt;      Message.warn(pin.get_name(inst_name)+msg) if pin.get_name =~ /\/([CS]DN|CP)$/&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/PRE&gt;&lt;br /&gt;&lt;br /&gt;Pretty cool!&lt;br /&gt;&lt;br /&gt;Anyway, I want to flush through and post my updates to sourceforce and then update v2kparse shortly.&lt;br /&gt;&lt;br /&gt;Stay tuned.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8479933371391943026-630714828129905135?l=v2kparse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/630714828129905135/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8479933371391943026&amp;postID=630714828129905135' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/630714828129905135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/630714828129905135'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/2009/03/unscheduled-interruption-but-good-one.html' title='Unscheduled interruption (but a good one)'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8479933371391943026.post-3385228160805149140</id><published>2009-01-26T09:29:00.000-08:00</published><updated>2009-02-18T13:53:05.744-08:00</updated><title type='text'>The parse tree evolves</title><content type='html'>The latest release to &lt;a href="https://sourceforge.net/projects/v2kparse"&gt;sourceforge&lt;/a&gt; includes the 1st pass of a full parse tree.&lt;br /&gt;The parse tree classes are under:&lt;br /&gt;&lt;pre&gt; srcs/v2k/parser/tree&lt;br /&gt;&lt;/pre&gt;There are 133 .java source files there; no wonder it's taken a while.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;font-size:85%;color:#000000;"&gt;NOTE: ANTLR does have (automatic) AST (Abstract Syntax Tree) building capability. However, I wanted to experience the &lt;span style="FONT-STYLE: italic"&gt;very&lt;/span&gt; hands-on experience of crafting my own, for this project. Not to worry, there will be many more parsers, for many more &lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Domain-specific_programming_language"&gt;&lt;span style="font-family:arial;font-size:85%;color:#000000;"&gt;DSLs&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:arial;font-size:85%;color:#6633ff;"&gt;&lt;span style="color:#000000;"&gt; to work on; and, automatic AST generation will be more efficient there.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;There is a simple script&lt;br /&gt;&lt;pre&gt; &lt;span style="FONT-WEIGHT: bold"&gt;&gt; bin/ptree&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Error: Must specify at least one "infile".&lt;br /&gt;Usage: v2kparse [options] infile...&lt;br /&gt;&lt;br /&gt;Options:&lt;br /&gt;&lt;br /&gt;-I dir        Add dir (must be readable) to `include file search path.&lt;br /&gt;&lt;br /&gt;-D name       Predefine name as a macro with value 1.&lt;br /&gt;&lt;br /&gt;-D name=defn  Predefine name as a macro with value defn.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Those options are less friendly than the (more common) Verilog style options (as in &lt;code&gt;bin/analyze&lt;/code&gt;; see earlier blogs); but useful for testing.&lt;br /&gt;&lt;br /&gt;Examine the &lt;code&gt;bin/analyze&lt;/code&gt; and &lt;code&gt;bin/ptree&lt;/code&gt; script to see the latter simply defines the constant &lt;code&gt;USEPT&lt;/code&gt; (use parse tree). This constant is detected in file &lt;code&gt;srcs/v2k/parser/Parser.java&lt;/code&gt; and selects which sub-class of&lt;br /&gt;&lt;pre&gt;  public abstract class ASTreeBase&lt;br /&gt;&lt;/pre&gt;to build the tree. There are 2 sub-classes:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;v2k.parser.tree.basic.ParseTree&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;v2k.parser.tree.ParseTree&lt;/code&gt;&lt;/li&gt;&lt;/ol&gt;The 1st: &lt;code&gt;tree.basic.ParseTree&lt;/code&gt; is used to build a simple tree which simply tracks module names and instances. That is used by the &lt;code&gt;bin/analyze&lt;/code&gt; script to glean info appropriate for source file dependency tracking (described in earlier blogs.) The 2nd one: &lt;code&gt;tree.ParseTree&lt;/code&gt; is used for full tree construction, as in the &lt;code&gt;bin/ptree&lt;/code&gt; script.&lt;br /&gt;&lt;br /&gt;So, get your hands dirty playing around with &lt;code&gt;bin/ptree&lt;/code&gt;. And, if you embelish the &lt;code&gt;bin/analyze&lt;/code&gt; script with use of the &lt;code&gt;-DUSEPT&lt;/code&gt; argument to java, then you &lt;span style="FONT-STYLE: italic"&gt;could&lt;/span&gt; also get a full-blown parse tree, and use the more standard Verilog command line arguments, too. However, since the analyze script also uses jruby hooks to generate usable output, by walking the &lt;code&gt;basic.ParseTree&lt;/code&gt;, the jruby scripts would also have to be changed (since the API of the &lt;code&gt;basic.ParseTree&lt;/code&gt; and (full) &lt;code&gt;tree.ParseTree&lt;/code&gt; is slightly different).&lt;br /&gt;&lt;br /&gt;The next phase of the project is to add elaboration...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8479933371391943026-3385228160805149140?l=v2kparse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/3385228160805149140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8479933371391943026&amp;postID=3385228160805149140' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/3385228160805149140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/3385228160805149140'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/2009/01/parse-tree-evolves.html' title='The parse tree evolves'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8479933371391943026.post-5040068465555826750</id><published>2008-09-22T19:23:00.000-07:00</published><updated>2008-09-23T19:45:34.985-07:00</updated><title type='text'>Some Cleanup and Examples</title><content type='html'>In this release uploaded to &lt;a href="https://sourceforge.net/projects/v2kparse"&gt;sourceforge&lt;/a&gt;, I added a fairly comprehensive document and examples: &lt;a href="http://v2kparse.sourceforge.net/includes.pdf"&gt;http://v2kparse.sourceforge.net/includes.pdf&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I ran across a major design flaw, during further testing, where I had been exploiting the &lt;a href="http://www.antlr2.org/javadoc/antlr/LexerSharedInputState.html"&gt;LexerSharedInputState&lt;/a&gt; to handle macro expansion during the processing of &lt;span style="font-family:courier new;"&gt;`macro_name&lt;/span&gt; (i.e. when expanding &lt;span style="FONT-STYLE: italic;font-family:courier new;" &gt;macro_name&lt;/span&gt; into its defined value).&lt;br /&gt;&lt;br /&gt;I was detecting the macro_name, determining/expanding its value and then effectively pushing the expansion into a &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/StringReader.html"&gt;StringReader&lt;/a&gt; and switching lexers to this &lt;span style="font-family:courier new;"&gt;Reader&lt;/span&gt; (using &lt;span style="font-family:courier new;"&gt;LexerSharedInputState&lt;/span&gt;) after pushing the current lexer onto a stack. Thus, after the macro expansion was lexed, the EOF would pop the stack and restore the previous lexer, etc.&lt;br /&gt;&lt;br /&gt;Seemed a pretty elegant solution; in fact, &lt;span style="font-family:courier new;"&gt;`include&lt;/span&gt; files are handled exactly this way!&lt;br /&gt;&lt;br /&gt;So, it's a good thing myself and others continue to test, test, test... So, we came upon a valid (Verilog) input as:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;`define N 4&lt;br /&gt;...&lt;br /&gt;wire [N-1:0] a = `N'b0;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;The failure occured at the &lt;span style="font-family:courier new;"&gt;`N'b0&lt;/span&gt;. A lexer rule was defined to grab a sized number token: i.e., &lt;span style="font-family:courier new;"&gt;4'b0&lt;/span&gt;; but, since the &lt;span style="font-family:courier new;"&gt;`N&lt;/span&gt; was expanded using one lexer and then popped back to continue with &lt;span style="font-family:courier new;"&gt;'b0&lt;/span&gt;, the parser got: &lt;span style="font-family:courier new;"&gt;4&lt;/span&gt; followed by &lt;span style="font-family:courier new;"&gt;'b0&lt;/span&gt;, which is not a (non-)terminal node, so an error!&lt;br /&gt;&lt;br /&gt;Anyway, the more I thought about this, the more apparent a cleaner split between preprocessing and subsequent (parsing) stages made more sense. (Guess it's been too long since I took my Compilers class!)&lt;br /&gt;&lt;br /&gt;So, while ANTLR does allow one to chain one lexer stream into another, these would have amounted to preprocessing the entire file, either into a tempfile or an in-memory buffer. Not a long term solution, especially since I do anticipate processing huge/netlist files.&lt;br /&gt;&lt;br /&gt;In other words, creating a preprocessing lexer to handle all the &lt;span style="font-family:courier new;"&gt;`include, `define, `&lt;span style="FONT-STYLE: italic"&gt;name&lt;/span&gt;&lt;/span&gt;, ... was easy (thanx to ANTLR!); but, connecting this pre-processed lexer stream to the next level lexer (connected to actual parser) was not trivial.&lt;br /&gt;&lt;br /&gt;But, Java threads and &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/PipedReader.html"&gt;PipedReader&lt;/a&gt;, &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/StringWriter.html"&gt;PipedWriter&lt;/a&gt; to the rescue!&lt;br /&gt;&lt;br /&gt;Using those, the preprocessor lexer runs in one thread supplying input to the Verilog lexer+parser in another thread. The Piped object mitigates the need to slurp in the whole tamale, and the Threads keep a clean separation between the writing (file through preprocessor lexer) and reading (by the Verilog lexer to parser).&lt;br /&gt;&lt;br /&gt;&lt;a href="http://java.sun.com/developer/JDCTechTips/2001/tt0208.html"&gt;Java threading makes this easy&lt;/a&gt;!&lt;br /&gt;&lt;br /&gt;Another side effect of the preprocessor separation is the ability to dump out preprocessed data/files, too; akin to the &lt;span style="font-family:courier new;"&gt;-E&lt;/span&gt; and &lt;span style="font-family:courier new;"&gt;-C&lt;/span&gt; options to gcc. In fact, I co-opted the same options as shown by the usage options:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Usage: analyze (--tcl out.tcl)? (--rb out.rb)? (--outf out.f)?&lt;br /&gt;               --only_used? --exit_on_err? (--verbose n)? --abs_paths?&lt;br /&gt;               (--redefn n)? (-E -C?)?&lt;br /&gt;               topModule vlogOpts+&lt;br /&gt;...&lt;br /&gt;  -E            : dump pre-processed files to "file.v.E".&lt;br /&gt;                    Useful for debugging preprocessing issues.&lt;br /&gt;  -C            : do not discard comments when "-E" is specified.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;There is a good methodology paper and examples using the default application (analyze) of the v2kparse project &lt;a href="http://v2kparse.sourceforge.net/includes.pdf"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;If you start diving into the source code, you will notice that I cleaned out parser tree code, related to the analyze application, from the Vlog.g parser (language) definition. I was compelled to get a useful application (analyze) off the parser; but, in that interest, muddied the parser infrastructure with &lt;span style="FONT-STYLE: italic"&gt;an &lt;/span&gt;application. My original intent was to keep the parse tree free of any (reasonable) application/use level intent bias/knowledge.&lt;br /&gt;&lt;br /&gt;So, the &lt;span style="font-family:courier new;"&gt;SimpleParseTree&lt;/span&gt; class (in &lt;span style="font-family:courier new;"&gt;srcs/v2k/parser/tree/SimpleParseTree.java&lt;/span&gt;) serves as an example implementation (override) of the default &lt;span style="font-family:courier new;"&gt;ASTreeBase&lt;/span&gt; class methods. The &lt;span style="font-family:courier new;"&gt;SimpleParseTree&lt;/span&gt; is used by the &lt;span style="font-family:courier new;"&gt;analyze&lt;/span&gt; application.&lt;br /&gt;&lt;br /&gt;I'm still mulling over a few other future uses for the ever-evolving &lt;span style="font-family:courier new;"&gt;ASTreeBase&lt;/span&gt;!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8479933371391943026-5040068465555826750?l=v2kparse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/5040068465555826750/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8479933371391943026&amp;postID=5040068465555826750' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/5040068465555826750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/5040068465555826750'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/2008/09/final-cleanup-and-examples.html' title='Some Cleanup and Examples'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8479933371391943026.post-3125589365695928901</id><published>2008-08-08T09:38:00.000-07:00</published><updated>2008-09-22T21:03:24.122-07:00</updated><title type='text'>Added Ruby file list generation</title><content type='html'>In this release uploaded to &lt;a href="https://sourceforge.net/projects/v2kparse"&gt;sourceforge&lt;/a&gt;, I added a Ruby (syntax) file list option:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Usage: analyze.rb (--tcl out.tcl)? (&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;--rb out.rb&lt;/span&gt;)? (--exit_on_err)?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                  topModule vlogOpts+&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    --tcl out.tcl : dump details in tcl format to "out.tcl".&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    --rb  out.rb  : dump details in ruby format to "out.rb".&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    --exit_on_err : exit status != 0 if any parse errors.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                  : And, no "out.tcl" generated if errors.&lt;/span&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;I also ran across an interesting testcase of some wacky control character, 0x93, in a Verilog source file!  I updated the (Antlr) lexer to accept a full 8-bit vocabulary and simply toss all the bizarre ones into a protected lexer rule: CNTL, and simply skip them: (except from Vlog.g, with line numbers shown):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1219 class VlogLexer extends Lexer;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1220 options {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1221     k=3;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1222     charVocabulary='\u0000'..'\u00FF';&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1223     testLiterals=false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1224 }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1474 WS  :  (CNTRL|' '|'\r'|'\t'|'\n' {newline();})&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1475         {$setType(Token.SKIP);}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1476     ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1477 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1478 protected&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1479 CNTRL&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1480     : '\u0000'..'\u0008'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1481     | '\u000B'..'\u000C'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1482     | '\u000E'..'\u001F'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1483     | '\u007F'..'\u00FF'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;1484     ;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Let me know any bugs, improvements, ideas, praise, etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8479933371391943026-3125589365695928901?l=v2kparse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/3125589365695928901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8479933371391943026&amp;postID=3125589365695928901' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/3125589365695928901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/3125589365695928901'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/2008/08/added-ruby-file-list-generation.html' title='Added Ruby file list generation'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8479933371391943026.post-1437474155848430518</id><published>2008-07-31T09:54:00.000-07:00</published><updated>2008-09-22T21:03:05.906-07:00</updated><title type='text'>Added Tcl file list generation</title><content type='html'>I uploaded the next version to &lt;a href="https://sourceforge.net/projects/v2kparse"&gt;sourceforge&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This version added a few more options relevant to my initial goal of building file lists and extracting other info for implementation related tasks.&lt;br /&gt;&lt;br /&gt;(See the previous post for download and install details.)&lt;br /&gt;&lt;br /&gt;After install:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt; &lt;span style="font-weight: bold;"&gt;bin/analyze &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Usage: analyze.rb (&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;--tcl out.tcl&lt;/span&gt;)? (&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;--exit_on_err&lt;/span&gt;)? topModule vlogOpts+&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    --tcl out.tcl : dump details in tcl format to "out.tcl".&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    --exit_on_err : exit status != 0 if any parse errors.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                  : And, no "out.tcl" generated if errors.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  vlogOpts is one of&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    file.v&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -f args.f&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -v library.v&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -y library_directory&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    +incdir+dir1(+dirn)*&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    +define+d(=v)?(+dn(=vn)?)*&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The additional options are: &lt;span style="font-weight: bold;"&gt;--tcl&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;--exit_on_err&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;You should try these out.  The format/info contained in the generated out.tcl file should be &lt;span style="font-style: italic;"&gt;self-explanatory&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Let me know any bugs, improvements, ideas, praise, etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8479933371391943026-1437474155848430518?l=v2kparse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/1437474155848430518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8479933371391943026&amp;postID=1437474155848430518' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/1437474155848430518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/1437474155848430518'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/2008/07/added-tcl-file-list-generation.html' title='Added Tcl file list generation'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8479933371391943026.post-3410420430040467671</id><published>2008-07-24T08:59:00.000-07:00</published><updated>2008-09-22T21:02:48.816-07:00</updated><title type='text'>Parser + JRuby (quick) linker</title><content type='html'>I uploaded the next version to &lt;a href="https://sourceforge.net/projects/v2kparse"&gt;sourceforge&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This new version cleaned up a few missing constructs and pre-processor directives which I encountered while testing even more real design RTL.&lt;br /&gt;&lt;br /&gt;So, while getting the parser/grammar stuff done was not too painful, thanx to &lt;a href="http://www.antlr.org/"&gt;ANTLR&lt;/a&gt; and the great debugger in &lt;a href="http://www.netbeans.org/"&gt;Netbeans&lt;/a&gt;; moving on to the linker stage was a great experience: I bit the bullet and learned &lt;a href="http://jruby.codehaus.org/"&gt;JRuby&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;(An &lt;a href="http://www.pragprog.com/titles/ruby3/programming-ruby-3"&gt;excellent book on Ruby itself is here&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;Why JRuby?  Well, I am normally a Tcl guy, when it comes to complex scripting.  I never learned Perl, since when I was at the crossroads of having to abandon complex awk, greps, seds and csh, I was fortunate enough to cross paths w/ John Ousterhout (the creator of Tcl) on a road show at Sun promoting Tcl.  Never had any regrets: it's a great language, and ever prevelant in any self-respecting EDA tools.&lt;br /&gt;&lt;br /&gt;Hmmm, I still haven't answered the why JRuby, huh?&lt;br /&gt;&lt;br /&gt;So, while I could have continued to do more of the rudimentary stuff around the parser (such as quick linking) in Java, I was aware of the JRuby capabilities w/in Netbeans (did I say how much I luv Netbeans?)... so did a little more digging and playing... and it's great!&lt;br /&gt;&lt;br /&gt;JRuby essentially gives you the Ruby language, which is a truly object-oriented interpreted language (while some may say scripting language, that has some negative connotations, IMHO, esp. if you compare it w/ other so-called scripting languages (like Perl --- yuk!)).  BUT, the best part is that the "J" part brings Java into the picture, too.  So, we can use Java for the more elegant parts of our design, and then Ruby for the more "one offs", experimental, oft-changing, ... parts.  (Or, just an excuse to use/learn Ruby!)&lt;br /&gt;&lt;br /&gt;So, the tact I took in this release is to use the Java part for the analyze part of the parser, and the Ruby side to parse options, iterate looking for candidate files (i.e., the -y +libext+ verilog options) and interact with the parse tree to (quick) link the design, in the interest of finding the complete (flat list of) files from the (typically) succinct .f files.&lt;br /&gt;&lt;br /&gt;(Go back to my 1st blog post to refresh to my original motivation for this project.)&lt;br /&gt;&lt;br /&gt;So, after you download and untar &lt;a href="https://sourceforge.net/projects/v2kparse"&gt;this release&lt;/a&gt;, you will also need to install/add the path to jruby on your system.&lt;br /&gt;&lt;br /&gt;If you do not have jruby, I would strongly suggest using the &lt;a href="http://download.netbeans.org/netbeans/6.1/final"&gt;Netbeans&lt;/a&gt; "all" pack.&lt;br /&gt;&lt;br /&gt;On my system, I have:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt; &lt;span style="font-weight: bold;"&gt;which jruby&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;/opt/netbeans-6.1/ruby2/jruby-1.1/bin/jruby&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After that is all setup, you can run a very simple testcase.  (I will eventually add something more complex; but, didn't want to slog the sourceforge downloads w/ huge designs, like the &lt;a href="http://www.opensparc.net/opensparc-t2/index.html"&gt;free Sparc one&lt;/a&gt;... and the &lt;a href="http://opencores.org/"&gt;opencores.org&lt;/a&gt; ones may not be so easily redistributed... and didn't want any legal hassles at such a young age).&lt;br /&gt;&lt;br /&gt;So, the simple one:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:courier new;" &gt;# I untar-d the download under /tmp/v2k, in this example&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt; &lt;span style="font-weight: bold;"&gt;cd /tmp; mkdir v2k; cd v2k&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt; &lt;span style="font-weight: bold;"&gt;&lt;span style="font-style: italic;"&gt;download v2kparse-0.2.tar.gz&lt;/span&gt;; tar zxf v2kparse-0.2.tar.gz&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt; &lt;span style="font-weight: bold;"&gt;bin/analyze&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Usage: analyze.rb topModule vlogOpts+&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  where vlogOpts is one of&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    file.v&lt;br /&gt;-f args.f&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    -v library.v&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    -y library_directory&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    +incdir+dir1(+dirn)*&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    +define+d(=v)?(+dn(=vn)?)*&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt; &lt;span style="font-weight: bold;"&gt;cd data&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:courier new;" &gt;# run the simple testcase&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt; &lt;span style="font-weight: bold;"&gt;../bin/analyze m1 -f tc2.f&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DBG1: after proc_args: +define+SYNTHESIS +incdir+tc2 -y tc2 tc2/m1.v&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Info: Pass 1: -I tc2 -D SYNTHESIS tc2/m1.v.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Info : tc2/m1.v:1: include file "/tmp/v2k/data/tc2/defs.vh".  (INCL-1)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Info: Unresolved: m2.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Info: Pass 2: /tmp/v2k/data/tc2/m2.v.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Info: Unresolved: m3.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Info: Pass 3: /tmp/v2k/data/tc2/m3.v.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Info: Link status: true.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In this (simple) testcase, the tc2.f is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+define+SYNTHESIS&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;+incdir+tc2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;-y tc2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;tc2/m1.v&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So, as the analyze runs, the analyze.rb script is iterating:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;starting with the fully specific file: tc2/m1.v&lt;/li&gt;&lt;li&gt;running the (java-based) parser&lt;/li&gt;&lt;li&gt;querying the parse tree (created by parser) for defined modules and their references&lt;/li&gt;&lt;li&gt;(analyze.rb) keeps track of defined, linked and unresolved references&lt;/li&gt;&lt;li&gt;uses the unresolved references and the -y +libext+ specs to find matching files&lt;/li&gt;&lt;li&gt;repeatedly calls the parser (with the newly found files) and queries the incrementally (modified) parse tree&lt;/li&gt;&lt;li&gt;goto 3 and repeat until fully linked, or nothing else to do&lt;/li&gt;&lt;/ol&gt;I've left some debug messages in the code; and, the final message indicates whether the link was successful.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;DISCLAIMER: this is a quick link, in the sense that an elaborate is not done: there are no port/pin checks, etc.  Just a simple check that a referenced module is defined, or is defined to be a leaf cell.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;If you want to play around with your own designs, you will likely have instanced memories, standard cells, macros, etc. which you normally would not specify in a .f file, explicitly.  These normally are added via a library.f for simulation; and, would use .lib/.db files for typical implementation tasks, like synthesis.&lt;br /&gt;&lt;br /&gt;So, there needs to be a convenient way to specify what modules names should be considered leafs.  If you look in the ruby/srcs/analyze.rb file (at the bottom), you will see:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;210 #TODO: Redefine the is_leaf method to describe module names&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;211 #      which are not defined in any (user created) verilog contexts.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;212 #      There are typically leaf/library cells.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;213 #&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That describes how to specify leafs for your specific needs.&lt;br /&gt;&lt;br /&gt;Have fun with this release, and I'll be back with more soon!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8479933371391943026-3410420430040467671?l=v2kparse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/3410420430040467671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8479933371391943026&amp;postID=3410420430040467671' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/3410420430040467671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/3410420430040467671'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/2008/07/parser-jruby-quick-linker.html' title='Parser + JRuby (quick) linker'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8479933371391943026.post-5460482953848559387</id><published>2008-06-23T20:12:00.000-07:00</published><updated>2008-09-22T21:02:28.770-07:00</updated><title type='text'>First pass uploaded to sourceforce</title><content type='html'>I finished the 1st pass of the &lt;a href="http://www.antlr2.org/"&gt;ANTLR 2.7.7&lt;/a&gt; based v2k parser and lexer and &lt;a href="https://sourceforge.net/project/showfiles.php?group_id=230316"&gt;uploaded to sourceforge&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The lexer includes a Verilog preprocessor which handles:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;`define,`undef&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;`include&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;`ifdef,`ifndef,`else,`endif&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:courier new;"&gt;`timescale&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Once you download, at the toplevel directory there is a runParser script which invokes java using the precompiled .jar files released under dist/.&lt;/p&gt;&lt;p&gt;Just type&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&gt; &lt;strong&gt;runParser&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;to see the usage.&lt;/p&gt;&lt;p&gt;I was compelled to use ANTLR 2.7.7 since the token stream mechanism does not try to slurp in the whole source file, an issue which I encountered with the more recent ANTLR 3.0.&lt;/p&gt;&lt;p&gt;While Verilog source files are not generally large, netlist files can be humungous, and one can quickly run out of memory by "slurping in the whole tamale."&lt;/p&gt;&lt;p&gt;Anyway, I've communicated the large file slurp file to the author of ANTLR and he'll be working out a solution in future releases.&lt;/p&gt;&lt;p&gt;(If you think large verilog netlists are problematic to slurp; think aout a SPEF file --- where I first encoutered the problem using ANTLR 3.x. Anyway, back to 2.7.7 works fine, even for large SPEF files.)&lt;/p&gt;&lt;p&gt;Anyway, back to the v2kparser...&lt;/p&gt;&lt;p&gt;I've been testing it out on a lot of the RTL for a large SOC I'm working on now; and, so far so good. It has even helped me find "bad style RTL" in the sense that (defined) &lt;span style="font-family:courier new;"&gt;'&lt;em&gt;values&lt;/em&gt;&lt;/span&gt; were used within source files which never `included the file containing the `define.  Now, there's looking at an order of analysis problem!&lt;/p&gt;&lt;p&gt;I always advocate using the software style for writing include files and using them too, as in:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;//file to be included all over: file.vh&lt;br /&gt;`ifndef _FILE_VH&lt;br /&gt;`define _FILE_VH_&lt;br /&gt;`define N 5&lt;br /&gt;`define M (1 &lt;&lt; `N)&lt;br /&gt;  ...&lt;br /&gt;`endif&lt;br /&gt;//`_FILE_VH_&lt;/span&gt;&lt;/p&gt;&lt;p&gt;and the file which wants to use&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;//rtl.v&lt;br /&gt;`include "file.vh"&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8479933371391943026-5460482953848559387?l=v2kparse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/5460482953848559387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8479933371391943026&amp;postID=5460482953848559387' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/5460482953848559387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/5460482953848559387'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/2008/06/first-pass-uploaded-to-sourceforce.html' title='First pass uploaded to sourceforce'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8479933371391943026.post-809957801874977321</id><published>2008-06-18T19:26:00.000-07:00</published><updated>2008-09-22T21:02:03.332-07:00</updated><title type='text'>Implement what your verify</title><content type='html'>I spend a lot of my working hours doing ASIC design related tasks, primarily on the implementation side.&lt;br /&gt;&lt;br /&gt;Hence, I've run through gazillions of lines of Verilog code, for lint tools, synthesis, formal EC, clock domain crossings, on and on.&lt;br /&gt;&lt;br /&gt;I have yet to find a consistent way to feed Verilog file lists, include directories, library paths --- all that dot-f stuff: *.v, +incdir+, -y, -v, usu. dumped into a simulator "as-is" --- well, the implementation tools do not take those verbatim, you have to spec Tcl list of files, search paths, define arguments; and, don't even try to do anything resembling -y and +libext+ type options.&lt;br /&gt;&lt;br /&gt;I've seen environments where I really wonder whether an ASIC was built with the same design files it was actually simulated with. (I kid you not!)&lt;br /&gt;&lt;br /&gt;So, having spent lots of hours mucking around with EDA tool development of various sorts: simulators, parsers, databases and alike, I decided to solve the problem of getting simulation file &lt;span style="font-style: italic;"&gt;stuff&lt;/span&gt;, verbatim, into the implementation tools.&lt;br /&gt;&lt;br /&gt;How?&lt;br /&gt;&lt;br /&gt;Well, lets first start with a real parser, so we can process &lt;span style="font-style: italic;"&gt;synthesizable&lt;/span&gt; Verilog RTL, including the preprocessor. From there, the sky is the limit.&lt;br /&gt;&lt;br /&gt;For real parser development, there is one really excellent tool: &lt;a href="http://www.antlr.org/"&gt;ANTLR&lt;/a&gt;. I've been doing all kinds of hobby and real parser development with ANTLR since it was Terence's PhD thesis back in the late 80's.&lt;br /&gt;&lt;br /&gt;There's all kinds of excellent info about ANTLR at the &lt;a href="http://www.antlr.org/"&gt;website&lt;/a&gt;, and even a &lt;a href="http://www.pragprog.com/titles/tpantlr/the-definitive-antlr-reference"&gt;great book to boot&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8479933371391943026-809957801874977321?l=v2kparse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://v2kparse.blogspot.com/feeds/809957801874977321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8479933371391943026&amp;postID=809957801874977321' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/809957801874977321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8479933371391943026/posts/default/809957801874977321'/><link rel='alternate' type='text/html' href='http://v2kparse.blogspot.com/2008/06/parser-for-verilog.html' title='Implement what your verify'/><author><name>kpfalzer</name><uri>http://www.blogger.com/profile/00750994667177946446</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
