-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation #12
Comments
If I might add my cent, it would be nice to mention this file somewhere in a readme and provide a small example such as the one just above. I just looked for mentions of it for around an hour 😅 |
PR for docs are also welcome 😃 |
@tgingold You got me on this one. |
Could you tell me where (probably in some source file ?) can I find if there is more options to use in this json file ?
I think that the example shows all the features, but you can have a look at workspace.py (the project file is read during __init__)
Moreover, as of today, what can this extension provide ? Only syntax checking or some more stuff ?
Slightly more: semantic checks, navigation (go to definition).
|
@suzizecat, let me step in, please.
GHDL is a piece of software that is one of a kind. It is a tool written in Ada by @tgingold during the last 15-20 years. Initially, it was meant to be a simulator/compiler. As such, what it basically does is to analyze VHDL sources, elaborate them and integrate everything along with a runtime library that handles timing during execution/simulation. However, the fact that VHDL as a language is so difficult to parse, makes GHDL unique. Precisely, GHDL has the best open/free source support for VHDL 2008, and it is comparable/better than many closed/commercial tools. As a matter if fact, the VHDL standarization group uses GHDL to discuss new features. As a result, there have been multiple requests during these almost two decades asking @tgingold whether GHDL could provide other VHDL-related features for development, such as syntactic/semantic analysis (linting), synthesis, 'transpilation' (from one version of VHDL to another one, typically for backwards compatibility), generation of C-compatible sources (kind of what Verilator does), etc. Specially during the last six months, @tgingold has been (re)working on some of these so useful/demanded but somehow 'hidden' features of the existing GHDL codebase. The main point is that all of those demanded features are possible and 'almost' available, but there is no public structured API for them. Unfortunately, diving into GHDL's codebase requires a very good knowledge not only about VHDL and hardware design, but also about compilers and relatively deep software architecture. Therefore, Tristan is making a huge effort to provide prototypes using other languages/environments which are more familiar to us (other users of all kinds). This repository is the result of that effort. Another result, is the experimental Recently, we updated the README in https://github.com/ghdl/ghdl#project-structure, to partially explain this context to new users. The path that connects GHDL with your question is as follows:
However, don't panic! This is just so that you understand that all this pieces of software are related to each other, and that they implement basically the same features in different languages/standarized interfaces. Hence, you can look at GHDL's documentation (https://ghdl.readthedocs.io) and try to use whatever you see by kind of ignoring that multiple intermediate 'glue' packages exist between the 'core' of GHDL and whichever 'frontend' you are using.
You can start with options for analysis (
Most, if not all, of those should be accepted in the The source code where the JSON file is loaded is https://github.com/ghdl/ghdl-language-server/blob/master/ghdl-ls/vhdl_langserver/workspace.py As you see, function
Tristan encourages users to use the tools and report whatever error/inconsistency we might find. He is actually quite clever and fast at understanding the underlying issue, so he is usually able to quickly reply explaining whether it will be a quick fix or if that feature will take longer. Most of the times, he will fix the issue on his own before you are able to understand what happened (@pepijndevos dixit). For now, I have tried:
Furthermore, you can find a list of Tristan's ideas in https://github.com/ghdl/ghdl-language-server/blob/master/TODO Nevertheless, I think that both Tristan and me have a blurry view of this VSCode extension, in the sense that we have ideas for it that probably do not belong here but rather in a sibling/child extension. This is because some of the ideas are relative to managing HDL designs/projects as a whole, which would include not only LSP features, but also simulation and/or synthesis. This is where the format of the The main point here is: do we want to design and maintain some new independent JSON schema to manage projects of (V)HDL sources? I think we agree that the format should be generic enough so that multiple tools can use it. Should some other tool already provide a JSON format that suits our needs, we'd probably discuss using or extending that instead. Some possibilities are:
Summarizing, any contribution is welcome. If you want to propose adding a sentence/note and a ref in the README, that's ok. If you want to dive into the code and find out which features/options are supported and which not, that's ok too. None of us are experts in the NodeJS/Electron/JavaScript/TypeScript ecosystem, so any knowledge related to VSCode itself and to the extension is very valuable (see #11 and #5). Should you be using any other editor (say vim), instructions about how you set it up would be great. Just bear the context in mind. If you have any background in (V)HDL design, your thoughts about this comments would be very valuable too. I.e., do you know what you are looking for or are you learning while you explore new tools? Just out of curiosity, how did you install/try this? Did you compile it or did you use the docker image? EDIT Of course, you are free to copy parts of this message to some |
Thanks for this (astonishingly) detailed reply ! I was also wondering if this could also describe "builds" commands, but since this whole language server thingy is, as far as I understand, something to perform code analysis in order to help the code edition, I'm not sure that this is is purpose and within its scope.
I'll have a look, thanks for the details ! For my background, I'm currently working at STMicroelectronics doing what is called Clock and Reset Domain Crossings verification. Those are structural checks which basically allows you to detect issues when an asynchronous signal reach a flop without any proper structure to prevent a metastability generation/propagation. I'll gladly add some more details if you wish to. I have tried this because, while I studied VHDL, I wasn't able to find a decent VHDL editor, let aside an opensource one. Therefore being stuck with Xilinx stuff which is basically a notepad ++/gedit with syntactic issues reported... When I saw a stuff linked with what looked like a nice VHDL elaboration and test tool, I gave it a shot ! So I'm learning while exploring tools (I tried to give a shot to Alliance which use some very outdated technologies by now and is therefore hard to setup, use... ) I compiled the whole GHDL stuff on Ubuntu 19.04 with GCC in order to get the libraries for the ghdl-ls (the hard way, it seems) but the explanations were quite good and it wasn't too much trouble. (One point tho, The current GCC master is in version 10 which kind of break GHDL compilation which doesn't recognize a right GCC version above 9. Might open something about that). It was a little bit painful to make the LS works with VSC due to the latest (10, what a coincidence) version of nodeJS being incompatible with the npm version in repositories (which recognize until 9 too) and some issue with ghdl I tried GHDL for a very little bit of time but I have to say that I'm pretty satisfied which the small bits I have tested so far (a wonky student design and a not less wonky testbench which kind of worked) and the fact that the tool is pretty straightforward with source reading is very nice. Finally, to add some stuff on the probably huge pile of GHDL feature that might be interesting :
And one for the completion stuff :
I will try to have a look at the json reader to get some documentation out when I'll have some time. Thanks again for the detailed reply ! |
You are welcome!
As you might have tried already, this is supported. However, all the files need to be defined in the
With
I'd be glad to know some details about the 'testbench infrastructure' you have. Is everything written in VHDL? How do you feed data in/out of the testbench? Which features do you need which you don't have a free/open source alternative for? Do you make heavy use of assertions? On the one hand, this is pure curiosity. On the other hand, there have been some recent efforts to do formal verification with VHDL, by using GHDL and yosys: http://pepijndevos.nl/2019/08/15/open-source-formal-verification-in-vhdl.html Although it is an extremely experimental feature, I wonder if this can be useful to you.
I believe that many of GHDL users can feel that pain... I was super excited when Tristan created this repo a few months ago. I expected it to be quite buggy, and it is. But it already provides many more features than I have ever had in a VHDL editor. Starting with VHDL 2008 support and 'go to'.
As said, GHDL supports all the versions of VHDL pretty well. So, as long as you can describe the structural checks in VHDL, you should be good. It seems that such checks would rely on GHDL's core, and not on LSP features.
Although GHDL seems an alien to Python/C/C++ people, I believe there is very good reason for that: the VHDL language was originally based on Ada. Hence, there are sintactic and semantic similarities between the language used to write the compiler and the target language to be compiled. Nevertheless, since GCC and LLVM backends are supported, integration of GHDL with C/C++ programs is actually very good. Furthermore, there are multiple mechanisms to co-execute VHDL along with modules/functions/components written in any language than can map to C signatures. The most known is VPI, which allows to access all the internal signals of a design at runtime. However, I find VHPIDIRECT easier to use. You can have a brief idea of how this works in https://ghdl.readthedocs.io/en/latest/using/Foreign.html Precisely, it is possible to co-execute VHDL, C and Python (through ctypes) by using VHPIDIRECT. There are some screencasts in VUnit/vunit#476, where the Python part is a flask server and a JavaScript frontend is used. As you see, it allows to provide an interactive custom GUI for GHDL simulations. If you are interested on this, I can provide you references to github projects of different complexity. Last, a python library exists, which allows to interact with the shared library that provides many of the core features of GHDL. However, this is mostly for developing tools on top of GHDL. I believe you don't want to dive into it yet.
As said, the VSCode part needs some love. If you are a VSCode user, do not hesitate to write down all the UX suggestions you might think of.
It is actually quite fun that you found GHDL because of the LSP features. I think that most of GHDL users might not be aware of it yet :D
That's the hardest way, yes :D. If you only want LSP features, you can use mcode backend, which reduces the build to The main point here is that GHDL with mcode backend is somewhere between 5-10MB, and with GCC backend it is >500MB. So, because of compilation time and disk usage, GCC is not worth, unless you really need coverage.
Yes, it seems that support for GCC 9 or GCC 10 needs to be fixed. You might want to either comment in ghdl/ghdl#883 or open a new issue.
I had to 'fight' with this issue too. In the end, I decided to install the default 'npm' and let it install the default nodejs (which is 8). In case they might be useful for you, these are the dockerfiles we use to test this repo in CI and to generate
BTW, when GitHub Actions are publicly available, it will be possible to download latest
I think we need some more context to understand this. There have been many recent changes to how libraries are found/defined. Therefore, it'd be helful if you could open a specific issue about it.
This is a very very demanded feature, but not easy to implement. GHDL does have all the structural representation, of course:
I think that the main stopper for having an structural representation which is somehow interactive is that a good understanding of GHDL's AST is required. Moreover, this changes quite frequently. This knowledge is significantly different from libraries to design GUI applications. Thinking about a 2D or 3D representation (as 2D layers) of the design, the complexity of routing/layout algorithms is added. Hence, it is difficult that some person has the knowledge, the time and the interest to implement some tool.
I'd say that it requires analysis and elaboration, but not synthesis. However, currently generics are a runtime option. Therefore, it might be difficult to elaborate a structural view without using same values for them. @tgingold has commented that he is going to make it an elaboration option only, in the future.
I think that this kind of task is better handled by some external tool, which can feed not only GHDL but also other vendor tools. For example, olofk/fusesoc, which uses edalize, and which shares features with VUnit. You'll see that 'IP-XACT' is mentioned in the README. Note that you can currently use GHDL with fusesoc/edalize for simulation (not for synthesis yet).
I think this is a specific enhancement request that deserves a new issue. However, note my comments about the scope of this extension. I don't want to prevent you from opening issues. Just be careful to put some indicator, cross-reference, or just mention in the issues that you feel might be partially out of scope. BTW, you might want to have a look at TerosTechnology/terosHDL. It contains many GHDL-based features that I'd like to see in a VSCode extension. However, it is based on Atom. |
The format of
hdl-prj.json
is currently undocumented. This is expected, since it is in a very early development stage and it is subject to change very frequently. However, since it is the only approach to set GHDL options (such as--std
), it might be frustrating for new users to try this tool without any reference. We'll use this issue to collect pieces of information to allow any user to have a hopefully satisfying first experience.Example
hdl-prj.json
file for VUnit's examples/vhdl/array_axis_vcs:At some point it might be useful to provide a json-schema.
A link to a demo in play-with-docker would let users try the VSC extension without a local docker installation.
The text was updated successfully, but these errors were encountered: