use getifacetype to identify generation of xxxx_io objects
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 13 Jun 2018 13:03:12 +0000 (14:03 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 13 Jun 2018 13:03:12 +0000 (14:03 +0100)
src/bsv/interface_decl.py

index b24e13de7b9b17a3da0e663271c3c7c047beaf8c..46b5bb74d56ca302f7aa8172849bd91c1bde15d7 100644 (file)
@@ -160,20 +160,23 @@ class Interface(object):
         res = '\n'.join(map(self.wirefmtpin, self.pins)).format(*args)
         res += '\n'
         for p in self.pinspecs:
-            name = self.pname(p['name']).format(*args)
+            name = self.pname(p['name'])
+            typ = self.getifacetype(name.format(""))
+            name = name.format(*args)
+            res += "      # declare %s_io, set up as type '%s'\n" % (name, typ)
             res += "      GenericIOType %s_io = GenericIOType{\n" % name
             params = []
-            if p.get('outen') is True:
+            if typ == 'inout':
                 outname = self.ifacefmtoutfn(name)
                 params.append('outputval:%s_out,' % outname)
                 params.append('output_en:%s_outen,' % outname)  # match busfmt
                 params.append('input_en:~%s_outen,' % outname)
-            elif p.get('action'):
+            elif typ == 'out':
                 outname = self.ifacefmtoutfn(name)
                 params.append('outputval:%s,' % outname)
                 params.append('output_en:1,')
                 params.append('input_en:0,')
-            else:
+            else: # input
                 params.append('outputval:0,')
                 params.append('output_en:0,')
                 params.append('input_en:1,')