1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00

prefer case over casez if possible

This commit is contained in:
Jan Decaluwe 2010-07-21 13:11:28 +02:00
parent b69ace1b99
commit 4e8ccc15a3
2 changed files with 6 additions and 1 deletions

View File

@ -1091,6 +1091,7 @@ class _AnalyzeVisitor(ast.NodeVisitor, _ConversionMixin):
choices.add(item)
node.isCase = True
node.caseVar = var1
node.caseItem = item1
if (len(choices) == len(var1.obj)) or (node.else_ is not None):
node.isFullCase = True

View File

@ -1258,7 +1258,11 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin):
# if node.isFullCase:
# self.write(" full_case")
# self.writeline()
self.write("casez (")
caseType = "case"
if isinstance(node.caseItem, EnumItemType):
if node.caseItem._type._encoding in ('one_hot', 'one_cold'):
caseType = "casez"
self.write("%s (" % caseType)
self.visit(var)
self.write(")")
self.indent()