From 9fd45e74dd66dcc174a4bf31a91546f900fc9b1f Mon Sep 17 00:00:00 2001 From: Henry Gomersall Date: Thu, 14 Apr 2016 11:57:27 +0100 Subject: [PATCH 1/2] Moved assignment of name attribute in _Block to before where it might be needed by an error message. --- myhdl/_block.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/myhdl/_block.py b/myhdl/_block.py index 04644c3c..6e0378be 100644 --- a/myhdl/_block.py +++ b/myhdl/_block.py @@ -107,11 +107,12 @@ class _Block(object): self.symdict = None self.sigdict = {} self.memdict = {} + self.name = self.__name__ = func.__name__ + '_' + str(calls - 1) + # flatten, but keep BlockInstance objects self.subs = _flatten(func(*args, **kwargs)) self._verifySubs() self._updateNamespaces() - self.name = self.__name__ = func.__name__ + '_' + str(calls - 1) self.verilog_code = self.vhdl_code = None self.sim = None if hasattr(deco, 'verilog_code'): From c66482e966318938651ae121e9747aef92859450 Mon Sep 17 00:00:00 2001 From: Henry Gomersall Date: Thu, 14 Apr 2016 12:28:23 +0100 Subject: [PATCH 2/2] Added additional helpful info from the .name attribute about which block is failing to return a valid block. --- myhdl/_block.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myhdl/_block.py b/myhdl/_block.py index 6e0378be..445ffca5 100644 --- a/myhdl/_block.py +++ b/myhdl/_block.py @@ -35,7 +35,7 @@ from myhdl._Signal import _Signal, _isListOfSigs class _error: pass -_error.ArgType = "A block should return block or instantiator objects" +_error.ArgType = "%s: A block should return block or instantiator objects" _error.InstanceError = "%s: subblock %s should be encapsulated in a block decorator" @@ -126,7 +126,7 @@ class _Block(object): def _verifySubs(self): for inst in self.subs: if not isinstance(inst, (_Block, _Instantiator, Cosimulation)): - raise BlockError(_error.ArgType) + raise BlockError(_error.ArgType % (self.name,)) if isinstance(inst, (_Block, _Instantiator)): if not inst.modctxt: raise BlockError(_error.InstanceError % (self.name, inst.callername))