@@ -177,16 +177,26 @@ def bank_tiles(self):
177177# If suddenly a command is given to assign an already used wire to another
178178# node, then all the contents of this node are combined with the existing one,
179179# and the node itself is destroyed.
180+ # To prevent further attempts to add wires to the destroyed node, we return the
181+ # name of the node to which the connection was made
180182wire2node = {}
181183def add_node (dev , node_name , wire_type , row , col , wire ):
182184 if (row , col , wire ) not in wire2node :
183185 wire2node [row , col , wire ] = node_name
184186 dev .nodes .setdefault (node_name , (wire_type , set ()))[1 ].add ((row , col , wire ))
187+ return node_name
185188 else :
186- if node_name != wire2node [row , col , wire ] and node_name in dev .nodes :
187- #print(f'{node_name} -> {wire2node[row, col, wire]} share ({row}, {col}, {wire})')
188- dev .nodes [wire2node [row , col , wire ]][1 ].update (dev .nodes [node_name ][1 ])
189- del dev .nodes [node_name ]
189+ old_node_name = wire2node [row , col , wire ]
190+ if node_name != old_node_name :
191+ if node_name in dev .nodes :
192+ #print(f'#0 {node_name} -> {wire2node[row, col, wire]} share ({row}, {col}, {wire})')
193+ dev .nodes [old_node_name ][1 ].update (dev .nodes [node_name ][1 ])
194+ del dev .nodes [node_name ]
195+ else :
196+ #print(f'#1 {node_name} -> {wire2node[row, col, wire]} share ({row}, {col}, {wire})')
197+ dev .nodes [old_node_name ][1 ].add ((row , col , wire ))
198+ return old_node_name
199+ return node_name
190200
191201# create bels for entry potints to the global clock nets
192202def add_buf_bel (dev , row , col , wire , buf_type = 'BUFG' ):
@@ -1036,6 +1046,24 @@ def fse_create_hclk_aliases(db, device, dat: Datfile):
10361046 1 : HCLK_PINS ((27 ,0 ), [("CALIB" ,27 ,0 ,"C5" ), ("RESETN" ,27 ,0 ,"B5" ) ], [("RESETN" ,27 ,0 ,"A1" ) ], [("RESETN" ,27 ,0 ,"C1" )])
10371047 }
10381048 },
1049+ "GW1N-9" : {
1050+ "TOPSIDE" :{
1051+ 0 : HCLK_PINS ((0 ,0 ), [("CALIB" ,9 ,0 ,"A2" ), ("RESETN" ,9 ,0 ,"B0" )], [("RESETN" ,9 ,0 ,"B2" )], [("RESETN" ,9 ,0 ,"B4" )]),
1052+ 1 : HCLK_PINS ((0 ,46 ), [("CALIB" ,9 ,0 ,"A3" ), ("RESETN" ,9 ,0 ,"B1" )], [("RESETN" ,9 ,0 ,"B3" )], [("RESETN" ,9 ,0 ,"B5" )])
1053+ },
1054+ "RIGHTSIDE" :{
1055+ 0 : HCLK_PINS ((18 ,46 ), [("CALIB" ,18 ,46 ,"A2" ), ("RESETN" ,18 ,46 ,"B0" )], [("RESETN" ,18 ,46 ,"B2" )], [("RESETN" ,18 ,46 ,"B4" )]),
1056+ 1 : HCLK_PINS ((18 ,46 ), [("CALIB" ,18 ,46 ,"A3" ), ("RESETN" ,18 ,46 ,"B1" )], [("RESETN" ,18 ,46 ,"B3" )], [("RESETN" ,18 ,46 ,"B5" )])
1057+ },
1058+ "BOTTOMSIDE" :{
1059+ 0 : HCLK_PINS ((28 ,0 ), [("CALIB" ,28 ,0 ,"D0" ), ("RESETN" ,28 ,0 ,"D2" )], [("RESETN" ,28 ,0 ,"D4" )], [("RESETN" ,28 ,0 ,"C0" )]),
1060+ 1 : HCLK_PINS ((28 ,46 ), [("CALIB" ,28 ,0 ,"D1" ), ("RESETN" ,28 ,0 ,"D3" )], [("RESETN" ,28 ,0 ,"D5" )], [("RESETN" ,28 ,0 ,"C1" )])
1061+ },
1062+ "LEFTSIDE" :{
1063+ 0 : HCLK_PINS ((18 ,0 ), [("CALIB" ,18 ,0 ,"A2" ), ("RESETN" ,18 ,0 ,"B0" ) ], [("RESETN" ,18 ,0 ,"B2" ) ], [("RESETN" ,18 ,0 ,"B4" ) ]),
1064+ 1 : HCLK_PINS ((18 ,0 ), [("CALIB" ,18 ,0 ,"A3" ), ("RESETN" ,18 ,0 ,"B1" ) ], [("RESETN" ,18 ,0 ,"B3" ) ], [("RESETN" ,18 ,0 ,"B5" ) ])
1065+ }
1066+ },
10391067 "GW1N-9C" : {
10401068 "TOPSIDE" :{
10411069 0 : HCLK_PINS ((0 ,0 ), [("CALIB" ,9 ,0 ,"A2" ), ("RESETN" ,9 ,0 ,"B0" )], [("RESETN" ,9 ,0 ,"B2" )], [("RESETN" ,9 ,0 ,"B4" )]),
@@ -1053,7 +1081,51 @@ def fse_create_hclk_aliases(db, device, dat: Datfile):
10531081 0 : HCLK_PINS ((18 ,0 ), [("CALIB" ,18 ,0 ,"A2" ), ("RESETN" ,18 ,0 ,"B0" ) ], [("RESETN" ,18 ,0 ,"B2" ) ], [("RESETN" ,18 ,0 ,"B4" ) ]),
10541082 1 : HCLK_PINS ((18 ,0 ), [("CALIB" ,18 ,0 ,"A3" ), ("RESETN" ,18 ,0 ,"B1" ) ], [("RESETN" ,18 ,0 ,"B3" ) ], [("RESETN" ,18 ,0 ,"B5" ) ])
10551083 }
1056- }
1084+ },
1085+ "GW1N-1" : {
1086+ "BOTTOMSIDE" :{
1087+ 0 : HCLK_PINS ((10 , 0 ), [("CALIB" , 10 , 0 , "D2" ), ("RESETN" , 10 , 0 , "D0" )], [("RESETN" , 10 , 0 , "D4" )], [("RESETN" , 10 , 0 , "D6" )]),
1088+ 1 : HCLK_PINS ((10 , 19 ), [("CALIB" , 10 , 0 , "D3" ), ("RESETN" , 10 , 0 , "D1" )], [("RESETN" , 10 , 0 , "D5" )], [("RESETN" , 10 , 0 , "D7" )])
1089+ },
1090+ },
1091+ "GW1NZ-1" : {
1092+ "TOPSIDE" :{
1093+ 0 : HCLK_PINS ((0 , 5 ), [("CALIB" , 0 , 19 , "D3" ), ("RESETN" , 0 , 19 , "D1" )], [("RESETN" , 0 , 18 , "C2" )], [("RESETN" , 0 , 18 , "C4" )]),
1094+ 1 : HCLK_PINS ((0 , 5 ), [("CALIB" , 0 , 19 , "D2" ), ("RESETN" , 0 , 19 , "D0" )], [("RESETN" , 0 , 18 , "C3" )], [("RESETN" , 0 , 18 , "C5" )])
1095+ },
1096+ "RIGHTSIDE" :{
1097+ 0 : HCLK_PINS ((5 , 19 ), [("CALIB" , 10 , 19 , "D3" ), ("RESETN" , 10 , 19 , "D1" )], [("RESETN" , 10 , 18 , "C2" )], [("RESETN" , 10 , 18 , "C4" )]),
1098+ 1 : HCLK_PINS ((5 , 19 ), [("CALIB" , 10 , 19 , "D2" ), ("RESETN" , 10 , 19 , "D1" )], [("RESETN" , 10 , 18 , "C3" )], [("RESETN" , 10 , 18 , "C5" )])
1099+ },
1100+ },
1101+ "GW1NS-4" : {
1102+ "TOPSIDE" :{
1103+ 0 : HCLK_PINS ((0 , 18 ), [("CALIB" , 1 , 0 , "C0" ), ("RESETN" , 0 , 0 , "C5" )], [("RESETN" , 0 , 0 , "B1" )], [("RESETN" , 1 , 0 , "C6" )]),
1104+ 1 : HCLK_PINS ((0 , 18 ), [("CALIB" , 1 , 0 , "D7" ), ("RESETN" , 0 , 0 , "B0" )], [("RESETN" , 1 , 0 , "C7" )], [("RESETN" , 1 , 0 , "C5" )])
1105+ },
1106+ "RIGHTSIDE" :{
1107+ 0 : HCLK_PINS ((9 , 37 ), [("CALIB" , 0 , 37 , "D7" ), ("RESETN" , 0 , 37 , "D5" )], [("RESETN" , 0 , 37 , "C3" )], [("RESETN" , 0 , 37 , "C1" )]),
1108+ 1 : HCLK_PINS ((9 , 37 ), [("CALIB" , 0 , 37 , "D6" ), ("RESETN" , 0 , 37 , "D6" )], [("RESETN" , 0 , 37 , "C2" )], [("RESETN" , 0 , 37 , "C0" )])
1109+ },
1110+ "BOTTOMSIDE" :{
1111+ 0 : HCLK_PINS ((19 , 16 ), [("CALIB" , 19 , 0 , "D0" ), ("RESETN" , 19 , 0 , "D2" )], [("RESETN" , 19 , 0 , "D4" )], [("RESETN" , 19 , 0 , "C0" )]),
1112+ 1 : HCLK_PINS ((19 , 17 ), [("CALIB" , 19 , 0 , "D1" ), ("RESETN" , 19 , 0 , "D3" )], [("RESETN" , 19 , 0 , "D5" )], [("RESETN" , 19 , 0 , "C1" )])
1113+ },
1114+ },
1115+ "GW1N-4" : {
1116+ "LEFTSIDE" :{
1117+ 0 : HCLK_PINS ((9 , 0 ), [("CALIB" , 19 , 0 ,"B4" ), ("RESETN" , 19 , 0 , "B6" ) ], [("RESETN" , 19 , 0 , "A0" )], [("RESETN" , 19 , 0 , "A2" )]),
1118+ 1 : HCLK_PINS ((9 ,0 ), [("CALIB" , 19 , 0 ,"B5" ), ("RESETN" , 19 , 0 , "B7" ) ], [("RESETN" , 19 , 0 , "A1" )], [("RESETN" , 19 , 0 , "A3" )])
1119+ },
1120+ "RIGHTSIDE" :{
1121+ 0 : HCLK_PINS ((9 , 37 ), [("CALIB" , 0 , 37 , "B7" ), ("RESETN" , 0 , 37 , "B5" )], [("RESETN" , 0 , 37 , "C3" )], [("RESETN" , 0 , 37 , "C1" )]),
1122+ 1 : HCLK_PINS ((9 , 37 ), [("CALIB" , 0 , 37 , "B6" ), ("RESETN" , 0 , 37 , "B6" )], [("RESETN" , 0 , 37 , "C2" )], [("RESETN" , 0 , 37 , "C0" )])
1123+ },
1124+ "BOTTOMSIDE" :{
1125+ 0 : HCLK_PINS ((19 , 0 ), [("CALIB" , 19 , 0 , "D0" ), ("RESETN" , 19 , 0 , "D2" )], [("RESETN" , 19 , 0 , "D4" )], [("RESETN" , 19 , 0 , "C0" )]),
1126+ 1 : HCLK_PINS ((19 , 37 ), [("CALIB" , 19 , 0 , "D1" ), ("RESETN" , 19 , 0 , "D3" )], [("RESETN" , 19 , 0 , "D5" )], [("RESETN" , 19 , 0 , "C1" )])
1127+ },
1128+ },
10571129}
10581130
10591131
@@ -1075,7 +1147,7 @@ def _iter_edge_coords(dev):
10751147
10761148def add_hclk_bels (dat , dev , device ):
10771149 #Stub for parts that don't have HCLK bel support yet
1078- if device not in ("GW2A-18" , "GW2A-18C" , "GW1N-9C " ):
1150+ if device not in ("GW2A-18" , "GW2A-18C" , "GW1N-9" , "GW1N-9C" , "GW1N-1" , "GW1NZ-1" , "GW1NS-4" , "GW1N-4 " ):
10791151 to_connect = ['HCLK0_SECT0_IN' , 'HCLK0_SECT1_IN' , 'HCLK1_SECT0_IN' , 'HCLK1_SECT1_IN' ]
10801152 for x in range (dev .cols ):
10811153 for y in range (dev .rows ):
@@ -1092,6 +1164,22 @@ def add_hclk_bels(dat, dev, device):
10921164 device = "GW2A-18"
10931165 device_hclk_pins = _device_hclk_pin_dict [device ]
10941166
1167+ if device == 'GW1NS-4' :
1168+ node_name = 'X16Y19/HCLK0_SECT0_IN'
1169+ node_name = add_node (dev , node_name , 'HCLK' , 19 , 16 , 'HCLK0_SECT0_IN' )
1170+ node_name = add_node (dev , node_name , 'HCLK' , 19 , 17 , 'HCLK0_SECT0_IN' )
1171+ node_name = 'X17Y19/HCLK1_SECT0_IN'
1172+ node_name = add_node (dev , node_name , 'HCLK' , 19 , 17 , 'HCLK1_SECT0_IN' )
1173+ node_name = add_node (dev , node_name , 'HCLK' , 19 , 20 , 'HCLK1_SECT0_IN' )
1174+ node_name = 'X17Y19/HCLK1_SECT1_IN'
1175+ node_name = add_node (dev , node_name , 'HCLK' , 19 , 17 , 'HCLK1_SECT1_IN' )
1176+ node_name = add_node (dev , node_name , 'HCLK' , 19 , 20 , 'HCLK1_SECT1_IN' )
1177+ node_name = 'X17Y19/HCLK_IN2'
1178+ node_name = add_node (dev , node_name , 'HCLK' , 19 , 17 , 'HCLK_IN2' )
1179+ node_name = add_node (dev , node_name , 'HCLK' , 19 , 20 , 'HCLK_IN2' )
1180+ node_name = 'X17Y19/HCLK_IN3'
1181+ node_name = add_node (dev , node_name , 'HCLK' , 19 , 17 , 'HCLK_IN3' )
1182+ add_node (dev , node_name , 'HCLK' , 19 , 20 , 'HCLK_IN3' )
10951183
10961184 #There is a sleight of hand going on here - there is likely only one physical CLKDIV bel per HCLK
10971185 #However because of how they are connected, and how I suspect that the muxes that utilize them are,
@@ -1132,7 +1220,7 @@ def add_hclk_bels(dat, dev, device):
11321220 dev .grid [tile_row ][tile_col ].bels [clkdiv2_name ] = clkdiv2
11331221 dev .grid [tile_row ][tile_col ].bels [clkdiv_name ] = clkdiv #We still create this so as not to break the PnR logic
11341222
1135- if device in ( "GW1N-9C, GW1NR-9C" ) :
1223+ if device == "GW1N-9C" :
11361224 clkdiv2_in = f"HCLK{ idx } _SECT{ section } _IN" if section == 0 else f"HCLK_IN{ idx * 2 + section } "
11371225 dev .hclk_pips [tile_row ,tile_col ][clkdiv2 .portmap ["HCLKIN" ]] = {clkdiv2_in :set ()}
11381226 sect_div2_mux = f"HCLK{ idx } _SECT{ section } _MUX_DIV2"
@@ -1150,7 +1238,6 @@ def add_hclk_bels(dat, dev, device):
11501238
11511239 else :
11521240 dev .hclk_pips [tile_row ,tile_col ][clkdiv2 .portmap ["HCLKIN" ]] = {f"HCLK{ idx } _SECT{ section } _IN" :set ()}
1153- # sect_div2_mux = f"HCLK{idx}_SECT{section}_MUX_DIV2"
11541241 sect_div2_mux = f"HCLK{ idx } _SECT{ section } _MUX2"
11551242 dev .hclk_pips [tile_row ,tile_col ][sect_div2_mux ] = {f"HCLK{ idx } _SECT{ section } _IN" :set (), clkdiv2 .portmap ["CLKOUT" ]:set ()}
11561243 dev .hclk_pips [tile_row ,tile_col ][clkdiv .portmap ["HCLKIN" ]] = ({sect_div2_mux :set ()})
@@ -1204,7 +1291,8 @@ def fse_create_hclk_nodes(dev, device, fse, dat: Datfile):
12041291 add_node (dev , f'HCLKMUX{ src [- 1 ]} ' , "GLOBAL_CLK" , row , col , src )
12051292 # strange GW1N-9C input-input aliases
12061293 for i in {0 , 2 }:
1207- dev .nodes .setdefault (f'X{ col } Y{ row } /HCLK9-{ i } ' , ('HCLK' , {(row , col , f'HCLK_IN{ i } ' )}))[1 ].add ((row , col , f'HCLK_9IN{ i } ' ))
1294+ add_node (dev , f'X{ col } Y{ row } /HCLK9-{ i } ' , 'HCLK' , row , col , f'HCLK_IN{ i } ' )
1295+ add_node (dev , f'X{ col } Y{ row } /HCLK9-{ i } ' , 'HCLK' , row , col , f'HCLK_9IN{ i } ' )
12081296 # GW1N-9C clock pin aliases
12091297 if side != 'B' : # it’s still unclear on this side, but the
12101298 # Tangnano9k external clock is not connected here, so we
0 commit comments