Giter Site home page Giter Site logo

suoto / hdl_checker Goto Github PK

View Code? Open in Web Editor NEW
184.0 17.0 20.0 1.08 MB

Repurposing existing HDL tools to help writing better code

License: GNU General Public License v3.0

Python 95.77% Shell 0.76% PowerShell 1.77% SystemVerilog 0.18% Verilog 0.18% VHDL 0.96% Dockerfile 0.37%
vhdl modelsim xilinx verilog systemverilog python hdl xilinx-vivado syntax-checker lsp-server

hdl_checker's People

Contributors

bramhooimeijer avatar paulwebbster avatar rajesh-s avatar sethgower avatar suoto 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

hdl_checker's Issues

Add Verilog support

Minimal steps to add Verilog support:

  • Parser
    • Extract dependencies
    • Extract design units
  • Compilers
    • Different compilation binaries (vcom vs vlog for instance)
  • Static check adaptation

Source file parsing issues

The method VhdlSourceFile.changed often return False when a file has been changed, resulting in wrong returns for most methods triggered by it. Unit tests sometimes catch this error but sometimes it just misses.

Verilog error not detected

Hi,

I am using the hdl_checker in the following environment:

  • Arch Linux, 5.3.11-arch1-1 64-bit
  • Neovim 0.4.3 + coc.nvim 0.0.74-266a37f273 and recommended configuration
  • hdl_checker 0.6.11
  • vivado 2018.3 (added to the $PATH)
  • ghdl 0.36
  • verilator 4.020
  • iverilog 10.3-1

And using this verilog file to test it:

module simple_mux(
	input [1:0] x,
	input [1:0] y,
	input s,
	output reg [1:0] m
	);

	this_is_an_error

	always @ (x or y or s)
	begin
		if(s==0)
			m=y;
		else
			m=x;
	end
endmodule

Looking at the log I see the error in the code was not detected, neither in the log file nor in Neovim. Is there something in my configuration/environment missing or wrong?

INFO    | 10:39:41 | hdl_checker.server @ run():205 MainThread |	Starting server. Our PID is 57584, no parent PID to attach to. Version string for hdl_checker is '0.6.11'
INFO    | 10:39:41 | pyls.python_ls @ start_io_lang_server():85 MainThread |	Starting HdlCheckerLanguageServer IO language server
WARNING | 10:39:41 | pyls.config.config @ __init__():55 MainThread |	Failed to load pyls entry point 'autopep8': No module named 'autopep8'
WARNING | 10:39:41 | pyls.config.config @ __init__():55 MainThread |	Failed to load pyls entry point 'pydocstyle': No module named 'pydocstyle'
WARNING | 10:39:42 | pyls.config.config @ __init__():55 MainThread |	Failed to load pyls entry point 'yapf': No module named 'yapf'
INFO    | 10:39:42 | hdl_checker.utils @ wrapper():361 MainThread |	m_initialize((), {'capabilities': {'textDocument': {'codeAction': {'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['',
                                                                                                               'quickfix',
                                                                                                               'refactor',
                                                                                                               'refactor.extract',
                                                                                                               'refactor.inline',
                                                                                                               'refactor.rewrite',
                                                                                                               'source',
                                                                                                               'source.organizeImports']}},
                                                  'dynamicRegistration': True},
                                   'codeLens': {'dynamicRegistration': True},
                                   'colorProvider': {'dynamicRegistration': True},
                                   'completion': {'completionItem': {'commitCharactersSupport': True,
                                                                     'deprecatedSupport': True,
                                                                     'documentationFormat': ['markdown',
                                                                                             'plaintext'],
                                                                     'preselectSupport': True,
                                                                     'snippetSupport': True},
                                                  'completionItemKind': {'valueSet': [1,
                                                                                      2,
                                                                                      3,
                                                                                      4,
                                                                                      5,
                                                                                      6,
                                                                                      7,
                                                                                      8,
                                                                                      9,
                                                                                      10,
                                                                                      11,
                                                                                      12,
                                                                                      13,
                                                                                      14,
                                                                                      15,
                                                                                      16,
                                                                                      17,
                                                                                      18,
                                                                                      19,
                                                                                      20,
                                                                                      21,
                                                                                      22,
                                                                                      23,
                                                                                      24,
                                                                                      25]},
                                                  'contextSupport': True,
                                                  'dynamicRegistration': True},
                                   'declaration': {'dynamicRegistration': True},
                                   'definition': {'dynamicRegistration': True},
                                   'documentHighlight': {'dynamicRegistration': True},
                                   'documentLink': {'dynamicRegistration': True},
                                   'documentSymbol': {'dynamicRegistration': True,
                                                      'symbolKind': {'valueSet': [1,
                                                                                  2,
                                                                                  3,
                                                                                  4,
                                                                                  5,
                                                                                  6,
                                                                                  7,
                                                                                  8,
                                                                                  9,
                                                                                  10,
                                                                                  11,
                                                                                  12,
                                                                                  13,
                                                                                  14,
                                                                                  15,
                                                                                  16,
                                                                                  17,
                                                                                  18,
                                                                                  19,
                                                                                  20,
                                                                                  21,
                                                                                  22,
                                                                                  23,
                                                                                  24,
                                                                                  25,
                                                                                  26]}},
                                   'foldingRange': {'dynamicRegistration': True,
                                                    'lineFoldingOnly': True,
                                                    'rangeLimit': 5000},
                                   'formatting': {'dynamicRegistration': True},
                                   'hover': {'contentFormat': ['markdown',
                                                               'plaintext'],
                                             'dynamicRegistration': True},
                                   'implementation': {'dynamicRegistration': True},
                                   'onTypeFormatting': {'dynamicRegistration': True},
                                   'publishDiagnostics': {'relatedInformation': True},
                                   'rangeFormatting': {'dynamicRegistration': True},
                                   'references': {'dynamicRegistration': True},
                                   'rename': {'dynamicRegistration': True,
                                              'prepareSupport': True},
                                   'signatureHelp': {'dynamicRegistration': True,
                                                     'signatureInformation': {'documentationFormat': ['markdown',
                                                                                                      'plaintext'],
                                                                              'parameterInformation': {'labelOffsetSupport': True}}},
                                   'synchronization': {'didSave': True,
                                                       'dynamicRegistration': True,
                                                       'willSave': True,
                                                       'willSaveWaitUntil': True},
                                   'typeDefinition': {'dynamicRegistration': True}},
                  'workspace': {'applyEdit': True,
                                'configuration': True,
                                'didChangeConfiguration': {'dynamicRegistration': True},
                                'didChangeWatchedFiles': {'dynamicRegistration': True},
                                'executeCommand': {'dynamicRegistration': True},
                                'symbol': {'dynamicRegistration': True,
                                           'symbolKind': {'valueSet': [1,
                                                                       2,
                                                                       3,
                                                                       4,
                                                                       5,
                                                                       6,
                                                                       7,
                                                                       8,
                                                                       9,
                                                                       10,
                                                                       11,
                                                                       12,
                                                                       13,
                                                                       14,
                                                                       15,
                                                                       16,
                                                                       17,
                                                                       18,
                                                                       19,
                                                                       20,
                                                                       21,
                                                                       22,
                                                                       23,
                                                                       24,
                                                                       25,
                                                                       26]}},
                                'workspaceEdit': {'documentChanges': True,
                                                  'failureHandling': 'textOnlyTransactional',
                                                  'resourceOperations': ['create',
                                                                         'rename',
                                                                         'delete']},
                                'workspaceFolders': True}},
 'initializationOptions': {},
 'processId': 57551,
 'rootPath': '/home/rnp/tmp/simple_mux',
 'rootUri': 'file:///home/rnp/tmp/simple_mux',
 'trace': 'off',
 'workspaceFolders': []}) => {'capabilities': {'definitionProvider': True, 'hoverProvider': True, 'textDocumentSync': 1}}
WARNING | 10:39:42 | hdl_checker.base_server @ _setupIfNeeded():338 MainThread |	Not all directories exist, forcing setup
DEBUG   | 10:39:42 | hdl_checker.base_server @ clean():363 MainThread |	Cleaning up project
DEBUG   | 10:39:42 | hdl_checker.utils @ removeDirIfExists():310 MainThread |	Failed to remove /home/rnp/tmp/simple_mux/.hdl_checker
DEBUG   | 10:39:42 | hdl_checker.base_server @ _recoverCacheIfPossible():311 MainThread |	Couldn't read cache file /home/rnp/tmp/simple_mux/.hdl_checker/cache.json, skipping recovery
DEBUG   | 10:39:42 | hdl_checker.lsp @ _onConfigUpdate():244 MainThread |	Updating from {}
INFO    | 10:39:42 | hdl_checker.lsp @ showInfo():174 MainThread |	[INFO] Searching /home/rnp/tmp/simple_mux for HDL files...
DEBUG   | 10:39:42 | SimpleFinder @ __init__():46 MainThread |	Search paths: ['/home/rnp/tmp/simple_mux']
DEBUG   | 10:39:42 | SimpleFinder @ _addSource():46 MainThread |	Adding path /home/rnp/tmp/simple_mux/simple_mux.v (flags=None, library=None)
INFO    | 10:39:42 | SimpleFinder @ generate():93 MainThread |	Resulting project:
{'sources': ['/home/rnp/tmp/simple_mux/simple_mux.v']}
INFO    | 10:39:42 | hdl_checker.base_server @ setConfig():175 MainThread |	Replacing None with /tmp/hdl_checker_project_pid57584.json
DEBUG   | 10:39:42 | hdl_checker.base_server @ setConfig():181 MainThread |	Set config to WatchedFile(path=Path('/tmp/hdl_checker_project_pid57584.json'), last_read=0.0)
DEBUG   | 10:39:42 | hdl_checker.utils @ onNewReleaseFound():465 MainThread |	Current version is 0.6.11, latest is (0, 6, 11)
INFO    | 10:39:42 | hdl_checker.utils @ wrapper():361 MainThread |	m_initialized((), {}) => None
INFO    | 10:39:43 | hdl_checker.lsp @ lint():294 Thread-4 |	linting: file:///home/rnp/tmp/simple_mux/simple_mux.v
INFO    | 10:39:43 | hdl_checker.lsp @ _getDiags():330 Thread-4 |	Linting Path('/home/rnp/tmp/simple_mux/simple_mux.v') (saved=True)
DEBUG   | 10:39:43 | hdl_checker.base_server @ _getBuilderMessages():393 Thread-4 |	Building '/home/rnp/tmp/simple_mux/simple_mux.v'
DEBUG   | 10:39:43 | hdl_checker.base_server @ configure():226 Thread-4 |	Updating with base config:
{'sources': ['/home/rnp/tmp/simple_mux/simple_mux.v']}
DEBUG   | 10:39:43 | hdl_checker.utils @ runShellCommand():259 Thread-4 |	vcom -version
DEBUG   | 10:39:43 | hdl_checker.utils @ runShellCommand():283 Thread-4 |	Command '['vcom', '-version']' failed with [Errno 2] No such file or directory: 'vcom'
DEBUG   | 10:39:43 | hdl_checker.utils @ runShellCommand():259 Thread-4 |	xvhdl --nolog --version
DEBUG   | 10:39:43 | hdl_checker.utils @ runShellCommand():283 Thread-4 |	Command '['xvhdl', '--nolog', '--version']' failed with [Errno 2] No such file or directory: 'xvhdl'
DEBUG   | 10:39:43 | hdl_checker.utils @ runShellCommand():259 Thread-4 |	ghdl --version
DEBUG   | 10:39:43 | hdl_checker.builder_utils @ getWorkingBuilders():98 Thread-4 |	Builder ghdl worked
DEBUG   | 10:39:43 | hdl_checker.base_server @ configure():237 Thread-4 |	Builder class: <class 'hdl_checker.builders.ghdl.GHDL'>
DEBUG   | 10:39:43 | hdl_checker.builders.ghdl @ setup():127 Thread-4 |	/home/rnp/tmp/simple_mux/.hdl_checker already exists
DEBUG   | 10:39:43 | hdl_checker.utils @ runShellCommand():259 Thread-4 |	ghdl --version
INFO    | 10:39:43 | hdl_checker.builders.ghdl @ _checkEnvironment():98 Thread-4 |	GHDL version string: '['GHDL 0.36 (v0.36) [Dunoon edition]', ' Compiled with GNAT Version: 9.2.0', ' GCC back-end code generator', 'Written by Tristan Gingold.', '', 'Copyright (C) 2003 - 2019 Tristan Gingold.', 'GHDL is free software, covered by the GNU General Public License.  There is NO']'. Version number is '0.36'
INFO    | 10:39:43 | hdl_checker.database @ addSource():151 Thread-4 |	Adding /home/rnp/tmp/simple_mux/simple_mux.v, library=None, flags=(single=(), dependencies=())
DEBUG   | 10:39:43 | hdl_checker.database @ _parseSource():422 Thread-4 |	Parsing /home/rnp/tmp/simple_mux/simple_mux.v
DEBUG   | 10:39:43 | hdl_checker.lsp @ _handleUiInfo():122 Thread-4 |	UI info: Added 1 sources (workspace=<pyls.workspace.Workspace object at 0x7f10ccdf1d90>)
DEBUG   | 10:39:43 | hdl_checker.base_server @ _updateConfigIfNeeded():219 Thread-4 |	Updated config file to WatchedFile(path=Path('/tmp/hdl_checker_project_pid57584.json'), last_read=1574242782.232715)
DEBUG   | 10:39:43 | hdl_checker.utils @ runShellCommand():259 Thread-4 |	ghdl --dispconfig
DEBUG   | 10:39:43 | hdl_checker.builders.ghdl @ _parseBuiltinLibraries():121 Thread-4 |	library path is /usr/lib/ghdl
DEBUG   | 10:39:43 | hdl_checker.builders.ghdl @ builtin_libraries():272 Thread-4 |	Builtin libraries: (Identifier('src'), Identifier('vendors'), Identifier('synopsys'), Identifier('std'), Identifier('mentor'), Identifier('ieee'))
DEBUG   | 10:39:43 | hdl_checker.database @ getDependenciesUnits():682 Thread-4 |	Searching {Path('/home/rnp/tmp/simple_mux/simple_mux.v')} resulted in dependencies: set()
DEBUG   | 10:39:43 | hdl_checker.database @ getDependenciesUnits():706 Thread-4 |	Search paths: set()

Support for regex in sources

Hi
Is there, or do you have plans for, support for specifying multiple source files using regex or something similar? For example to include all .vhd and .vhdl files in all subdirectories:

{
   "sources": [
      "src/**/*.vhd*"
   ]
}

Report paths not built as a diagnostic

During the compilation sequence resolution, unsatisfied dependencies (that is, dependencies that failed to be mapped to file) are not compiled and nothing is reported to the user. Only way right now to detect this has happened is looking at the logs.

Setup HOWTO. Compilers' default flags.

The howto setup page, section 'Compilers' default flags', should say that the default flags have scope 'single'. I was mistaken into believing they are 'global'.

Project files

I saw in the hdl_checker wiki the page to create a project, but I could not file where (directory) the project file should be saved ($HOME, root directory of the project, etc..) and how the project file should be named. Could please clarify these two questions? Thanks. :)

Unable to add builder options with format "<option> <value>"

Builder options that use whitespace to separate the option from the name are placed incorrectly to the builder.
When defining the batch_build_flags in the configuration file as follows

batch_build_flags = -v --some-option some_value

it is not guaranteed that --some-option will be followed by some_value as the user expects.

Server should also search for files when config file has no sources

A JSON config without a sources key should trigger searching for sources under the root URI. right now that only happens with no config file is passed or the config file is not readable.

Main idea is to allow the config files to coordinate search paths.

For example, given the structure below:

<root>
  +-> common_code
  |   '-> src
  |   '-> testbench
  +-> component_a
  |   '-> src
  |   '-> testbench
  '-> some_project
      '-> src
      '-> testbench

The only thing the tool needs to know is where else to search besides the current root URI. That must be achieved by the following some_project/.hdl_checker.config content:

{
    "include": [
        "../common_code/.hdl_checker.config",
        "../component_a/.hdl_checker.config"
    ]
}

The same idea should be applied to included files recursively.

GHDL builder adapter doesn't caches rebuilds

Given the following project hierarchy

+- top_module
    |
    +- instance of 'submodule'
        |
        +- common_package

and the following steps:

  1. Setup the project as usual
  2. Make some change to common_package like add a constant and build it
  3. Build top_module

It is expected that the GHDL builder adapter should catch the error thrown by the ghdl compiler telling us that submodule must be recompiled as well so the user doesn't need to manually build submodule and then top_module.

ModelSim builder adapter already have this implemented.

How to add unisim library?

Hello, thanks for your great work, it all looks promising, especially with the vs code plugin. The only thing I am not getting is how to add specific arguments to pass to ghdl (like library search paths and ieee=synopsys

Bug in version checking

I just upgraded to 0.6.10 but I get a message that 0.6.9 is a newer version

LSP :: HDL Checker version 0.6.9 is out! (current version is 0.6.10)

ModelSim builder fails to parse some rebuild messages

ModelSim compiler implementation fails to catch some rebuild cases. The output is something like

Entity work.component_a was not selected for default binding because it is out of date relative to dependency work.package_a.

Given the following hierarchy (the initial build worked as expected)

  • source_a (component_a, package_a)
    • component_a (package_a)

The following sequence should reproduce this behaviour

  1. Build source_a
  2. Build package_a
  3. Make some changes to package_a
  4. Build package_a to update this changes
  5. Building source_a gives the warning above

Expected result:

  1. When building source_a, the builder should parse the compiler output and identify the need to rebuild work.component_a
  2. Rebuild work.component_a
  3. Build source_a again (repeat from 1 if necessary)

The error is forwarded to the caller so it shows up on the error messages.

hdl checker on termux

I am trying to get hdl checker working on termux with neovim and coc, but when installing with "pip install hdl-checker --upgrade " i get the following error and hdl language server isnt starting

๎‚ฐ โŒ˜ โœ˜ ๎‚ฐ hdl_checker --version                       ๎‚ฒ ~
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/hdl_checker", line 11, in <module>
    load_entry_point('hdl-checker==0.6.11', 'console_scripts', 'hdl_checker')()
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/hdl_checker/server.py", line 29, in <module>
    from pyls.python_ls import start_io_lang_server  # type: ignore
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyls/python_ls.py", line 10, in <module>
    from pyls_jsonrpc.streams import JsonRpcStreamReader, JsonRpcStreamWriter
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/pyls_jsonrpc/streams.py", line 5, in <module>
    import ujson as json
ImportError: dlopen failed: cannot locate symbol "Buffer_AppendShortHexUnchecked" referenced by "/data/data/com.termux/files/usr/lib/python3.8/site-packages/ujson.cpython-38.so"...
 9 ๎‚ฐ โŒ˜ โœ˜ ๎‚ฐ

Help to design the low-level, LLVM-like universal HDL language

FPGA world suffers a lot from fragmentation - some tools produce Verilog, some VHDL, some - only subsets of them, creating low-level LLVM-like alternative will help everyone, so HDL implementations will opt only for generating this low-level HDL and routing/synthesizers accept it. LLVM or WebAssembly - you can see how many languages and targets are supported now by both. With more open source tools for FPGA this is more feasible now than ever. Most of the people suggest to adapt FIRRTL for this. Please check the discussion and provide a feedback if you have any. There is a good paper on FIRRTL design and its reusability across different tools and frameworks.

Such thing can help for static analysis like LSP and Clang helped for C/C++.

See f4pga/ideas#19

Maintaining project file

@suoto I find your project really interesting, you had great idea!

There is only one thing that bothers me. Do you use hdlcc on a daily basis?
It looks like project files for hdlcc describe FPGA project file structure. Usually RTL file structure of FPGA project is also described in different files (for example TCL scripts or project files generated by vendors IDEs). Maintaining both is inconvenient and it is easy to forget to update hdlcc project file. Would you be so nice to explain how you handle this issue?

Can't get messages when source has non standard characters

Just tried pasting a bit of code in which opening and closing double quotes (", U+0022) were converted into left double quote (โ€œ, U+201C) and right double quote (โ€, U+201D), and could not get any messages back. Looking at the log I can see that ModelSim in this case seems to be called but it returns nothing.

hdlcc running on a different process

hdlcc running on a different process is a possible fix for issue #13.
Link other issues arising from hdlcc running inside the editor's Python shell to this issue.

Helper tools to autogenerate PRJ config from other file formats

Hello,

First of all, I'd like to thank you for vim-hdl and hdlcc. They are great tools and have a lot potential.
I think a useful addition would be to add simple tools which would automatically generate PRJ file from other project files e.g. Vivado *.XPR projects or *.XISE projects.
My rationale is that for large projects typing the PRJ configuration by hand can be a nightmare.
Even worse, in my job I have to frequently switch between many projects, which effectively prevents me from using hdlcc on a daily basis.

Make compiler built in libraries dynamic

Moving suoto/vim-hdl#4 to hdlcc.

Built-in libraries are statically defined, which means that things will break on different environments. We can either use the compiler to get them somehow or create an option for the user to set manually. Using the compiler is the preferred approach.

hdlcc standalone profiling not useful

hdlcc standalone profiling results are not useful because the work itself is done inside another thread.

Current results look like this:
image

CI tests only catch if the switch works, it doesn't checks the profiling output itself.

[PATCH] The json name for the builder is "builder_name" and not "builder".


hdl_checker/base_server.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hdl_checker/base_server.py b/hdl_checker/base_server.py
index cb990dc..44d8d40 100644
--- a/hdl_checker/base_server.py
+++ b/hdl_checker/base_server.py
@@ -225,7 +225,7 @@ class BaseServer(object): # pylint: disable=useless-object-inheritance

     _logger.debug("Updating with base config:\n%s", pformat(config))
  •    builder_name = config.pop("builder", None)
    
  •    builder_name = config.pop("builder_name", None)
       if builder_name is not None:
           builder_cls = getBuilderByName(builder_name)
       else:
    

--
2.24.0

What should be the name of the .json file?

First, thanks for this plugin!

The default recursive method says my project is too big and that I should pass a .json file to point to the right files.

I followed this section of the Wiki: https://github.com/suoto/hdl_checker/wiki/HOWTO:-Setting-up-a-project#using-json-file

However, I don't know how to call the json file. I tried project.json but it didn't work.
Could you please tell me how to name it?

For info I am using nvim + coc.nvim.
Thanks in advance!

Add support for LSP DiagnosticRelatedInformation

If source A depends on source B, errors on source B should be included in the diagnostics shown for source A (warnings can be suppressed) via DiagnosticRelatedInformation (more info: https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_publishDiagnostics).

This requires keeping track of the which of source A's dependencies triggered building source B (there might be more than one) so that the diagnostics from the latter can be included at a pertinent location on the former.

[PATCH] KeyError bug fixed in rebuildProject().

The dict servers has Path objects as key, not the project_file.


hdl_checker/handlers.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hdl_checker/handlers.py b/hdl_checker/handlers.py
index 9b363e1..a86fd86 100644
--- a/hdl_checker/handlers.py
+++ b/hdl_checker/handlers.py
@@ -236,7 +236,8 @@ def rebuildProject():
server = _getServerByProjectFile(project_file)
server.clean()
_logger.debug("Removing and recreating server object")

  • del servers[project_file]
  • root_dir = Path(p.dirname(project_file))
  • del servers[root_dir]
    _getServerByProjectFile(project_file)

--
2.24.0

Project file detection

First of all, nice work you did here.

Could you elaborate how hdlcc is detecting its project files? I was testing your vim-hdl example but couldn't figure it out completely

Fix project persistency implementation

Using Pickle to dump/load project objects to a file causes issues when the object is dumped in a Python shell and loaded from another shell that doesn't have access to the objects the original shell had.

For example, building a project within Vim then trying to build it via command line gives the following exception

Traceback (most recent call last):
  File "/home/asouto/bin/runner.py", line 213, in <module>
    main(runner_args)
  File "/home/asouto/bin/runner.py", line 161, in main
    project.readConfigFile()
  File "/home/asouto/utils/vim/vim/bundle/vim-hdl/python/vimhdl/project_builder.py", line 79, in readConfigFile
    obj = pickle.load(open(cache_fname, 'r'))
  File "/home/asouto/utils/vim/vim/bundle/vim-hdl/python/vimhdl/vim_client.py", line 25, in <module>
    import vim
ImportError: No module named vim

Checking a file from text content fails to include correct build flags

When compiling the file via its path (i.e., via HdlCodeCheckerBase.getMessagesByPath), flags are included correctly, but when compiling with content (i.e., via HdlCodeCheckerBase.getMessagesWithText), the builder call is missing arguments:

Compiling by path:

vlog -modelsimini <path/to/modelsim.ini> -quiet -work <path/to/library> \
  -sv +incdir+<path/to/include/folder> -lint -hazards -pedanticerrors   \
  -L library_name <path/to/file/on/disk>

Compiling with content:

vlog -modelsimini <path/to/modelsim.ini> -quiet -work <path/to/library> \
  -sv -L library_name <path/to/temporary/dump/file.sv>

Windows 10 FileNotFoundError without GIT installed

The FileNotFoundError is being generate, possibly because GIT is not installed.

filter_func = filterGitIgnoredPaths if isGitRepo(search_path) else _noFilter
File "C:\Users\cumby_w\AppData\Roaming\Python\Python37\site-packages\hdl_checker-0.6.9-py3.7.egg\hdl_checker\parser_utils.py", line 283, in isGitRepo
return p.exists(subp.check_output(cmd, stderr=subp.STDOUT).decode().strip())
File "C:\Program Files\Python37\lib\subprocess.py", line 395, in check_output
**kwargs).stdout
File "C:\Program Files\Python37\lib\subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Program Files\Python37\lib\subprocess.py", line 775, in init
restore_signals, start_new_session)
File "C:\Program Files\Python37\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

Wrong dependency error

While fiddling around with the LSP version I got some multiple definition warnings by the HDL Checker.

The code I used:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

package very_common_pkg is
end package;

package body very_common_pkg is
end package body;

When I removed (and later added) the last semicolon I got the warning
Dependency 'very_common_pkg' (library=None) has 2 definitions (files are "/home/skaupper/repos/vhdl-lsp-client/vhdl_test/lib1/foo.vhd", "/home/skaupper/repos/vhdl-lsp-client/vhdl_test/lib1/foo.vhd"). The selected option may not be the correct one
and at the same moment
Dependency 'very_common_pkg' (library=None) has 2 definitions (files are "/home/skaupper/repos/vhdl-lsp-client/vhdl_test/lib1/foo.vhd", "/tmp/tmp072shbl8.vhd"). The selected option may not be the correct one

Let me know if you need further information.

hdl_checker_log_pid44064.log

Added to Emacs lsp-mode

Just a FYI. I added support for HDL Checker to the Emacs package lsp-mode: emacs-lsp/lsp-mode#1167
So it is now easy to just add the following to your Emacs config. Setting the server path is only required if the server binary is not in your PATH

(require 'use-package)
(setq lsp-vhdl-server-path "~/.local/bin/hdl_checker")
(custom-set-variables
 '(lsp-vhdl-server 'hdl-checker))
(use-package lsp-mode
	     :config (add-hook 'vhdl-mode-hook 'lsp))

Type DefaultDict cannot be instantiated;

[object Object]
[Error - 5:03:20] Request textDocument/hover failed.
  Message: TypeError: Type DefaultDict cannot be instantiated; use collections.defaultdict() instead
  Code: -32602 

Paths were not built

I have a config that includes a single file as source but the hdl_checker log file says the file path is not built and missing simicolons etc. are not reported. Is is possible to find out what the problem is?

I'm starting hdl_checker in lsp mode through lsp-mode for Emacs and the full log is below

INFO    | 20:14:29 | hdl_checker.server @ startServer():219 MainThread |	Starting server. Our PID is 18461, no parent PID to attach to. Version string for hdl_checker is '0.6.9'
INFO    | 20:14:29 | pyls.python_ls @ start_io_lang_server():85 MainThread |	Starting HdlCheckerLanguageServer IO language server
WARNING | 20:14:29 | pyls.config.config @ __init__():55 MainThread |	Failed to load pyls entry point 'autopep8': No module named 'autopep8'
WARNING | 20:14:29 | pyls.config.config @ __init__():55 MainThread |	Failed to load pyls entry point 'pydocstyle': No module named 'pydocstyle'
WARNING | 20:14:29 | pyls.config.config @ __init__():55 MainThread |	Failed to load pyls entry point 'pylint': No module named 'pylint'
WARNING | 20:14:29 | pyls.config.config @ __init__():55 MainThread |	Failed to load pyls entry point 'rope_completion': No module named 'rope'
WARNING | 20:14:29 | pyls.config.config @ __init__():55 MainThread |	Failed to load pyls entry point 'rope_rename': No module named 'rope'
WARNING | 20:14:29 | pyls.config.config @ __init__():55 MainThread |	Failed to load pyls entry point 'yapf': No module named 'yapf'
INFO    | 20:14:29 | hdl_checker.utils @ wrapper():362 MainThread |	m_initialize((), {'capabilities': {'textDocument': {'codeAction': {'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['',
                                                                                                               'quickfix',
                                                                                                               'refactor',
                                                                                                               'refactor.extract',
                                                                                                               'refactor.inline',
                                                                                                               'refactor.rewrite',
                                                                                                               'source',
                                                                                                               'source.organizeImports']}},
                                                  'dynamicRegistration': True},
                                   'completion': {'completionItem': {'documentationFormat': ['markdown'],
                                                                     'snippetSupport': True},
                                                  'contextSupport': True},
                                   'declaration': {'linkSupport': True},
                                   'definition': {'linkSupport': True},
                                   'documentLink': {'dynamicRegistration': True},
                                   'documentSymbol': {'hierarchicalDocumentSymbolSupport': True,
                                                      'symbolKind': {'valueSet': [1,
                                                                                  2,
                                                                                  3,
                                                                                  4,
                                                                                  5,
                                                                                  6,
                                                                                  7,
                                                                                  8,
                                                                                  9,
                                                                                  10,
                                                                                  11,
                                                                                  12,
                                                                                  13,
                                                                                  14,
                                                                                  15,
                                                                                  16,
                                                                                  17,
                                                                                  18,
                                                                                  19,
                                                                                  20,
                                                                                  21,
                                                                                  22,
                                                                                  23,
                                                                                  24,
                                                                                  25,
                                                                                  26]}},
                                   'foldingRange': {'dynamicRegistration': True,
                                                    'lineFoldingOnly': False,
                                                    'rangeLimit': None},
                                   'formatting': {'dynamicRegistration': True},
                                   'hover': {'contentFormat': ['markdown',
                                                               'plaintext']},
                                   'implementation': {'linkSupport': True},
                                   'rangeFormatting': {'dynamicRegistration': True},
                                   'rename': {'dynamicRegistration': True},
                                   'semanticHighlightingCapabilities': {'semanticHighlighting': None},
                                   'signatureHelp': {'signatureInformation': {'parameterInformation': {'labelOffsetSupport': True}}},
                                   'synchronization': {'didSave': True,
                                                       'willSave': True,
                                                       'willSaveWaitUntil': True},
                                   'typeDefinition': {'linkSupport': True}},
                  'workspace': {'applyEdit': True,
                                'configuration': True,
                                'didChangeWatchedFiles': {'dynamicRegistration': True},
                                'executeCommand': {'dynamicRegistration': False},
                                'symbol': {'symbolKind': {'valueSet': [1,
                                                                       2,
                                                                       3,
                                                                       4,
                                                                       5,
                                                                       6,
                                                                       7,
                                                                       8,
                                                                       9,
                                                                       10,
                                                                       11,
                                                                       12,
                                                                       13,
                                                                       14,
                                                                       15,
                                                                       16,
                                                                       17,
                                                                       18,
                                                                       19,
                                                                       20,
                                                                       21,
                                                                       22,
                                                                       23,
                                                                       24,
                                                                       25,
                                                                       26]}},
                                'workspaceEdit': {'documentChanges': True,
                                                  'resourceOperations': ['create',
                                                                         'rename',
                                                                         'delete']},
                                'workspaceFolders': True}},
 'initializationOptions': None,
 'processId': 17966,
 'rootPath': '/home/cbs/projects/train/train/',
 'rootUri': 'file:///home/cbs/projects/train/train/'}) => {'capabilities': {'definitionProvider': True, 'hoverProvider': True, 'textDocumentSync': 1}}
WARNING | 20:14:35 | hdl_checker.base_server @ _setupIfNeeded():330 MainThread |	Not all directories exist, forcing setup
INFO    | 20:14:35 | hdl_checker.base_server @ setConfig():167 MainThread |	Replacing None with /home/cbs/projects/train/train/.hdl_checker.config
INFO    | 20:14:35 | hdl_checker.utils @ wrapper():362 MainThread |	m_initialized((), {}) => None
INFO    | 20:14:36 | hdl_checker.lsp @ lint():295 Thread-4 |	linting: file:///home/cbs/projects/train/train/src/hdl/common.vhd
INFO    | 20:14:36 | hdl_checker.lsp @ _getDiags():331 Thread-4 |	Linting Path('/home/cbs/projects/train/train/src/hdl/common.vhd') (saved=True)
INFO    | 20:14:36 | hdl_checker.lsp @ lint():295 Thread-5 |	linting: file:///home/cbs/projects/train/train/src/hdl/common_top.vhd
INFO    | 20:14:36 | hdl_checker.lsp @ _getDiags():331 Thread-5 |	Linting Path('/home/cbs/projects/train/train/src/hdl/common_top.vhd') (saved=True)
INFO    | 20:14:36 | hdl_checker.lsp @ lint():295 Thread-7 |	linting: file:///home/cbs/projects/train/train/src/hdl/registers_pkg.vhd
INFO    | 20:14:36 | hdl_checker.lsp @ _getDiags():331 Thread-7 |	Linting Path('/home/cbs/projects/train/train/src/hdl/registers_pkg.vhd') (saved=True)
INFO    | 20:14:36 | hdl_checker.lsp @ lint():295 Thread-8 |	linting: file:///home/cbs/projects/train/train/src/hdl/revision.vhd
INFO    | 20:14:36 | hdl_checker.lsp @ _getDiags():331 Thread-8 |	Linting Path('/home/cbs/projects/train/train/src/hdl/revision.vhd') (saved=True)
INFO    | 20:14:36 | hdl_checker.lsp @ lint():295 Thread-6 |	linting: file:///home/cbs/projects/train/train/src/hdl/fb_capabilities.vhd
INFO    | 20:14:36 | hdl_checker.lsp @ _getDiags():331 Thread-6 |	Linting Path('/home/cbs/projects/train/train/src/hdl/fb_capabilities.vhd') (saved=True)
INFO    | 20:14:36 | hdl_checker.database @ addSource():151 Thread-4 |	Adding /home/cbs/projects/train/train/src/hdl/revision.vhd, library=work, flags=(single=('--std=08',), dependencies=('--std=08',))
INFO    | 20:14:36 | hdl_checker.database @ _updatePathLibrary():324 Thread-4 |	Setting library for '/home/cbs/projects/train/train/src/hdl/common.vhd' to 'not_in_project'
WARNING | 20:14:36 | hdl_checker.database @ getBuildSequence():763 Thread-4 |	1 paths were not built: ['/home/cbs/projects/train/train/src/hdl/revision.vhd']
INFO    | 20:14:36 | hdl_checker.builders.fallback @ build():420 Thread-4 |	Forcing build of /home/cbs/projects/train/train/src/hdl/common.vhd
INFO    | 20:14:37 | hdl_checker.database @ _updatePathLibrary():324 Thread-6 |	Setting library for '/home/cbs/projects/train/train/src/hdl/fb_capabilities.vhd' to 'not_in_project'
WARNING | 20:14:37 | hdl_checker.database @ getBuildSequence():763 Thread-6 |	1 paths were not built: ['/home/cbs/projects/train/train/src/hdl/revision.vhd']
INFO    | 20:14:37 | hdl_checker.builders.fallback @ build():420 Thread-6 |	Forcing build of /home/cbs/projects/train/train/src/hdl/fb_capabilities.vhd
INFO    | 20:14:37 | hdl_checker.database @ _updatePathLibrary():324 Thread-7 |	Setting library for '/home/cbs/projects/train/train/src/hdl/registers_pkg.vhd' to 'not_in_project'
INFO    | 20:14:37 | hdl_checker.database @ getBuildSequence():766 Thread-7 |	Nothing more to do after 0 steps
INFO    | 20:14:37 | hdl_checker.builders.fallback @ build():420 Thread-7 |	Forcing build of /home/cbs/projects/train/train/src/hdl/registers_pkg.vhd
INFO    | 20:14:37 | hdl_checker.database @ _updatePathLibrary():324 Thread-5 |	Setting library for '/home/cbs/projects/train/train/src/hdl/common_top.vhd' to 'not_in_project'
INFO    | 20:14:37 | hdl_checker.database @ getBuildSequence():766 Thread-5 |	Nothing more to do after 0 steps
INFO    | 20:14:37 | hdl_checker.builders.fallback @ build():420 Thread-5 |	Forcing build of /home/cbs/projects/train/train/src/hdl/common_top.vhd
INFO    | 20:14:37 | hdl_checker.database @ getBuildSequence():766 Thread-8 |	Nothing more to do after 0 steps
INFO    | 20:14:37 | hdl_checker.builders.fallback @ build():420 Thread-8 |	Forcing build of /home/cbs/projects/train/train/src/hdl/revision.vhd

Initialization should not suggest a project file when it's already using one

HDL Checker will suggest using a project file when setup is taking more than 30s; this can be confusing when

  • the user is already using one
  • the user was not using a project file but decides to do so but the setup is not significantly faster

Suggest a project file when

  • the user is not already using one
  • file search finds nothing
  • file search yields file(s) whose contents have been seen before (typically generated IP files are repeated throughout the hierarchy)

Incorrect compiler priority when multiple compilers are available on the path

Issue details

When both ModelSim and GHDL are on the path, HDL Checker is choosing GHDL while it should be choosing ModelSim.

  • Output of hdl_checker -V
  • Python version used: Python 3.6
  • OS: Ubuntu 18.04
  • Compiler and version, one of
    • vsim -version: Questa Sim-64 vsim 2019.4_2 Simulator 2019.12 Dec 7 2019
    • ghdl --version: 0.37-dev
    • xvhdl -version: N/A

Language server protocol support

Language server protocol is all the rage these days.
I find hdlcc to be very useful VHDL code checker, but limited only to vim. LSP would allow it to be used also in VS Code, Atom and other editors.
Would such a task be feasible? Do you think it's worth the effort?

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.