GithubHelp home page GithubHelp logo

nic30 / hdlconvertor Goto Github PK

View Code? Open in Web Editor NEW
277.0 22.0 63.0 14.87 MB

Fast Verilog/VHDL parser preprocessor and code generator for C++/Python based on ANTLR4

License: MIT License

ANTLR 13.91% C++ 47.28% Python 6.79% VHDL 7.01% Verilog 8.63% SystemVerilog 12.07% CMake 0.61% Jupyter Notebook 1.87% Dockerfile 0.10% Cython 1.73%
parser verilog fpga vhdl systemverilog systemverilog-parser vhdl-parser verilog-parser antrl4 python

hdlconvertor's People

Contributors

ameyavs avatar dalance avatar fredrequin avatar hdl4fpga avatar henryiii avatar hjnauman avatar hs-apotell avatar imec-myhdl avatar johnsbrew avatar khwong-c avatar kleinesfilmroellchen avatar lionheart117 avatar mewais avatar nic30 avatar pear0 avatar stefan-titus-keysight avatar taichi-ishitani avatar thomasb81 avatar wsnyder avatar zegervdv 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hdlconvertor's Issues

[SV parser] randomize_call

randomize_call:

Parsing of

void'( randomize( p.address, p.length, p.payload )
failed

LRM state for following definition
randomize_call ::=
randomize { attribute_instance }
[ ( [ variable_identifier_list | null ] ) ]
[ with [ ( [ identifier_list ] ) ] constraint_block ]

However

the 'with' part should use curly bracket instead of bracket.

and

variable_identifier_list should be a hierarchical_variable_identifier_list that does not exist in order to reference hierarchical variable.

Update vhdl

Hello,
Is there any way to update a vhdl file after parsing. I need to take the generics from an entity and then add few more and hence create a new/update the vhdl file.

Thanks,
Mohit

release GIL during parsing

Currently the Global Interpreter Lock is held even if only C++ code is parsing. Releasing GIL during this time will make multithreading as fast as multiprocessing without need for inter process communication.

A humble request

Hello Nic,

I have a humble request, Could you please remove the examples you have added in the tests, I am not supposed to share such information, I can get in serious trouble. I am very sorry for the inconvenience and thanks a lot for your fixes and help.

Failure to Install

I am attempting to install via pip using python3.7 from Anaconda on Red Hat Linux.

uname -a
Linux 2.6.32-696.el6.x86_64 #1 SMP Tue Feb 21 00:53:17 EST 2017 x86_64 x86_64 x86_64 GNU/Linux

gcc --version
gcc 4.8.3

In file included from /tmp/pip-install-qkuw3rae/hdlConvertor/src/antlr4-runtime-cpp/antlr4-runtime.h:10:0,
                 from /tmp/pip-install-qkuw3rae/hdlConvertor/src/vhdlConvertor/../VhdlParser/vhdlParser.h:7,
                 from /tmp/pip-install-qkuw3rae/hdlConvertor/src/vhdlConvertor/packageHeaderParser.h:4,
                 from /tmp/pip-install-qkuw3rae/hdlConvertor/src/vhdlConvertor/packageHeaderParser.cpp:1:
/tmp/pip-install-qkuw3rae/hdlConvertor/src/antlr4-runtime-cpp/antlr4-common.h:10:19: fatal error: codecvt: No such file or directory
 #include <codecvt>
                   ^
compilation terminated.

I am missing this codecvt include. Where did it come from and should getting it be part of the install process?

g++ FATAL error

Hello, I am not able to install. When I try to run the command:
python3 hdlConvertor-master/hdlConvertor-master/setup.py install

I get this error:
running install
running build
running build_ext
building 'hdlConvertor' extension
g++ -pthread -shared -o build/lib.linux-x86_64-3.5/hdlConvertor.cpython-35m-x86_64-linux-gnu.so
g++: fatal error: no input files
compilation terminated.

My gcc version- 5.4.0
Python version-3.5.1

I am not able to debug the issue. Could you please help?

Thanks,
Mohit

New ANTLR C++ release

I have not had any luck compiling with the latest ANTLR C++ runtime release. Any chance you have time to update to latest ANTLR version?

Parse crashes on VHDL 'range attribute

Example file:

architecture arch of module is
begin
    data <= i_data(i_data'range) and i_mask;
end architecture arch;

Parsing is successful when leaving out the 'range.
There are no visible errors, even with debug=True.

[SV parser] interface_class not parse

interface_class_declaration is missing from the grammar provided by the standard.

So such contruction are not recognized:
'''
interface class intf_class;
endclass
'''

It impact :
p194.sv, p196.sv, p197.sv,p198.sv,p199.sv,p200_2.sv,p200.sv,p201.sv,p202.sv

I am not 100% sure, but following fix work:

package_or_generate_item_declaration:
      net_declaration 
      | data_declaration 
      | task_declaration 
      | function_declaration 
      | checker_declaration 
      | dpi_import_export 
      | extern_constraint_declaration 
      | class_declaration
      **| interface_class_declaration**
      | class_constructor_declaration 
      | ( local_parameter_declaration | parameter_declaration ) SEMI 
      | covergroup_declaration 
      | assertion_item_declaration 
      | SEMI;
anonymous_program: KW_PROGRAM SEMI ( anonymous_program_item )* KW_ENDPROGRAM;
anonymous_program_item:
      task_declaration 
      | function_declaration 
      | class_declaration
      **| interface_class_declaration**
      | covergroup_declaration 
      | class_constructor_declaration 
      | SEMI;

Visibility of preprocessor defines between the languages

Main problem is that verilog uses includes and vhdl imports.
The functionality is different and how to `define something in verilog for vhdl or reversed, is not known to me.
There are tools which supports vhdl+verilog in single design, how does the preprocessor fork there?
For example how it works in Xilinx Vivado or Intel Quartus?

proper include dir

separate public *.h from the rest of the project for future c++ lib extraction

Add TCL parser

TCL grammar already present. Only API for Python should be added.
TCL grammar is very simple and can be also implemented directly in python maybe this can be more flexible.

Installation issue, 'cl.exe' failed with exit status 2

Hi,

Thanks for uploading the package however I have been unable to install. I have downloaded the entire package and am trying to install using the command "python setup.py install" however I return the following error:

ime-cpp\BufferedTokenStream.cpp(387): warning C4273: 'antlr4::BufferedTokenStrea
m::getText': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\BufferedTokenStream.h(91): note: see previous definition of 'getText'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\BufferedTokenStream.cpp(391): warning C4273: 'antlr4::BufferedTokenStrea
m::getText': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\BufferedTokenStream.h(92): note: see previous definition of 'getText'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\BufferedTokenStream.cpp(399): warning C4273: 'antlr4::BufferedTokenStrea
m::fill': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\BufferedTokenStream.h(95): note: see previous definition of 'fill'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\BufferedTokenStream.cpp(410): warning C4273: 'antlr4::BufferedTokenStrea
m::InitializeInstanceFields': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\BufferedTokenStream.h(197): note: see previous definition of 'Initialize
InstanceFields'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /nolo
go /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\william\Desktop\hdlConvertor-master\hdlCo
nvertor-master\src/antlr4-runtime-cpp/ -IC:\Anaconda3\include -IC:\Anaconda3\inc
lude "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Pr
ogram Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program
Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" "-IC:\Program Files (x86)
\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\8.
1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\P
rogram Files (x86)\Windows Kits\8.1\include\winrt" "-IC:\Program Files (x86)\Mic
rosoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual
Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\includ
e\10.0.10150.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include
\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Fi
les (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.
1\include\winrt" /EHsc /TpC:\Users\william\Desktop\hdlConvertor-master\hdlConver
tor-master\src/antlr4-runtime-cpp\CharStream.cpp /Fobuild\temp.win-amd64-3.5\Rel
ease\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-ru
ntime-cpp\CharStream.obj -std=c++11
cl : Command line warning D9002 : ignoring unknown option '-std=c++11'
CharStream.cpp
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\IntStream.h(41): warning C4251: 'antlr4::IntStream::UNKNOWN_SOURCE_NAME'
: class 'std::basic_string<char,std::char_traits,std::allocator>' ne
eds to have dll-interface to be used by clients of class 'antlr4::IntStream'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CharStream.cpp(10): warning C4273: 'antlr4::CharStream::~CharStream': in
consistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CharStream.h(16): note: see previous definition of '{dtor}'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /nolo
go /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\william\Desktop\hdlConvertor-master\hdlCo
nvertor-master\src/antlr4-runtime-cpp/ -IC:\Anaconda3\include -IC:\Anaconda3\inc
lude "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Pr
ogram Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program
Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" "-IC:\Program Files (x86)
\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\8.
1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\P
rogram Files (x86)\Windows Kits\8.1\include\winrt" "-IC:\Program Files (x86)\Mic
rosoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual
Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\includ
e\10.0.10150.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include
\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Fi
les (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.
1\include\winrt" /EHsc /TpC:\Users\william\Desktop\hdlConvertor-master\hdlConver
tor-master\src/antlr4-runtime-cpp\CommonToken.cpp /Fobuild\temp.win-amd64-3.5\Re
lease\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-r
untime-cpp\CommonToken.obj -std=c++11
cl : Command line warning D9002 : ignoring unknown option '-std=c++11'
CommonToken.cpp
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\IntStream.h(41): warning C4251: 'antlr4::IntStream::UNKNOWN_SOURCE_NAME'
: class 'std::basic_string<char,std::char_traits,std::allocator>' ne
eds to have dll-interface to be used by clients of class 'antlr4::IntStream'
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\Exceptions.h(15): warning C4251: 'antlr4::RuntimeException::_message': c
lass 'std::basic_string<char,std::char_traits,std::allocator>' needs
to have dll-interface to be used by clients of class 'antlr4::RuntimeException'

c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\Exceptions.h(56): warning C4251: 'antlr4::IOException::_message': class
'std::basic_string<char,std::char_traits,std::allocator>' needs to h
ave dll-interface to be used by clients of class 'antlr4::IOException'
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\ProxyErrorListener.h(18): warning C4251: 'antlr4::ProxyErrorListener::_d
elegates': class 'std::set<antlr4::ANTLRErrorListener *,std::less<_Kty>,std::all
ocator<_Kty>>' needs to have dll-interface to be used by clients of class 'antlr
4::ProxyErrorListener'
with
[
_Kty=antlr4::ANTLRErrorListener *
]
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\Recognizer.h(147): warning C4251: 'antlr4::Recognizer::_mutex': class 's
td::mutex' needs to have dll-interface to be used by clients of class 'antlr4::R
ecognizer'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\mutex(76): note:
see declaration of 'std::mutex'
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\Recognizer.h(150): warning C4251: 'antlr4::Recognizer::_tokenTypeMapCach
e': class 'std::map<const antlr4::dfa::Vocabulary *,std::map<std::string,size_t,
std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>,std::less<const antlr
4::dfa::Vocabulary>,std::allocator<std::pair<const antlr4::dfa::Vocabulary,std::
map<_Kty,_Ty,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>>>' need
s to have dll-interface to be used by clients of class 'antlr4::Recognizer'
with
[
_Kty=std::string,
_Ty=size_t
]
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\Recognizer.h(151): warning C4251: 'antlr4::Recognizer::_ruleIndexMapCach
e': class 'std::map<std::vector<std::string,std::allocator<_Ty>>,std::map<std::s
tring,size_t,std::less<_Ty>,std::allocator<std::pair<const _Kty,unsigned __int64

,std::less<std::vector<_Ty,std::allocator<_Ty>>>,std::allocator<std::pair<con
st std::vector<_Ty,std::allocator<_Ty>>,std::map<_Kty,size_t,std::less<_Ty>,std:
:allocator<std::pair<const _Kty,unsigned __int64>>>>>>' needs to have dll-interf
ace to be used by clients of class 'antlr4::Recognizer'
with
[
_Ty=std::string,
_Kty=std::string
]
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\Vocabulary.h(185): warning C4251: 'antlr4::dfa::Vocabulary::_literalName
s': class 'std::vector<std::string,std::allocator<_Ty>>' needs to have dll-inter
face to be used by clients of class 'antlr4::dfa::Vocabulary'
with
[
_Ty=std::string
]
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\Vocabulary.h(186): warning C4251: 'antlr4::dfa::Vocabulary::_symbolicNam
es': class 'std::vector<std::string,std::allocator<_Ty>>' needs to have dll-inte
rface to be used by clients of class 'antlr4::dfa::Vocabulary'
with
[
_Ty=std::string
]
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\Vocabulary.h(187): warning C4251: 'antlr4::dfa::Vocabulary::_displayName
s': class 'std::vector<std::string,std::allocator<_Ty>>' needs to have dll-inter
face to be used by clients of class 'antlr4::dfa::Vocabulary'
with
[
_Ty=std::string
]
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(18): warning C4251: 'antlr4::CommonToken::EMPTY_SOURCE': s
truct 'std::pair<antlr4::TokenSource *,antlr4::CharStream *>' needs to have dll-
interface to be used by clients of class 'antlr4::CommonToken'
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(53): warning C4251: 'antlr4::CommonToken::_source': struct
'std::pair<antlr4::TokenSource *,antlr4::CharStream *>' needs to have dll-inter
face to be used by clients of class 'antlr4::CommonToken'
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(61): warning C4251: 'antlr4::CommonToken::_text': class 's
td::basic_string<char,std::char_traits,std::allocator>' needs to hav
e dll-interface to be used by clients of class 'antlr4::CommonToken'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(23): warning C4273: 'EMPTY_SOURCE': inconsistent dll lin
kage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(18): note: see previous definition of 'protected: static s
td::pair<antlr4::TokenSource *,antlr4::CharStream *> const antlr4::CommonToken::
EMPTY_SOURCE'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(23): error C2491: 'antlr4::CommonToken::EMPTY_SOURCE': d
efinition of dllimport static data member not allowed
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(25): warning C4273: 'antlr4::CommonToken::CommonToken':
inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(87): note: see previous definition of '{ctor}'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(30): warning C4273: 'antlr4::CommonToken::CommonToken':
inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(88): note: see previous definition of '{ctor}'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(43): warning C4273: 'antlr4::CommonToken::CommonToken':
inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(97): note: see previous definition of '{ctor}'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(51): warning C4273: 'antlr4::CommonToken::CommonToken':
inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(112): note: see previous definition of '{ctor}'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(70): warning C4273: 'antlr4::CommonToken::getType': inco
nsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(114): note: see previous definition of 'getType'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(74): warning C4273: 'antlr4::CommonToken::setLine': inco
nsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(128): note: see previous definition of 'setLine'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(78): warning C4273: 'antlr4::CommonToken::getText': inco
nsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(126): note: see previous definition of 'getText'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(95): warning C4273: 'antlr4::CommonToken::setText': inco
nsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(125): note: see previous definition of 'setText'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(99): warning C4273: 'antlr4::CommonToken::getLine': inco
nsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(129): note: see previous definition of 'getLine'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(103): warning C4273: 'antlr4::CommonToken::getCharPositi
onInLine': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(131): note: see previous definition of 'getCharPositionInL
ine'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(107): warning C4273: 'antlr4::CommonToken::setCharPositi
onInLine': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(132): note: see previous definition of 'setCharPositionInL
ine'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(111): warning C4273: 'antlr4::CommonToken::getChannel':
inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(134): note: see previous definition of 'getChannel'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(115): warning C4273: 'antlr4::CommonToken::setChannel':
inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(135): note: see previous definition of 'setChannel'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(119): warning C4273: 'antlr4::CommonToken::setType': inc
onsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(137): note: see previous definition of 'setType'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(123): warning C4273: 'antlr4::CommonToken::getStartIndex
': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(139): note: see previous definition of 'getStartIndex'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(127): warning C4273: 'antlr4::CommonToken::setStartIndex
': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(140): note: see previous definition of 'setStartIndex'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(131): warning C4273: 'antlr4::CommonToken::getStopIndex'
: inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(142): note: see previous definition of 'getStopIndex'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(135): warning C4273: 'antlr4::CommonToken::setStopIndex'
: inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(143): note: see previous definition of 'setStopIndex'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(139): warning C4273: 'antlr4::CommonToken::getTokenIndex
': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(145): note: see previous definition of 'getTokenIndex'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(143): warning C4273: 'antlr4::CommonToken::setTokenIndex
': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(146): note: see previous definition of 'setTokenIndex'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(147): warning C4273: 'antlr4::CommonToken::getTokenSourc
e': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(148): note: see previous definition of 'getTokenSource'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(151): warning C4273: 'antlr4::CommonToken::getInputStrea
m': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(149): note: see previous definition of 'getInputStream'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(155): warning C4273: 'antlr4::CommonToken::toString': in
consistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(151): note: see previous definition of 'toString'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(159): warning C4273: 'antlr4::CommonToken::toString': in
consistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(153): note: see previous definition of 'toString'
C:\Users\william\Desktop\hdlConvertor-master\hdlConvertor-master\src/antlr4-runt
ime-cpp\CommonToken.cpp(186): warning C4273: 'antlr4::CommonToken::InitializeIns
tanceFields': inconsistent dll linkage
c:\users\william\desktop\hdlconvertor-master\hdlconvertor-master\src\antlr4-runt
ime-cpp\CommonToken.h(155): note: see previous definition of 'InitializeInstance
Fields'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\
amd64\cl.exe' failed with exit status 2

I have visual studio 14 installed and it is finding the c++ compiler it just hits an error, any tips?

Thanks,

Will

Verilog parse causes Exeption: Variable has no type

Using the example uart.v in tests directory causes this error:

>>> res = hdlConvertor.parse("uart.v", "verilog")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
Exception: Variable has no type

[Feature] Sourcetrail: a perfect use case for hdlConvertor?

Today I'm here to discuss an amazing tool I recently discovered. It is called Sourcetrail:

https://www.sourcetrail.com/

It is an actively maintained and free for non-commercial use project.

Its super cool feature is related to the ability of indexing source codes of different types, at the same time, and navigating through them by making use of one of the most advanced code-browsing systems I've ever seen.

The real game-changer is, however, the Graph diagram, which really makes you understand how the code is structured.

At some point, I thought: wouldn't it be great for this tool to support Verilog/VHDL?

And then I did a great discovery, the Sourcetrails authors told me that it is indeed possible to add any custom parse-able language/data to the indexing database, by making use of this library:

https://github.com/CoatiSoftware/SourcetrailDB

From the project page:

The SourcetrailDB project provides write access to Sourcetrail database files. You can use the SourcetrailDB project to write an indexer for an arbitrary programming language (or other kinds of data, e.g. see poetry indexer example) and export a Sourcetrail database file that can be viewed and navigated within Sourcetrail.

There are even some nice examples which explain how to create an indexer for some poetry texts (!):

https://github.com/CoatiSoftware/SourcetrailDB/tree/master/examples/cpp_poetry_indexer

I asked Sourcetrails authors about adding VHDL support, and they told me that a robust VHDL parser providing the necessary elements to the SourcetrailDB would have done the trick.

So, hdlConvertor (and other tools) came into my mind.

By adding the parsed results to the SourcetrailDB, then something like the following could be obtained:

image

You could, for example, click on the SUBCOMPONENT entity of COMPONENT2, and this would expand it. Or, you could click on the SIGNALS section of COMPONENT1, and a box with all of the internally declared signals would appear. Or, even more, when clicking on a certain element of PORT OUT of COMPONENT 1, then Sourcetrail would show all of its references, for example, its connections with other components. Graphically and in the source code section.

The results would be extremely cool, in my opinion: a different way to visually navigate VHDL code, without having to go down to the RTL level. This has the potential to be a real time-saver, especially when navigating through complex designs. As a comparison, just consider each Verilog/VHDL component as a C++ class with internal variables, methods, instantiations and so on, and the interconnections between these classes.

Thus, I would like to discuss with you about the do-ability of my idea and the possible benefits arising from it.

support for preprocesor definitions from python

It is easy to pass a strings to preprocessor in form of python dict.
But how to ensure that the string is in correct format/language?
Should we care?

Should the define be only the string or it should be function which accepts the parameters?
If it should be a function what parameters it should have?
Need a list of defines defined in std. verilog/vhdl compilers (like func in gcc).

character literals / enumeration literals

character literals ('0', '1', 'Z' etc) are converted to an integer in line 176 of src/vhdlConvertor/literalParser.cpp by subtracting the value '0' This produces 'weird' results for anything else than '0' and '1'. for example std_logic is predefined enumeration('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-') Also the bit width is set to 8 (in line 168 of the same file).

Solving is probably easiest by doing a 2-step (visitor) approach: during the first visit do type annotation (like in myhdl) where signal/variable types/widths/initvalues/signed are resolved (in the myhdl case relevant info is stored in attributes of the nodes, but that is dynamic, so might not be the best approach in cpp, During the second visit the type is known, and conversion is relatively simple.

[SV parser] hierarchical function call

For p335.sv

Following construction is not recognize as a hierarchical function call:
C#(8)::ENCODER_f(encoder_in);

I think I already had this issue on my attempt to fix sv2012 grammar. Probably the LRM grammar is incorrect.
But now on sv2017Parser, the initial grammar of rule primary has change a lot so it is difficult to compare.

check parse errors before conversions

If the source file is in invalid format the ANTL4 will recover, however some of the parse tree nodes may become NULL. It would be very obscure to check every node access for null.

From this reason the ANTL4 parse errors has to be checked before conversion and by default conversion can not be performed even if the parser recovered. And proper exception should be raised instead

[Verilog preprocessor] crash / incorrect support of nested macro

Following verilog code crash the tool :

`define port_gen(inN,ouN) /* comment */ \
  input inN_clk; /* comment */ \
  input inN_rstn; /* comment */ \
  input inN_en; /* comment */ \
  input [7:0] inN_data;/* comment */ \
  /* comment */ \
  output [7:0] ouN_data; 

`define out_gen down_data

`define	sqr( x ) (x * x) // comment

`define	sum( a /* comment */ , b /* comment */ ) /* comment */ \
  (a + b)

`define sumsqr(
    a // comment
  ,
    b // comment
  ) \
  `sum ( \
    `sqr(a) \
   , \
    `sqr(b) \
   )


module macro();
 `port_gen(up,down)
 
  assign `out_gen = `sumsqr(
            up_data /* input data */
           ,
            (4 + 8) /* 12 */
           );

endmodule

[SV parser] interface class inside a class must not be supported.

( attribute_instance )* ( class_property | class_method | class_constraint | class_declaration | interface_class_declaration | covergroup_declaration )

Interface class construction is not allowed inside a class.
I test this code on a famous simulator...

test_3.sv.txt

class Myclass;

	interface class MyClassItf;
	endclass

endclass

xrun(64): 1X.XX-sXXX: (c) C0p7r1ght 1995-20XX C4d3nc3 D3s1gn S7st3ms, 1nc.
TOOL: xrun(64) 19.03-s001: Started on Aug 12, 2019 at 19:39:57 CEST
xrun
-sv
test_3.sv
-ams_lorder XC3L18M
file: test_3.sv
interface class MyClassItf;
|
xmvlog: *E,CLSSCP (test_3.sv,4|15): An interface class cannot be declared within this scope.
xmvlog: *W,NOTOPL: no top-level unit found, must have recursive instances.
Total errors/warnings found outside modules and primitives:
errors: 1, warnings: 1
xrun: *E,VLGERR: An error occurred during parsing. Review the log file for errors with the code *E and fix those identified problems to proceed. Exiting with code (status 1).
TOOL: xrun(64) 1X.XX-sXXX: Exiting on Aug 12, 2019 at 19:39:57 CEST (total: 00:00:00)

xmhelp: 1:X.XX-sXXX (c) C0p7r1ght 1995-20XX C4d3nc3 D3s1gn S7st3ms, 1nc.
xmvlog/CLSSCP =
A class or interface class was declared in a scope where it is not allowed.

VHDL architecture is not parsed

Nice library - thanks for sharing it!

I have installed it on Lubuntu 18.10 x64. The parser seems generally to work, however it does not handle any VHDL architecture content. For example, the file 'mux.vhd' that is provided as test example is turned into the structure stored in the attached file 'mux_ast.txt':

mux_ast.txt

The entire following section of 'mux.vhd' is not parsed at all:

' process(i0,i1,i2,i3,sel)
' begin
' case sel is
' when "00" => bitout <= i0;
' when "01" => bitout <= i1;
' when "10" => bitout <= i2;
' when others => bitout <= i3;
' end case;
' end process;

My understanding was that all the VHDL 2002 constructs should be understood and parsed, shouldn't it?

Toplevel assignments ignored in VHDL

Parsing a VHDL file, the toplevel assignments in a process are not parsed.

Example VHDL input:

architecture arch of module is
begin
   data <= i_data and i_mask;
end architecture arch;

I get a module:

(Pdb) pp d.objs
[<hdlConvertor.hdlAst.HdlModuleDef object at 0x7f6fc6d75120>]

but it has no content:

(Pdb) pp d.objs[0].objs
[]

Verilog Assign to Concatenation Error

Verilog allows concatenated values on the left hand side of an assign statement. From this code:

assign {sa00_mc, sa10_mc, sa20_mc, sa30_mc} = mix_col(sa00_sr,sa10_sr,sa20_sr,sa30_sr);

However an attempt to parse this file results in the following error:

hdlConvertor._hdlConvertor.ParseException: wrong assign initialisation

The grammar seems to support this assignment style. I see net_concatenation included in net_lvalue which is used by net_assignment, so it's not clear to me what might be happening.

Segmentation fault

Hello,

Thanks for all the solutions, Its working now well.

But for vhdl files having ~1000 lines , I am getting the segmentation fault. I am not really sure why is this happening. Could you please help me here.

release v1.3: VDHL-2008, SV2017, AST as Python objects, sim. part

  • [done] VHDL will get new full 2008 grammar
  • [done] all AST object will have own class defined in Python and instantiated by C++ (JSON conversion will disappear from C++)
  • [done] AST and HDL objects will be simplified to reduce codebase and to simplify processing
  • [done] separate C++/Python parts, proper include directory
  • [done] error reporting before it is too late
  • [done] CMake C-lib only install target
  • [done] replace Verilog2001 and SystemVerilog2012 by sv1800-2017
    • [done] fix performance issues #53 (entirely hand rewritten grammar, all Icarus + hdlConvertor Verilog sources ~1.5s)
    • [done] fix operator priority
  • [done] Verilog preprocessor: proper path stack for transitive include resolution + tests
    • [done] Python API for macro database
    • [done] fixed ifdef marco substitution, include
    • [done] expansion of macros in macro which is a result of macro expansion
    • [done] fixed __LINE__, __FILE__ #79
  • [done] full reverse conversion to Verilog/VHDL to assert the functionality
    • [done] hierarchy, connections, expressions, statements
      • [done] VHDL
      • [done] Verilog
    • functions, tasks etc.
      • [done] VHDL
      • [done] Verilog
    • sim part
      • [done] VHDL
      • [done] Verilog
  • [done] move utils scripts to a separate repo
  • [done] smart pointers for hdlObjects (to solve memory leaks in exception handling)

After this update:

  • PIP release
    • minify change list
  • [done] Lexer only mode which will print or return lexer tokens (mainly for debugging, implemented as a flag on parser/preprocessor containers)
  • deb for c++ lib in public repo
  • custom typedefs
    • SV
    • VHDL

A fast System Verilog grammar

antlr/grammars-v4#1438
736ae3b#commitcomment-33951857

The current sv2012 grammar is so slow that it is "not possible" to use it for real libraries.
The reason for this is simply the code of the grammar.
In order to improve it we have to remove simple rules and deal with ambiguity. Because the main performance issues comes from ambiguity and full context analysis caused by it.

It may be wise to first update to sv2017 and optimize after.
The goal is also to get rid off separate grammar for a Verilog2001 because currently only reason for this separation is a performance.

Build system regression

Any change in the hdlConvertor trig the recompilation of libparsesv.a, libparseVerilog.a, libparseVhdl.a
even if it is not necessary.

Because libparsesv.a, libparseVerilog.a, libparseVhdl.a containt the antlr C grammar details, the compilation take time and is useless if grammar does not change.

This is a pain in the development short loop : edit-compile-test.

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.