diff options
author | Kammie <kammoh@gmail.com> | 2019-02-14 00:07:06 -0500 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2019-02-14 06:07:06 +0100 |
commit | 4b9a513b53b5a121a1abe5fd93abc8d14e6b7750 (patch) | |
tree | d39b21acb861fa1dacf99b2d995daf350f9658d3 | |
parent | 50da90f509aa6de2961f1795af0be2452bc2c6d9 (diff) | |
download | ghdl-4b9a513b53b5a121a1abe5fd93abc8d14e6b7750.tar.gz ghdl-4b9a513b53b5a121a1abe5fd93abc8d14e6b7750.tar.bz2 ghdl-4b9a513b53b5a121a1abe5fd93abc8d14e6b7750.zip |
VPI: add support for detecting ports and their directions (#753)
* VPI: add support for detecting ports and their directions
* fix indentation
* address gna/issue450: hack to include "ports" in "net" iteration
-rw-r--r-- | src/grt/grt-vpi.adb | 35 | ||||
-rw-r--r-- | src/grt/grt-vpi.ads | 9 |
2 files changed, 39 insertions, 5 deletions
diff --git a/src/grt/grt-vpi.adb b/src/grt/grt-vpi.adb index 644b155ee..5337f7abb 100644 --- a/src/grt/grt-vpi.adb +++ b/src/grt/grt-vpi.adb @@ -345,7 +345,7 @@ package body Grt.Vpi is Error : AvhpiErrorT; begin case aType is - when vpiNet => + when vpiPort | vpiNet => Rel := VhpiDecls; when vpiModule => if Ref = null then @@ -485,6 +485,17 @@ package body Grt.Vpi is Res := Vpi_Get_Size (Ref); when vpiVector => Res := Boolean'Pos (Vpi_Get_Vector (Ref)); + when vpiDirection => + case Vhpi_Get_Mode (Ref.Ref) is + when VhpiInMode => + Res := vpiInput; + when VhpiOutMode => + Res := vpiOutput; + when VhpiInoutMode => + Res := vpiInout; + when others => + Res := vpiNoDirection; + end case; when others => dbgPut_Line ("vpi_get: unknown property"); Res := 0; @@ -513,8 +524,16 @@ package body Grt.Vpi is | VhpiForGenerateK | VhpiCompInstStmtK => return vpiModule; - when VhpiPortDeclK - | VhpiSigDeclK => + when VhpiPortDeclK => + declare + Info : Verilog_Wire_Info; + begin + Get_Verilog_Wire (Res, Info); + if Info.Vtype /= Vcd_Bad then + return vpiPort; + end if; + end; + when VhpiSigDeclK => declare Info : Verilog_Wire_Info; begin @@ -548,6 +567,9 @@ package body Grt.Vpi is when vpiNet => return new struct_vpiHandle'(mType => vpiNet, Ref => Res); + when vpiPort => + return new struct_vpiHandle'(mType => vpiPort, + Ref => Res); when vpiParameter => return new struct_vpiHandle'(mType => vpiParameter, Ref => Res); @@ -592,6 +614,8 @@ package body Grt.Vpi is when vpiInternalScope | vpiModule => Expected_Kind := vpiModule; + when vpiPort => + Expected_Kind := vpiPort; when vpiNet => Expected_Kind := vpiNet; when others => @@ -603,7 +627,8 @@ package body Grt.Vpi is exit when Error /= AvhpiErrorOk; Kind := Vhpi_Handle_To_Vpi_Prop (Res); - if Kind /= vpiUndefined and then Kind = Expected_Kind then + if Kind /= vpiUndefined and then (Kind = Expected_Kind or + (Kind = vpiPort and Expected_Kind = vpiNet)) then return Build_vpiHandle (Res, Kind); end if; end loop; @@ -722,7 +747,7 @@ package body Grt.Vpi is when vpiRightRange | vpiLeftRange => case Ref.mType is - when vpiNet => + when vpiPort| vpiNet => Res := new struct_vpiHandle (aType); Res.Ref := Ref.Ref; return Res; diff --git a/src/grt/grt-vpi.ads b/src/grt/grt-vpi.ads index 68635c876..0ee7cc5e9 100644 --- a/src/grt/grt-vpi.ads +++ b/src/grt/grt-vpi.ads @@ -44,6 +44,15 @@ package Grt.Vpi is -- object codes, see vpi_user.h vpiModule: constant integer := 32; vpiNet: constant integer := 36; + vpiPort: constant integer := 44; + -- + vpiDirection: constant integer := 20; + vpiInput: constant integer := 1; + vpiOutput: constant integer := 2; + vpiInout: constant integer := 3; + vpiMixedIO: constant integer := 4; + vpiNoDirection: constant integer := 5; + vpiParameter: constant integer := 41; vpiLeftRange: constant integer := 79; vpiRightRange: constant integer := 83; |