Giter Club home page Giter Club logo

verilog-parser's Introduction

Verilog Parser

Documentation Build Status Coverage Status Licence: MIT

This repository contains a flex / bison parser for the IEEE 1364-2001 Verilog Standard.


Getting Started

This will get you going workspace wise.

$> make all
$> make test-all

This will download the test suite files, setup the build directory, and compile the parser, library and test app.

To start using the parser in your own code, take a look at main.c which is a simple demonstration app used for testing and coverage. The basic code which you need is something like this:

// Initialise the parser.
verilog_parser_init();

// Open A File handle to read data in.
FILE * fh = fopen("my_verilog_file.v", "r");

// Parse the file and store the result.
int result = verilog_parse_file(fh);

if(result == 0)
    printf("Parse successful\n");
else
    printf("Parse failed\n");

fclose(fh);

You can keep calling verilog_parse_file(fh) on as many different file handles as you like to build up a multi-file project AST representation. The parser will automatically follow any include directives it finds.

For an example of using the library in a realish situation, the verilog-dot project shows how the library can be integrated into an existing project and used.

Testing

The test suite is comprised of example code taken from the fantastic ASIC World tutorial on Verilog. The idea being that by using a well-known and comprehensive set of tutorial examples, almost all of the syntactic features of the language can be hit very easily with little effort.

The repository also contains an archive of verilog source code taken from the OpenSPARCT1 microprocessor from Oracle. This archive is unpacked into the tests/ directory when make setup is run, and ensures that the parser is able to handle a real-life source base in terms of scale and complexity. The full workspace environment required to run or analyse the OpenSPARCT1 is not provided, the files only demonstrate the ability to correctly parse a large project, and handle the various internal header files and preprocessor definitions.

Contributing

Of-course, the current test suite does not test everything and I expect there to be awkward bugs. This is the first time I have written a parser of this size and complexity. I have set up automatic coverage collection after each CI build, this gives a good indication of which parts of the code are tested and dependable. Hitting 100% coverage for a parser is a pain, but hopefully over time it will tend that way. The current situation is that all of the verilog language features that are used commonly are tested for. The main missing bits are due to a lack of test cases for user defined primitives (UDPs).

If you find a bug, or otherwise want to contribute, then please don't hesitate to file a pull request. If you have found a bug, please add a test for the bug in the tests/ folder. This should trigger the bug in the original code, and ideally, not trigger in you're submitted fix! I'm open to people just submitting bugs as well, but it might take longer for me to get round to fixing it!

There is more information on how to help in the contributing guide.

Design Choices

Why C, why not something more modern?

This comes down to who will use this tool, and who will develop this tool. Ideally, these are the same people. The current demographic of people working in ASIC / RTL design is that of (please excuse my generalising) electronic engineers, with (again, sorry) little experience of recent programming language technologies like Haskell (great for parsing and formal/state-based assertions) and Python (perl is still king in ASIC design flows, but this is changing). Further, the size and complexity of many RTL designs means you need a language that has lots of low-level acceleration potential, as well as being tried-and-tested. C meets most of these points, while also being something that electronics engineers are more likely to be familiar with and comfortable using.

Why flex/bison, why not Boost::Sprint, ANTLR, or something custom?

Similar to the above answer. These are tools that are very old, and very stable. They are more likely to be available and supported for the kinds of development environments RTL designers work in which are often at least a decade old. What flex and bison loose in terms of nice features, syntactic sugar, and, sadly, ease of use - they make up for in stability and likelihood of familiarity for the people I hope will use this project. Many of the design decisions around this project have been equal parts social and engineering in their justification.

Why not adapt an existing parser?

Good question. I looked at the parsers found in Icarus Verilog and yosys but found that while they were excellent in and of themselves, they were too well adapted to their end use to be made into a general purpose parser. They did inform me well on how to parse the trickier parts of the grammar though, and I certainly cannot fault them in any other way! This parser has been written to correspond very closely to the IEEE Verilog 2001 Syntax specification. This means it is longer (by line count) but much easier to understand and relate to the original specification. For example, each grammar rule in the Bison file matches almost exactly with it's namesake in the IEEE spec.


Todo

There are some things that the parser does not support:

  • System-Verilog. Sorry folks, its another language completely. This parser should serve as a very good starting point if you want to build one though, since Verilog is a subset of System-Verilog.
  • System timing checks. See Annex 7.5.1 of the specification for what this omits. It hopefully won't be long before I get round to adding it though.

Wishlist

This is a wishlist of tools that I would like to use the parser in. If anyone else would like to use the parser as the basis for their own tools like this, I am more than happy to help!

  • A code indenter / style format checker.
  • A pre-processed source checker (expand macros and parameters, etc) for easy browsing of generic logic blocks and cores.
  • Something to highlight when signals cross clock domains.
  • Critical path identifier (something which doesn't take 20 minuets to run on a grid engine)
  • A switching probability analysis tool.
  • This could even feed into a rough power & energy estimation tool.
  • A simple hierarchy visualiser, which you can feed all your project files into and which will spit out a digested view of the module hierarchy.
  • Proper Doxygen support for Verilog, or failing that, a Doxygen like tool for Verilog

verilog-parser's People

Contributors

ashishtibrewal avatar ben-marshall avatar mithro avatar zhanghongce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

verilog-parser's Issues

Build Warnigns/Errors

Issue Description

Many rule warnings (errors) that need addressing

What should happen:

No/Less Warnings

What actually happens:

Warnings

verilog-parser/src/verilog_parser.y:165.17-29: warning: symbol binary_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> binary_number
                 ^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:164.17-30: warning: symbol decimal_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> decimal_number
                 ^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:166.17-26: warning: symbol hex_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> hex_number
                 ^^^^^^^^^^
verilog-parser/src/verilog_parser.y:167.17-28: warning: symbol octal_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> octal_number
                 ^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:168.17-27: warning: symbol real_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> real_number
                 ^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:821.28-42: warning: type clash on default action: <list> != <node> [-Wother]
 list_of_actual_arguments : actual_argument
                            ^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:825.19-28: warning: type clash on default action: <node> != <expression> [-Wother]
 actual_argument : expression
                   ^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3703.27-47: warning: type clash on default action: <node> != <parameter_declaration> [-Wother]
 specify_item            : specparam_declaration
                           ^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3706.27-42: warning: type clash on default action: <node> != <path_declaration> [-Wother]
                         | path_declaration
                           ^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3710.27-78: warning: type clash on default action: <node> != <keyword> [-Wother]
 pulsestyle_declaration  : KW_PULSESTYLE_ONEVENT list_of_path_outputs SEMICOLON
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3711.27-79: warning: type clash on default action: <node> != <keyword> [-Wother]
                         | KW_PULSESTYLE_ONDETECT list_of_path_outputs SEMICOLON
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3714.31-77: warning: type clash on default action: <node> != <keyword> [-Wother]
 showcancelled_declaration   : KW_SHOWCANCELLED list_of_path_outputs SEMICOLON
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3715.31-79: warning: type clash on default action: <node> != <keyword> [-Wother]
                             | KW_NOSHOWCANCELLED list_of_path_outputs SEMICOLON
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:4535.3-54: warning: type clash on default action: <list> != <string> [-Wother]
   OPEN_SQ_BRACKET constant_expression CLOSE_SQ_BRACKET
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:4536.3-4537.33: warning: type clash on default action: <list> != <string> [-Wother]
 | OPEN_SQ_BRACKET constant_expression CLOSE_SQ_BRACKET
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y: warning: 11 nonterminals useless in grammar [-Wother]
verilog-parser/src/verilog_parser.y: warning: 11 rules useless in grammar [-Wother]
verilog-parser/src/verilog_parser.y:542.38-50: warning: nonterminal useless in grammar: expressions_o [-Wother]
 %type   <list>                       expressions_o
                                      ^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:716.38-44: warning: nonterminal useless in grammar: comment [-Wother]
 %type   <string>                     comment
                                      ^^^^^^^
verilog-parser/src/verilog_parser.y:720.38-53: warning: nonterminal useless in grammar: one_line_comment [-Wother]
 %type   <string>                     one_line_comment
                                      ^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:715.38-50: warning: nonterminal useless in grammar: block_comment [-Wother]
 %type   <string>                     block_comment
                                      ^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:714.38-41: warning: nonterminal useless in grammar: anys [-Wother]
 %type   <string>                     anys
                                      ^^^^
verilog-parser/src/verilog_parser.y:722.38-48: warning: nonterminal useless in grammar: white_space [-Wother]
 %type   <string>                     white_space
                                      ^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:165.17-29: warning: nonterminal useless in grammar: binary_number [-Wother]
 %type  <number> binary_number
                 ^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:164.17-30: warning: nonterminal useless in grammar: decimal_number [-Wother]
 %type  <number> decimal_number
                 ^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:166.17-26: warning: nonterminal useless in grammar: hex_number [-Wother]
 %type  <number> hex_number
                 ^^^^^^^^^^
verilog-parser/src/verilog_parser.y:167.17-28: warning: nonterminal useless in grammar: octal_number [-Wother]
 %type  <number> octal_number
                 ^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:168.17-27: warning: nonterminal useless in grammar: real_number [-Wother]
 %type  <number> real_number
                 ^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3566.19-40: warning: rule useless in grammar [-Wother]
 expressions_o   : expressions {$$ = $1;} |{$$=ast_list_new();}
                   ^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3566.43-62: warning: rule useless in grammar [-Wother]
 expressions_o   : expressions {$$ = $1;} |{$$=ast_list_new();}
verilog-parser/src/verilog_parser.y:165.17-29: warning: symbol binary_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> binary_number
                 ^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:164.17-30: warning: symbol decimal_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> decimal_number
                 ^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:166.17-26: warning: symbol hex_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> hex_number
                 ^^^^^^^^^^
verilog-parser/src/verilog_parser.y:167.17-28: warning: symbol octal_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> octal_number
                 ^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:168.17-27: warning: symbol real_number is used, but is not defined as a token and has no rules [-Wother]
 %type  <number> real_number
                 ^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:821.28-42: warning: type clash on default action: <list> != <node> [-Wother]
 list_of_actual_arguments : actual_argument
                            ^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:825.19-28: warning: type clash on default action: <node> != <expression> [-Wother]
 actual_argument : expression
                   ^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3703.27-47: warning: type clash on default action: <node> != <parameter_declaration> [-Wother]
 specify_item            : specparam_declaration
                           ^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3706.27-42: warning: type clash on default action: <node> != <path_declaration> [-Wother]
                         | path_declaration
                           ^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3710.27-78: warning: type clash on default action: <node> != <keyword> [-Wother]
 pulsestyle_declaration  : KW_PULSESTYLE_ONEVENT list_of_path_outputs SEMICOLON
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3711.27-79: warning: type clash on default action: <node> != <keyword> [-Wother]
                         | KW_PULSESTYLE_ONDETECT list_of_path_outputs SEMICOLON
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3714.31-77: warning: type clash on default action: <node> != <keyword> [-Wother]
 showcancelled_declaration   : KW_SHOWCANCELLED list_of_path_outputs SEMICOLON
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3715.31-79: warning: type clash on default action: <node> != <keyword> [-Wother]
                             | KW_NOSHOWCANCELLED list_of_path_outputs SEMICOLON
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:4535.3-54: warning: type clash on default action: <list> != <string> [-Wother]
   OPEN_SQ_BRACKET constant_expression CLOSE_SQ_BRACKET
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:4536.3-4537.33: warning: type clash on default action: <list> != <string> [-Wother]
 | OPEN_SQ_BRACKET constant_expression CLOSE_SQ_BRACKET
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y: warning: 11 nonterminals useless in grammar [-Wother]
verilog-parser/src/verilog_parser.y: warning: 11 rules useless in grammar [-Wother]
verilog-parser/src/verilog_parser.y:542.38-50: warning: nonterminal useless in grammar: expressions_o [-Wother]
 %type   <list>                       expressions_o
                                      ^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:716.38-44: warning: nonterminal useless in grammar: comment [-Wother]
 %type   <string>                     comment
                                      ^^^^^^^
verilog-parser/src/verilog_parser.y:720.38-53: warning: nonterminal useless in grammar: one_line_comment [-Wother]
 %type   <string>                     one_line_comment
                                      ^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:715.38-50: warning: nonterminal useless in grammar: block_comment [-Wother]
 %type   <string>                     block_comment
                                      ^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:714.38-41: warning: nonterminal useless in grammar: anys [-Wother]
 %type   <string>                     anys
                                      ^^^^
verilog-parser/src/verilog_parser.y:722.38-48: warning: nonterminal useless in grammar: white_space [-Wother]
 %type   <string>                     white_space
                                      ^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:165.17-29: warning: nonterminal useless in grammar: binary_number [-Wother]
 %type  <number> binary_number
                 ^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:164.17-30: warning: nonterminal useless in grammar: decimal_number [-Wother]
 %type  <number> decimal_number
                 ^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:166.17-26: warning: nonterminal useless in grammar: hex_number [-Wother]
 %type  <number> hex_number
                 ^^^^^^^^^^
verilog-parser/src/verilog_parser.y:167.17-28: warning: nonterminal useless in grammar: octal_number [-Wother]
 %type  <number> octal_number
                 ^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:168.17-27: warning: nonterminal useless in grammar: real_number [-Wother]
 %type  <number> real_number
                 ^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3566.19-40: warning: rule useless in grammar [-Wother]
 expressions_o   : expressions {$$ = $1;} |{$$=ast_list_new();}
                   ^^^^^^^^^^^^^^^^^^^^^^
verilog-parser/src/verilog_parser.y:3566.43-62: warning: rule useless in grammar [-Wother]
 expressions_o   : expressions {$$ = $1;} |{$$=ast_list_new();}

...only first terminal screen pasted here

Steps to re-create:

bison==3.0.4
flex==2.6.4
(ubuntu-bionic packages)

$> make clean
$> make debug

People to Notify:

Related Issues:

../../tests/dff_udp1.v line 11 - ERROR: syntax error, unexpected CLOSE_BRACKET - ')' - Parse failed

Issue Description

Getting following error

../../tests/dff_udp1.v line 11 - ERROR: syntax error, unexpected CLOSE_BRACKET
- ')'
- Parse failed

File ../../tests/dff_udp1.v obtained from https://www.hdlworks.com/hdl_corner/verilog_ref/items/UserDefinedPrimitives.htm

cat -n ../../tests/dff_udp1.v
     1	//https://www.hdlworks.com/hdl_corner/verilog_ref/items/UserDefinedPrimitives.htm
     2	
     3	primitive Dff (q, d, clk, rst);    // sequential UDP
     4	  output q;
     5	  input clk, rst, d;
     6	  reg q;
     7	  initial q = 0;
     8	  table
     9	    // d  clk  rst : old q : q
    10	       ?   ?    0  :   ?   : 0;
    11	       0   R    1  :   ?   : 0;
    12	       1  (01)  1  :   ?   : 1;
    13	       ?   N    1  :   ?   : -;
    14	       *   ?    1  :   ?   : -;
    15	       ?   ?   (0?):   ?   : -;
    16	  endtable
    17	endprimitive 

What problem / feature / issue are you raising? Describe in as much detail
as possible.

What should happen:

What should normal behaviour for the given input be?

../../tests/dff_udp1.v   - Parse successful

What actually happens:

../../tests/dff_udp1.v line 11 - ERROR: syntax error, unexpected CLOSE_BRACKET
- ')'
- Parse failed

Steps to re-create:

Describe exactly how to re-create the bug.

cd to build/debug

Obtain from https://www.hdlworks.com/hdl_corner/verilog_ref/items/UserDefinedPrimitives.htm and copy and paste file to ../../tests/dff_udp1.v

Then run
./src/parser ../../tests/dff_udp1.v

$> make clean
$> make all
$> ./src/parser ../../tests/dff_udp1.v

People to Notify:

Related Issues:

Inbalanced `yy_preproc -> current_file` Stack

Hi, again!

I think there might be an issue with the yy_preproc -> current_file stack when handling preprocessor macros (but not the include). For MACRO_IDENTIFIER, the lexer will jump into the macro definitions, but unlike the way that "include" is handled, it does not push the stack. At the end of that string, it will trigger the <<EOF>> case, which pops the stack. This could cause stack underflow, and when later yy_preproc -> current_file is used to assigned to the meta field, the file name there becomes null (the stack returns null when is underflowed.)

{MACRO_IDENTIFIER}     {

    // Look for the macro entry.
    verilog_macro_directive * macro = NULL;
    char * macroName = (yytext)+1;
    ast_hashtable_result r = ast_hashtable_get(yy_preproc -> macrodefines,
                                               macroName,
                                               (void**)&macro);
    
    if(r == HASH_SUCCESS)
    {
        // Switch buffers to expand the macro.

        YY_BUFFER_STATE cur = YY_CURRENT_BUFFER;
        YY_BUFFER_STATE n   = yy_scan_string(macro -> macro_value);
        
        yy_switch_to_buffer(cur);
        yypush_buffer_state(n);
    }
    else
    {
        // Undefined macro - PANIC!
        //printf("ERROR: Undefined macro '%s' on line %d\n", yytext, yylineno);
        //printf("\tIt's probably all going to fall apart now...\n\n");
    }
}
<<EOF>> {

    yypop_buffer_state();

    // We are exiting a file, so pop from the the preprocessor stack of files
    // being parsed.
    ast_stack_pop(yy_preproc -> current_file);


    if ( !YY_CURRENT_BUFFER )
    {
        yyterminate();
    }
    else
    {
        YY_BUFFER_STATE cur = YY_CURRENT_BUFFER;
        yylineno = cur -> yy_bs_lineno;
    }
}

Representation of always and initial blocks/statements

Issue Description

Current AST representation of always @(posedge clk) begin ... end is horrible to sift through.

The fix:

This code is being refactored on the feature/procedural-refactor branch. There will be a new ast_block_statement object which incorporates the intrinsic properties of an always / initial block like their event triggers, declared values and their various procedural statements.

Support for BISON 3.3.1 (or above)

Please delete or fill out each section as appropriate:


Issue Description

Current version requires BISON 3.0.4 or above (defined in CMakefiles.txt). However, it does not build under BISON 3.3.1 (version from homebrew formulae ).

What should happen:

Library build pass.

What actually happens:

/usr/bin/m4:/usr/share/bison/skeletons/yacc.c:1652: undefined macro `b4_symbol(610, has_type)'
/usr/bin/m4:/usr/share/bison/skeletons/yacc.c:1652: undefined macro `b4_symbol(610, has_type)' 
/usr/share/bison/skeletons/yacc.c:1652: error: b4_symbol_if: field has_type of 610 is not a Boolean: 
/usr/share/bison/skeletons/yacc.c:1652: the top level                                                
/root/verilog-parser/src/verilog_scanner.l:3:14: fatal error: verilog_parser.tab.h: No such file or directory
     #include "verilog_parser.tab.h"

Steps to re-create:

Describe exactly how to re-create the bug.

$> install bison 3.3.1
$> make 

People to Notify:

Related Issues:

file name changed libbison-dev_3.0.4.dfsg-1_amd64.deb to libbison-dev_3.0.4.dfsg-1+b1_amd64.deb on remote server

Issue Description

! master # 245 errored 784730a
194 builds about 17 hours ago

The command "wget http://ftp.us.debian.org/debian/pool/main/b/bison/libbison-dev_3.0.4.dfsg-1_amd64.deb" failed and exited with 8 during . Your build has been stopped.

What problem / feature / issue are you raising? Describe in as much detail
as possible.

The name of the link to the deb file has changed on the remote server

from

http://ftp.us.debian.org/debian/pool/main/b/bison/libbison-dev_3.0.4.dfsg-1_amd64.deb

to

http://ftp.us.debian.org/debian/pool/main/b/bison/libbison-dev_3.0.4.dfsg-1+b1_amd64.deb

libbison-dev_3.0.4.dfsg-1+b1_amd64.deb 25-Feb-2017 02:59 433122

What should happen:

What should normal behaviour for the given input be?
in the travis file

https://github.com/ben-marshall/verilog-parser/blob/master/.travis.yml

Line 14 should be replaced with the correct name:

http://ftp.us.debian.org/debian/pool/main/b/bison/libbison-dev_3.0.4.dfsg-1+b1_amd64.deb


People to Notify:

Related Issues:

Parse failed

Issue Description

Parse failed on Verilog file/module

What should happen:

There should be no error

What actually happens:

verilog-parser$ ./build/release/src/parser ../add.v
../add.v line 21 - ERROR: syntax error, unexpected KW_TRI1
- 'tri1'
 - Parse failed

Steps to re-create:

// add.v
module add (
        cin,
        dataa,
        datab,
        cout,
        result);
input   cin;
input   [7:0] dataa;
input   [7:0] datab;
output  cout;
output  [7:0] result;


wire gnd;
wire vcc;
wire unknown;

assign gnd = 1'b0;
assign vcc = 1'b1;
assign unknown = 1'bx;

tri1 devclrn;
tri1 devpor;
tri1 devoe;

endmodule
$> make clean
$> make all
$> make debug
$> ./build/debug/src/parser add.v

People to Notify:

Related Issues:

Memory Leaking

Issue Description

The library has alot of memory leaks. The sneaky system in src/verilog_ast.c for keeping track of alloc'd memory actually causes segfaults. The whole thing needs going through with a fine tooth comb to fix the leaks.

Improve Coverage

This is very much a todo item. As of commit 72498fe code coverage for the current test suite is hovering just above 50%. This needs to be 95% at least.

Todo:

  • List which parts of the parser and AST constructor are not being hit.
  • Write tests for those parts.

`undef at end of file causes segfault in some cases.

Issue Description

When parsing large numbers of files, a `undef directive appearing as the penultimate token in a file will cause a segfault. When running with valgrind however, it does not, so it is very much a heisenbug.

Steps to re-create:

Feed the parser a set of files, and one of them should have a `undef on the last line.

$> make clean
$> make all
$> ./src/parser ../../tests/*.v

Segfault when running with multiple files as input.

There is something in the parsing code for the UDP rules which causes a segfault when more than one input file is supplied to the test app on the command line.

Further diagnosis is needed to work out which rule, but isolating each one from the grammar in turn should be enough to expose the code at fault.

Steps to repeat:

$> make clean
$> make setup
$> make test
$> build/bin/verilog-app tests/*.v

Valgrind reports the problem as coming from inside malloc, which is missleading. The problem goes away when UDP parsing is skipped, and only appears after the UDP action code was added,

Inadequate Hash Table Structure

Issue Description

In the interests of getting something working quickly, the ast_hashtable structure in verilog_ast_common.h/c is implemented over the top of ast_list, and all operations take O(N) time.

What should happen:

It should be a proper hash table, with proper hashing and all that.


People to Notify:

Pre-Processor Support

Issue Description

There is currently no pre-processor support at all for the compiler directives described in section 19 of the Verilog 2001 specification.

What should happen:

Graceful handling of all compiler directives, with correct substitution of macros and adherence to `ifdef constructs.

What actually happens:

Parser errors whenever a compiler directive is encountered.

Steps to re-create:

Feed the test app any program with a pre-processor directive in it.


People to Notify:

Related Issues:

None.

Enumerating Module Ports Causes Segfault

Issue Description

Enumerating Module Ports Causes Segfault depending on how the ports are declared in the source file. If the source uses the port_expression part of the grammar, this will trigger the segfault. The fix will involve re-writing the port rule in verilog_parser.y and modifying it's type.

Global Variable Defined in Header

Sorry to bother, but I have a question on the following line:

ast_metadata meta; //!< Node metadata.

Can anyone please explain a little bit, why here is global variable definition and why it is mysteriously indented. Do you mean to put it in the structure defined above it?

Personally, I think this practice makes it harder to use this Verilog parser in a bigger project as if two source files include this header, there will be a duplication of definition in the linking stage.

If this global variable is really needed, can I suggest to declare it here using extern and define it in verilog_ast.c ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.