Skip to content

Commit

Permalink
Merge pull request #319 from DurandA/feature-integer-attributes
Browse files Browse the repository at this point in the history
Add integer attributes
  • Loading branch information
enjoy-digital authored Dec 21, 2019
2 parents 40c3555 + 94e239f commit e754c05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions litex/build/lattice/diamond.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from migen.fhdl.structure import _Fragment

from litex.gen.fhdl.verilog import DummyAttrTranslate

from litex.build.generic_platform import *
from litex.build import tools
from litex.build.lattice import common
Expand Down
18 changes: 10 additions & 8 deletions litex/gen/fhdl/verilog.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,23 +198,20 @@ def _printattr(attr, attr_translate):
firsta = True
for attr in sorted(attr,
key=lambda x: ("", x) if isinstance(x, str) else x):
# platform-dependent attribute
if isinstance(attr, tuple):
# platform-dependent attribute
attr_name, attr_value = attr
elif attr not in attr_translate.keys():
attr_name, attr_value = attr, None
# translated attribute
else:
# translated attribute
at = attr_translate[attr]
if at is None:
continue
attr_name, attr_value = at
if not firsta:
r += ", "
firsta = False
r += attr_name
if attr_value is not None:
r += " = \"" + attr_value + "\""
const_expr = "\"" + attr_value + "\"" if not isinstance(attr_value, int) else str(attr_value)
r += attr_name + " = " + const_expr
if r:
r = "(* " + r + " *)"
return r
Expand Down Expand Up @@ -370,9 +367,14 @@ def _printspecials(overrides, specials, ns, add_data_file, attr_translate):
return r


class DummyAttrTranslate:
def __getitem__(self, k):
return (k, "true")


def convert(f, ios=None, name="top",
special_overrides=dict(),
attr_translate={},
attr_translate=DummyAttrTranslate(),
create_clock_domains=True,
display_run=False,
reg_initialization=True,
Expand Down

0 comments on commit e754c05

Please sign in to comment.