@@ -543,7 +543,7 @@ class LatticePlatform(TemplatedPlatform):
543
543
544
544
# Oxide templates
545
545
546
- _oxide_required_tools = [
546
+ _oxide_required_tools = [
547
547
"yosys" ,
548
548
"nextpnr-nexus" ,
549
549
"prjoxide"
@@ -579,7 +579,7 @@ class LatticePlatform(TemplatedPlatform):
579
579
"{{name}}.pdc" : r"""
580
580
# {{autogenerated}}
581
581
{% 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}}{{']'}}
583
583
{% if attrs -%}
584
584
ldc_set_port -iobuf {{ '{' }}{%- for key, value in attrs.items() %}{{key}}={{value}} {% endfor %}{{ '}' }} {{'['}}get_ports {{port_name}}{{']'}}
585
585
{% endif %}
@@ -605,7 +605,7 @@ class LatticePlatform(TemplatedPlatform):
605
605
{{invoke_tool("nextpnr-nexus")}}
606
606
{{get_override("nextpnr_opts")|options}}
607
607
--log {{name}}.tim
608
- --device {{platform.device}}-{{platform.speed}}{{platform.package}}{{platform.grade}}
608
+ --device {{platform.device}}-{{platform.speed}}{{platform.package}}{{platform.grade}}
609
609
--pdc {{name}}.pdc
610
610
--json {{name}}.json
611
611
--fasm {{name}}.fasm
@@ -818,7 +818,8 @@ def __init__(self, *, toolchain=None):
818
818
device = self .device .lower ()
819
819
if device .startswith (("lfe5" , "lae5" )):
820
820
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-" )):
822
823
self .family = "machxo2"
823
824
elif device .startswith (("lifcl-" , "lfcpnx-" , "lfd2nx-" , "lfmxo5-" , "ut24c" )):
824
825
self .family = "nexus"
@@ -921,30 +922,36 @@ def create_missing_domain(self, name):
921
922
m = Module ()
922
923
if self .default_clk == "OSCG" :
923
924
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" )
926
927
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 } " )
930
931
clk_i = Signal ()
931
932
m .submodules += Instance ("OSCG" , p_DIV = self .oscg_div , o_OSC = clk_i )
932
933
elif self .default_clk == "OSCH" :
933
934
osch_freq = self .osch_frequency
934
935
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} " )
937
939
osch_freq_param = f"{ float (osch_freq ):.2f} "
938
940
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
+ )
940
947
elif self .default_clk == "OSCA" :
941
948
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" )
944
951
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 } " )
948
955
clk_i = Signal ()
949
956
m .submodules += Instance ("OSCA" ,
950
957
p_HF_CLK_DIV = str (self .osca_div - 1 ),
@@ -968,17 +975,15 @@ def create_missing_domain(self, name):
968
975
# Here we build a simple reset synchronizer from D-type FFs with a positive-level
969
976
# asynchronous preset which we tie low
970
977
m .submodules += [
971
- Instance (
972
- "FD1P3BX" ,
978
+ Instance ("FD1P3BX" ,
973
979
p_GSR = "DISABLED" ,
974
980
i_CK = clk_i ,
975
981
i_D = ~ rst_i ,
976
982
i_SP = Const (1 ),
977
983
i_PD = Const (0 ),
978
984
o_Q = gsr0 ,
979
985
),
980
- Instance (
981
- "FD1P3BX" ,
986
+ Instance ("FD1P3BX" ,
982
987
p_GSR = "DISABLED" ,
983
988
i_CK = clk_i ,
984
989
i_D = gsr0 ,
@@ -992,9 +997,9 @@ def create_missing_domain(self, name):
992
997
m .submodules += [
993
998
Instance ("FD1S3AX" , p_GSR = "DISABLED" , i_CK = clk_i , i_D = ~ rst_i , o_Q = gsr0 ),
994
999
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.)
998
1003
Instance ("SGSR" , i_CLK = clk_i , i_GSR = gsr1 ),
999
1004
]
1000
1005
# GSR implicitly connects to every appropriate storage element. As such, the sync
0 commit comments