aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom/formatting/prettyprint.py
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-18 10:19:59 +0200
committerTristan Gingold <tgingold@free.fr>2021-06-18 19:19:27 +0200
commit823ee7dd560da1e8f08a34685c03f98ccc89b390 (patch)
tree9b628795399605aa478ab2e95feec7004ca43575 /pyGHDL/dom/formatting/prettyprint.py
parent05755b53e1d723ff4d2c9de79c61badd42491b13 (diff)
downloadghdl-823ee7dd560da1e8f08a34685c03f98ccc89b390.tar.gz
ghdl-823ee7dd560da1e8f08a34685c03f98ccc89b390.tar.bz2
ghdl-823ee7dd560da1e8f08a34685c03f98ccc89b390.zip
Added handling of Floating Point.
Diffstat (limited to 'pyGHDL/dom/formatting/prettyprint.py')
-rw-r--r--pyGHDL/dom/formatting/prettyprint.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/pyGHDL/dom/formatting/prettyprint.py b/pyGHDL/dom/formatting/prettyprint.py
index 387706cac..7129a30c4 100644
--- a/pyGHDL/dom/formatting/prettyprint.py
+++ b/pyGHDL/dom/formatting/prettyprint.py
@@ -12,7 +12,7 @@ from pyVHDLModel.VHDLModel import (
PortInterfaceItem,
BinaryExpression,
IdentityExpression,
- UnaryExpression,
+ UnaryExpression, WithDefaultExpression,
)
from pyGHDL import GHDLBaseException
@@ -220,16 +220,17 @@ class PrettyPrint:
subType = generic.SubType
if isinstance(subType, SimpleSubTypeSymbol):
buffer.append(
- "{prefix} - {name} : {mode} {type}".format(
+ "{prefix} - {name} : {mode} {type}{initialValue}".format(
prefix=prefix,
name=generic.Name,
mode=ModeTranslation[generic.Mode],
type=subType.SymbolName,
+ initialValue=self.formatInitialValue(generic),
)
)
elif isinstance(subType, ConstrainedSubTypeSymbol):
buffer.append(
- "{prefix} - {name} : {mode} {type}({constraints})".format(
+ "{prefix} - {name} : {mode} {type}({constraints}){initialValue}".format(
prefix=prefix,
name=generic.Name,
mode=ModeTranslation[generic.Mode],
@@ -246,6 +247,7 @@ class PrettyPrint:
for constraint in subType.Constraints
]
),
+ initialValue=self.formatInitialValue(generic),
)
)
else:
@@ -264,13 +266,14 @@ class PrettyPrint:
prefix = " " * level
buffer.append(
- "{prefix} - {name} : {mode} {subtypeindication}".format(
+ "{prefix} - {name} : {mode} {subtypeindication}{initialValue}".format(
prefix=prefix,
name=port.Name,
mode=ModeTranslation[port.Mode],
subtypeindication=self.formatSubtypeIndication(
port.SubType, "port", port.Name
),
+ initialValue=self.formatInitialValue(port),
)
)
@@ -336,6 +339,12 @@ class PrettyPrint:
)
)
+ def formatInitialValue(self, item: WithDefaultExpression) -> str:
+ if item.DefaultExpression is None:
+ return ""
+
+ return " := {expr}".format(expr=self.formatExpression(item.DefaultExpression))
+
def formatExpression(self, expression: Expression) -> str:
if isinstance(expression, SimpleObjectSymbol):
return "{name}".format(name=expression.SymbolName)