Skip to content

Commit f0dd01e

Browse files
committed
vendor._lattice: reflow to 100 columns. NFC
1 parent 855545b commit f0dd01e

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

amaranth/vendor/_lattice.py

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ class LatticePlatform(TemplatedPlatform):
543543

544544
# Oxide templates
545545

546-
_oxide_required_tools = [
546+
_oxide_required_tools = [
547547
"yosys",
548548
"nextpnr-nexus",
549549
"prjoxide"
@@ -579,7 +579,7 @@ class LatticePlatform(TemplatedPlatform):
579579
"{{name}}.pdc": r"""
580580
# {{autogenerated}}
581581
{% for port_name, pin_name, attrs in platform.iter_port_constraints_bits() -%}
582-
ldc_set_location -site {{ '{' }}{{pin_name}}{{ '}' }} {{'['}}get_ports {{port_name}}{{']'}}
582+
ldc_set_location -site {{ '{' }}{{pin_name}}{{ '}' }} {{'['}}get_ports {{port_name}}{{']'}}
583583
{% if attrs -%}
584584
ldc_set_port -iobuf {{ '{' }}{%- for key, value in attrs.items() %}{{key}}={{value}} {% endfor %}{{ '}' }} {{'['}}get_ports {{port_name}}{{']'}}
585585
{% endif %}
@@ -605,7 +605,7 @@ class LatticePlatform(TemplatedPlatform):
605605
{{invoke_tool("nextpnr-nexus")}}
606606
{{get_override("nextpnr_opts")|options}}
607607
--log {{name}}.tim
608-
--device {{platform.device}}-{{platform.speed}}{{platform.package}}{{platform.grade}}
608+
--device {{platform.device}}-{{platform.speed}}{{platform.package}}{{platform.grade}}
609609
--pdc {{name}}.pdc
610610
--json {{name}}.json
611611
--fasm {{name}}.fasm
@@ -818,7 +818,8 @@ def __init__(self, *, toolchain=None):
818818
device = self.device.lower()
819819
if device.startswith(("lfe5", "lae5")):
820820
self.family = "ecp5"
821-
elif device.startswith(("lcmxo2-", "lcmxo3l", "lcmxo3d", "lamxo2-", "lamxo3l", "lamxo3d", "lfmnx-")):
821+
elif device.startswith(("lcmxo2-", "lcmxo3l", "lcmxo3d", "lamxo2-", "lamxo3l", "lamxo3d",
822+
"lfmnx-")):
822823
self.family = "machxo2"
823824
elif device.startswith(("lifcl-", "lfcpnx-", "lfd2nx-", "lfmxo5-", "ut24c")):
824825
self.family = "nexus"
@@ -921,30 +922,36 @@ def create_missing_domain(self, name):
921922
m = Module()
922923
if self.default_clk == "OSCG":
923924
if not hasattr(self, "oscg_div"):
924-
raise ValueError("OSCG divider (oscg_div) must be an integer between 2 "
925-
"and 128")
925+
raise ValueError(
926+
"OSCG divider (oscg_div) must be an integer between 2 and 128")
926927
if not isinstance(self.oscg_div, int) or self.oscg_div < 2 or self.oscg_div > 128:
927-
raise ValueError("OSCG divider (oscg_div) must be an integer between 2 "
928-
"and 128, not {!r}"
929-
.format(self.oscg_div))
928+
raise ValueError(
929+
f"OSCG divider (oscg_div) must be an integer between 2 and 128, "
930+
f"not {self.oscg_div!r}")
930931
clk_i = Signal()
931932
m.submodules += Instance("OSCG", p_DIV=self.oscg_div, o_OSC=clk_i)
932933
elif self.default_clk == "OSCH":
933934
osch_freq = self.osch_frequency
934935
if osch_freq not in self._supported_osch_freqs:
935-
raise ValueError("Frequency {!r} is not valid for OSCH clock. Valid frequencies are {!r}"
936-
.format(osch_freq, self._supported_osch_freqs))
936+
raise ValueError(
937+
f"Frequency {osch_freq!r} is not valid for OSCH clock. "
938+
f"Valid frequencies are {self._supported_osch_freqs!r}")
937939
osch_freq_param = f"{float(osch_freq):.2f}"
938940
clk_i = Signal()
939-
m.submodules += Instance("OSCH", p_NOM_FREQ=osch_freq_param, i_STDBY=Const(0), o_OSC=clk_i, o_SEDSTDBY=Signal())
941+
m.submodules += Instance("OSCH",
942+
p_NOM_FREQ=osch_freq_param,
943+
i_STDBY=Const(0),
944+
o_OSC=clk_i,
945+
o_SEDSTDBY=Signal()
946+
)
940947
elif self.default_clk == "OSCA":
941948
if not hasattr(self, "osca_div"):
942-
raise ValueError("OSCA divider (osca_div) must be an integer between 2 "
943-
"and 256")
949+
raise ValueError(
950+
f"OSCA divider (osca_div) must be an integer between 2 and 256")
944951
if not isinstance(self.osca_div, int) or self.osca_div < 2 or self.osca_div > 256:
945-
raise ValueError("OSCA divider (osca_div) must be an integer between 2 "
946-
"and 256, not {!r}"
947-
.format(self.osca_div))
952+
raise ValueError(
953+
f"OSCA divider (osca_div) must be an integer between 2 and 256, "
954+
f"not {self.osca_div!r}")
948955
clk_i = Signal()
949956
m.submodules += Instance("OSCA",
950957
p_HF_CLK_DIV=str(self.osca_div - 1),
@@ -968,17 +975,15 @@ def create_missing_domain(self, name):
968975
# Here we build a simple reset synchronizer from D-type FFs with a positive-level
969976
# asynchronous preset which we tie low
970977
m.submodules += [
971-
Instance(
972-
"FD1P3BX",
978+
Instance("FD1P3BX",
973979
p_GSR="DISABLED",
974980
i_CK=clk_i,
975981
i_D=~rst_i,
976982
i_SP=Const(1),
977983
i_PD=Const(0),
978984
o_Q=gsr0,
979985
),
980-
Instance(
981-
"FD1P3BX",
986+
Instance("FD1P3BX",
982987
p_GSR="DISABLED",
983988
i_CK=clk_i,
984989
i_D=gsr0,
@@ -992,9 +997,9 @@ def create_missing_domain(self, name):
992997
m.submodules += [
993998
Instance("FD1S3AX", p_GSR="DISABLED", i_CK=clk_i, i_D=~rst_i, o_Q=gsr0),
994999
Instance("FD1S3AX", p_GSR="DISABLED", i_CK=clk_i, i_D=gsr0, o_Q=gsr1),
995-
# Although we already synchronize the reset input to user clock, SGSR has dedicated
996-
# clock routing to the center of the FPGA; use that just in case it turns out to be
997-
# more reliable. (None of this is documented.)
1000+
# Although we already synchronize the reset input to user clock, SGSR has
1001+
# dedicated clock routing to the center of the FPGA; use that just in case it
1002+
# turns out to be more reliable. (None of this is documented.)
9981003
Instance("SGSR", i_CLK=clk_i, i_GSR=gsr1),
9991004
]
10001005
# GSR implicitly connects to every appropriate storage element. As such, the sync

0 commit comments

Comments
 (0)