From f4ee428c35a82a5e2fb19d541ecee9e1792c686b Mon Sep 17 00:00:00 2001 From: Kevin Kiningham Date: Sat, 25 Feb 2017 02:44:32 -0800 Subject: [PATCH 1/2] [pymtl/tools] Fix error with empty combinational block --- pymtl/tools/ast_helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pymtl/tools/ast_helpers.py b/pymtl/tools/ast_helpers.py index 65ca070a..8df3c3f6 100644 --- a/pymtl/tools/ast_helpers.py +++ b/pymtl/tools/ast_helpers.py @@ -110,5 +110,9 @@ def get_method_ast( func ): #----------------------------------------------------------------------- # http://stackoverflow.com/a/19416942 def get_closure_dict( fn ): - closure_objects = [c.cell_contents for c in fn.func_closure] + # If fn does not close over anything, fn.func_closure will be None + # instead of the more sensible [], so we need to check here + func_closure = fn.func_closure if fn.func_closure is not None else [] + + closure_objects = [c.cell_contents for c in func_closure] return dict( zip( fn.func_code.co_freevars, closure_objects )) From 313a98a1eaa3819e4aa6a965679c3d976c35ee56 Mon Sep 17 00:00:00 2001 From: Kevin Kiningham Date: Sat, 25 Feb 2017 02:47:24 -0800 Subject: [PATCH 2/2] [pymtl/tools/translation] Add visitor for pass statement --- pymtl/tools/translation/verilog_behavioral.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pymtl/tools/translation/verilog_behavioral.py b/pymtl/tools/translation/verilog_behavioral.py index b9d5c3f4..fcf59de5 100644 --- a/pymtl/tools/translation/verilog_behavioral.py +++ b/pymtl/tools/translation/verilog_behavioral.py @@ -642,6 +642,12 @@ def visit_Print(self, node): msg = '$display( "{}", {} );'.format( fmt_str, sig_lst ) return fmt( msg, self.indent ) + #----------------------------------------------------------------------- + # visit_Pass + #----------------------------------------------------------------------- + def visit_Pass(self, node): + return '' + #----------------------------------------------------------------------- # opmap #-----------------------------------------------------------------------