Commit 6f28ae76 authored by Raptor Engineering Development Team's avatar Raptor Engineering Development Team
Browse files

Add optional ability to specify different IO standards on a single bank

This functionality is only enabled on the Lattice+Trellis flow
for now.
parent faca6d99
......@@ -4,6 +4,7 @@
# Copyright (c) 2013-2014 Sebastien Bourdeauducq <sb@m-labs.hk>
# Copyright (c) 2014-2019 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2015 Yann Sionneau <ys@m-labs.hk>
# Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
# SPDX-License-Identifier: BSD-2-Clause
import sys
......@@ -40,12 +41,16 @@ class Pins:
class IOStandard:
def __init__(self, name):
self.name = name
def __init__(self, *identifiers):
self.identifiers = []
for i in identifiers:
if isinstance(i, int):
self.identifiers += ["X"]*i
else:
self.identifiers += i.split()
def __repr__(self):
return "{}('{}')".format(self.__class__.__name__, self.name)
return "{}('{}')".format(self.__class__.__name__, " ".join(self.identifiers))
class Drive:
def __init__(self, strength):
......
......@@ -3,6 +3,7 @@
#
# Copyright (c) 2020 Pepijn de Vos <pepijndevos@gmail.com>
# Copyright (c) 2015-2018 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
# SPDX-License-Identifier: BSD-2-Clause
import os
......@@ -31,7 +32,7 @@ def _build_cst(named_sc, named_pc):
for c in other:
if isinstance(c, IOStandard):
lines.append(f"IO_PORT \"{name}\" IO_TYPE={c.name};")
lines.append(f"IO_PORT \"{name}\" IO_TYPE={c.identifiers[0]};")
elif isinstance(c, Misc):
lines.append(f"IO_PORT \"{name}\" {c.misc};")
......
......@@ -4,6 +4,7 @@
# Copyright (c) 2015-2019 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2017-2018 Sergiusz Bazanski <q3k@q3k.org>
# Copyright (c) 2017 William D. Jones <thor0505@comcast.net>
# Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
# SPDX-License-Identifier: BSD-2-Clause
import os
......@@ -33,7 +34,7 @@ def _format_constraint(c):
if isinstance(c, Pins):
return ("LOCATE COMP ", " SITE " + "\"" + c.identifiers[0] + "\"")
elif isinstance(c, IOStandard):
return ("IOBUF PORT ", " IO_TYPE=" + c.name)
return ("IOBUF PORT ", " IO_TYPE=" + c.identifiers[0])
elif isinstance(c, Misc):
return ("IOBUF PORT ", " " + c.misc)
......
......@@ -5,6 +5,7 @@
# Copyright (c) 2015-2019 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2017-2018 Sergiusz Bazanski <q3k@q3k.org>
# Copyright (c) 2017 William D. Jones <thor0505@comcast.net>
# Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
# SPDX-License-Identifier: BSD-2-Clause
import os
......@@ -79,7 +80,7 @@ def _format_constraint(c):
if isinstance(c, Pins):
return ("ldc_set_location -site {" + c.identifiers[0] + "} [get_ports ","]")
elif isinstance(c, IOStandard):
return ("ldc_set_port -iobuf {IO_TYPE="+c.name+"} [get_ports ", "]")
return ("ldc_set_port -iobuf {IO_TYPE="+c.identifiers[0]+"} [get_ports ", "]")
elif isinstance(c, Misc):
return ("ldc_set_port -iobuf {"+c.misc+"} [get_ports ", "]" )
......
......@@ -4,6 +4,7 @@
# Copyright (c) 2018-2019 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2018-2019 David Shah <dave@ds0.me>
# Copyright (c) 2018 William D. Jones <thor0505@comcast.net>
# Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
# SPDX-License-Identifier: BSD-2-Clause
import os
......@@ -19,17 +20,20 @@ from litex.build.lattice import common
# IO Constraints (.lpf) ----------------------------------------------------------------------------
def _format_constraint(c):
def _format_constraint(c, index):
if isinstance(c, Pins):
return ("LOCATE COMP ", " SITE " + "\"" + c.identifiers[0] + "\"")
elif isinstance(c, IOStandard):
return ("IOBUF PORT ", " IO_TYPE=" + c.name)
if index < len(c.identifiers):
return ("IOBUF PORT ", " IO_TYPE=" + c.identifiers[index])
else:
return ("IOBUF PORT ", " IO_TYPE=" + c.identifiers[len(c.identifiers)-1])
elif isinstance(c, Misc):
return ("IOBUF PORT ", " " + c.misc)
def _format_lpf(signame, pin, others, resname):
fmt_c = [_format_constraint(c) for c in ([Pins(pin)] + others)]
def _format_lpf(signame, index, pin, others, resname):
fmt_c = [_format_constraint(c, index) for c in ([Pins(pin)] + others)]
lpf = []
for pre, suf in fmt_c:
lpf.append(pre + "\"" + signame + "\"" + suf + ";")
......@@ -43,9 +47,9 @@ def _build_lpf(named_sc, named_pc, build_name):
for sig, pins, others, resname in named_sc:
if len(pins) > 1:
for i, p in enumerate(pins):
lpf.append(_format_lpf(sig + "[" + str(i) + "]", p, others, resname))
lpf.append(_format_lpf(sig + "[" + str(i) + "]", i, p, others, resname))
else:
lpf.append(_format_lpf(sig, pins[0], others, resname))
lpf.append(_format_lpf(sig, 0, pins[0], others, resname))
if named_pc:
lpf.append("\n\n".join(named_pc))
tools.write_to_file(build_name + ".lpf", "\n".join(lpf))
......
......@@ -2,6 +2,7 @@
# This file is part of LiteX.
#
# Copyright (c) 2018-2019 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
# SPDX-License-Identifier: BSD-2-Clause
import os
......@@ -27,7 +28,7 @@ def _format_io_constraint(c):
if isinstance(c, Pins):
return "-pin_name {} ".format(c.identifiers[0])
elif isinstance(c, IOStandard):
return "-io_std {} ".format(c.name)
return "-io_std {} ".format(c.identifiers[0])
elif isinstance(c, Misc):
return "-RES_PULL {} ".format(c.misc)
else:
......
......@@ -8,6 +8,7 @@
# Copyright (c) 2018-2017 Tim 'mithro' Ansell <me@mith.ro>
# Copyright (c) 2018 William D. Jones <thor0505@comcast.net>
# Copyright (c) 2019 Larry Doolittle <ldoolitt@recycle.lbl.gov>
# Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
# SPDX-License-Identifier: BSD-2-Clause
import os
......@@ -27,7 +28,7 @@ def _format_constraint(c):
if isinstance(c, Pins):
return "LOC=" + c.identifiers[0]
elif isinstance(c, IOStandard):
return "IOSTANDARD=" + c.name
return "IOSTANDARD=" + c.identifiers[0]
elif isinstance(c, Drive):
return "DRIVE=" + str(c.strength)
elif isinstance(c, Misc):
......
......@@ -28,7 +28,7 @@ def _format_xdc_constraint(c):
if isinstance(c, Pins):
return "set_property LOC " + c.identifiers[0]
elif isinstance(c, IOStandard):
return "set_property IOSTANDARD " + c.name
return "set_property IOSTANDARD " + c.identifiers[0]
elif isinstance(c, Drive):
return "set_property DRIVE " + str(c.strength)
elif isinstance(c, Misc):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment