nic30 / hdlconvertor Goto Github PK
View Code? Open in Web Editor NEWFast Verilog/VHDL parser preprocessor and code generator for C++/Python based on ANTLR4
License: MIT License
Fast Verilog/VHDL parser preprocessor and code generator for C++/Python based on ANTLR4
License: MIT License
hdlConvertor/grammars/sv2017Parser.g4
Line 1474 in 845edd1
Parsing of
failedLRM 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.
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
The verilog grammar allow to specify grammar in different way. This one is not yet implemented in hdlConvertor:
module paramM ();
parameter integer DWIDTH = 9;
parameter NOTYPE = 8 ;
endmodule
For reference : antlr/grammars-v4#1343
Hello,
ANTRL4 should always be separated from hdlConvertor but no package in ubuntu/respository existed.
Now when I see someone maybe using this I can create packages into linux respositories and also make an update.
Who does use this library?
On which distribution or system?
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.
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.
Chisel3 compatibility layer, simple format.
Grammar available
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?
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
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?
function int[$] GenQueue(int low, int high);
The grammar does not support the definition of queue type like this.
It seems that the other tools does not underestand this syntax as well.
returning-queue-from-function-in-systemverilog
int[$] q;
Similar problem as previous one. Everywhere except in this example the [$]
is always behind variable id. It seems to me that the example is wrong.
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
.
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;
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?
separate public *.h from the rest of the project for future c++ lib extraction
It would be interesting to know on the project readme what is the current VHDL and Verilog standard which is supported by the parser.
Otherwise the errors are reported after the conversion is done and some errors may broke the tree so much that conversion code will fail on nullptr dereference as required part is simply missing.
https://github.com/Nic30/hdlConvertor/blob/master/include/hdlConvertor/parserContainer.h#L63
Current dpi_import_export does not support escaped symbol as a target to import but p940.sv says it can be.
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.
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
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
Today I'm here to discuss an amazing tool I recently discovered. It is called Sourcetrail:
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:
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.
p832.sv, p833.sv, p834.sv, p835.sv,p837.sv, p845.sv, p884.sv
Broken lexer.
Hi!
Could you add a LICENSE or COPYING file to this repository?
Thanks!
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 ('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.
Each test is executed twice on setup.py test.
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.
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
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
hdlConvertor/grammars/sv2017Parser.g4
Line 271 in 346be63
Interface class construction is not allowed inside a class.
I test this code on a famous simulator...
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.
There is an algorithm which prints braces in expression only if they are truly required, based on operator precedence.
https://github.com/HardwareIR/netlistDB/blob/master/src/serializer/serializer.cpp#L56
Need an equivalent for toVhdl/toVerilog for output to look nice.
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':
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?
For a complex circuits many nodes has to be generated maybe it would be better to construct python objects only if they are accessed.
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 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.
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.
__LINE__
, __FILE__
#79Check if it possible to use https://github.com/deftio/travis-ci-cpp-example with python module.
If I have a constant array like this:
Add doc for Entity, Architecture Module, functions, statements etc.
Comments are staged on hidden channel. It would be useful to include original HDL comments (maybe optionally) for doc generators etc.
https://stackoverflow.com/questions/12485132/catching-and-keeping-all-comments-with-antlr
(first answer which was accepted is not actual ...)
It would be useful to also have C++ implementation only. For this reason Python dependency fro hdlObjects and parsers has to be removed. Arbitrary int (PyLong) can be replaced by boost cpp_int
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.