richjyoung / vscode-modern-vhdl

Modern VSCode VHDL Support
MIT License
30 stars 12 forks source link

Folder indexing and entity identification #4

Open jacopoabramo opened 5 years ago

jacopoabramo commented 5 years ago

I usually use VS Code mostly in terms of file editing; normally I work in parallel with Vivado (a Xilinx tool used to synthesize VHDL code for their products) because currently there is no way for VS Code to identify whether an entity has been included correctly within the project, or even within a specific folder.

That being said, my idea was having a folder indexing which would be capable of reading the code and being able to identify if the component I'm trying to instantiating somewhere is either present within my path, and if it is coherent with the entity definition itself.

For example:

...
architecture rtl of myTop is

component myComponent
port (
port1: in std_logic;
port2: in std_logic;
port3: in std_logic;
port4: out std_logic
);
end component;

signal port1, port2, port3, port4: std_logic;
...

begin

i_myComp: myComponent
port map (
port1 => port1,
port2 => port2,
--port3 => port3, (this is commented out so it's not declared)
port4 => port4
);

It would be nice to identify the fact that there is no port3 associated to i_myComp. It would be probably a bit more complicated when considering the possibility that port3 or any other port may also have a default value associated, but I guess it would be a start anyway.

Would this make sense to you @richjyoung ?

richjyoung commented 5 years ago

It makes sense and I'm working on functionality to enable this kind of behaviour in the future. The fundamental difference here is processing a file in the context of a wider workspace, rather than just itself.

I take your point about defaults, that is harder to detect, but at a minimum it would be nice to offer autocomplete or highlight invalid ports.

Including a component declaration inside an architecture is one of the harder problems to solve, as the component only specifies what an instantiated entity should look like, not where it is. Also, resolving components or entities within libraries is similarly difficult because libraries are managed outside of the VHDL in a tool-specific manner. I would like to support libraries in the future, but my focus for this extension is on providing as much functionality with zero-configuration as possible. I.e. I do not want a user to have to specify library to folder mappings within the VSCode settings.