sneakypete81 / atom-vhdl-entity-converter

Convert a VHDL entity into a component, instance or signal definitions, using the clipboard.
https://atom.io/packages/vhdl-entity-converter
GNU General Public License v3.0
8 stars 7 forks source link

If an entity does not have generics no ports are detected #4

Closed svenn71 closed 8 years ago

svenn71 commented 8 years ago

remove the generic part of an entity and there will be no port map generated

sneakypete81 commented 8 years ago

What we really need is a little unit testing! Thanks for reporting these issues.

svenn71 commented 8 years ago

I have cloned your repository and started hacking a bit on my own. Found that testing for generic array length > 0 would skip creation of generics if they do not exist in the entity

diff --git a/lib/templates.js b/lib/templates.js
index ad9c748..d146854 100644
--- a/lib/templates.js
+++ b/lib/templates.js
@@ -51,7 +51,7 @@ function componentTemplate(entity) {

 function instanceTemplate(entity) {
   text = `${entity.name}_i : ${entity.name}\n`
-  if (entity.generics) {
+  if (entity.generics > 0) {
     text += `generic map (\n`
     longest = longestinArray(entity.generics, "name")
     for (generic of entity.generics) {