@@ -32,7 +32,8 @@ def add(name, deps=tuple()):
3232
3333 add ("array_util" )
3434 add ("com" )
35- add ("verification_components" , ["com" , "osvvm" ])
35+ add ("external_arrays" )
36+ add ("verification_components" , ["com" , "osvvm" , "external_arrays" ])
3637 add ("osvvm" )
3738 add ("random" , ["osvvm" ])
3839 add ("json4vhdl" )
@@ -74,6 +75,42 @@ def _add_data_types(self):
7475 """
7576 self ._add_files (join (VHDL_PATH , "data_types" , "src" , "*.vhd" ))
7677
78+ def _add_external_arrays (self , ** args ):
79+ """
80+ Add sources corresponding to VHPIDIRECT arrays (or their placeholders)
81+ """
82+ from vunit .test .common import simulator_check
83+
84+ packages = [False , False , False ]
85+ implementations = [None , None , None ]
86+ if args is not None :
87+ if 'packages' in args and args ['packages' ] is not None :
88+ packages = args ["packages" ]
89+ if 'implementations' in args and args ["implementations" ] is not None :
90+ implementations = args ["implementations" ]
91+
92+ files = [["external_byte_array-novhpi.vhd" , "external_byte_array-body.vhd" ]]
93+
94+ # files = [
95+ # ["external_byte_array-novhpi.vhd", "external_byte_array-body.vhd"],
96+ # ["external_integer_array-novhpi.vhd", "external_integer_array-body.vhd"],
97+ # ["external_memory-novhpi.vhd", "external_memory-body.vhd"]
98+ # ]
99+
100+ if not simulator_check (lambda simclass : simclass .supports_vhpi ()):
101+ print ("the selected simulator does not support VHPI; using non-VHPI packages..." )
102+ else :
103+ for pkg in range (0 , 1 ): # len(files)
104+ if packages [pkg ]:
105+ if implementations [pkg ] is not None :
106+ files [pkg ] = implementations [pkg ]
107+ else :
108+ files [pkg ][0 ] = "external_byte_array-vhpi.vhd"
109+
110+ for pkg in range (0 , 1 ): # len(files)
111+ for name in files [pkg ]:
112+ self ._add_files (join (VHDL_PATH , "data_types" , "src" , "external" , name ))
113+
77114 def _add_array_util (self ):
78115 """
79116 Add array utility
@@ -227,7 +264,7 @@ def _add_check(self, name, args=None):
227264 return False
228265
229266 old_args = self ._already_added [name ]
230- if args != old_args :
267+ if args != old_args and name != "external_arrays" :
231268 raise RuntimeError (
232269 "Optional builtin %r added with arguments %r has already been added with arguments %r"
233270 % (name , args , old_args ))
0 commit comments