Start adding connections
This commit is contained in:
parent
c5e7893710
commit
de33b7b19b
182
gatemate/die.py
182
gatemate/die.py
|
|
@ -6,6 +6,11 @@ def max_row():
|
||||||
def max_col():
|
def max_col():
|
||||||
return 163
|
return 163
|
||||||
|
|
||||||
|
def is_sb(x,y):
|
||||||
|
if (x>=-1 and x<=162 and y>=-1 and y<=130):
|
||||||
|
return (x+1) % 2 == (y+1) % 2
|
||||||
|
return False
|
||||||
|
|
||||||
def is_sb_big(x,y):
|
def is_sb_big(x,y):
|
||||||
if (x>=-1 and x<=162 and y>=-1 and y<=130):
|
if (x>=-1 and x<=162 and y>=-1 and y<=130):
|
||||||
if (x+1) % 2 == 1 and (y+1) % 2 == 1:
|
if (x+1) % 2 == 1 and (y+1) % 2 == 1:
|
||||||
|
|
@ -22,8 +27,11 @@ def is_sb_sml(x,y):
|
||||||
return True if (x+1) % 4 != (y+1) % 4 else False
|
return True if (x+1) % 4 != (y+1) % 4 else False
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_sb_type(x,y):
|
||||||
|
return "SB_BIG" if is_sb_big(x,y) else "SB_SML"
|
||||||
|
|
||||||
def is_cpe(x,y):
|
def is_cpe(x,y):
|
||||||
return x>=1 and x<=160 and y>=1 and y<=128
|
return not(x<=0 or x>=160 or y<=0 or y>=120)
|
||||||
|
|
||||||
def is_outmux(x,y):
|
def is_outmux(x,y):
|
||||||
return is_cpe(x,y) and (x+1) % 2 == (y+1) % 2
|
return is_cpe(x,y) and (x+1) % 2 == (y+1) % 2
|
||||||
|
|
@ -276,7 +284,7 @@ def get_endpoints_for_type(type):
|
||||||
|
|
||||||
def get_mux_connections_for_type(type):
|
def get_mux_connections_for_type(type):
|
||||||
muxes = []
|
muxes = []
|
||||||
def create_pip(src, dst, bits, value):
|
def create_mux(src, dst, bits, value):
|
||||||
mux = dst.replace(".","_") + "_MUX"
|
mux = dst.replace(".","_") + "_MUX"
|
||||||
muxes.append({"src":src, "dst":dst, "mux":mux, "bits":bits, "value": value})
|
muxes.append({"src":src, "dst":dst, "mux":mux, "bits":bits, "value": value})
|
||||||
|
|
||||||
|
|
@ -285,10 +293,10 @@ def get_mux_connections_for_type(type):
|
||||||
for p in range(12):
|
for p in range(12):
|
||||||
plane = f"{p+1:02d}"
|
plane = f"{p+1:02d}"
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
create_pip(f"INMUX.P{plane}.D{i}", f"INMUX.P{plane}.Y", 3, i)
|
create_mux(f"INMUX.P{plane}.D{i}", f"INMUX.P{plane}.Y", 3, i)
|
||||||
if "_" in type and p>7: # OUTMUX only on CPE_BIG and CPE_SML
|
if "_" in type and p>7: # OUTMUX only on CPE_BIG and CPE_SML
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
create_pip(f"OUTMUX.P{plane}.D{i}", f"OUTMUX.P{plane}.Y", 2, i)
|
create_mux(f"OUTMUX.P{plane}.D{i}", f"OUTMUX.P{plane}.Y", 2, i)
|
||||||
|
|
||||||
if "BIG" in type:
|
if "BIG" in type:
|
||||||
# SB_BIG
|
# SB_BIG
|
||||||
|
|
@ -296,44 +304,44 @@ def get_mux_connections_for_type(type):
|
||||||
plane = f"{p+1:02d}"
|
plane = f"{p+1:02d}"
|
||||||
# Per Y output mux
|
# Per Y output mux
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
create_pip(f"SB_BIG.P{plane}.D0", f"SB_BIG.P{plane}.Y{i+1}", 3, 0)
|
create_mux(f"SB_BIG.P{plane}.D0", f"SB_BIG.P{plane}.Y{i+1}", 3, 0)
|
||||||
create_pip(f"SB_BIG.P{plane}.YDIAG", f"SB_BIG.P{plane}.Y{i+1}", 3, 1)
|
create_mux(f"SB_BIG.P{plane}.YDIAG", f"SB_BIG.P{plane}.Y{i+1}", 3, 1)
|
||||||
create_pip(f"SB_BIG.P{plane}.D2_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 2)
|
create_mux(f"SB_BIG.P{plane}.D2_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 2)
|
||||||
create_pip(f"SB_BIG.P{plane}.D3_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 3)
|
create_mux(f"SB_BIG.P{plane}.D3_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 3)
|
||||||
create_pip(f"SB_BIG.P{plane}.D4_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 4)
|
create_mux(f"SB_BIG.P{plane}.D4_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 4)
|
||||||
create_pip(f"SB_BIG.P{plane}.D5_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 5)
|
create_mux(f"SB_BIG.P{plane}.D5_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 5)
|
||||||
create_pip(f"SB_BIG.P{plane}.D6_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 6)
|
create_mux(f"SB_BIG.P{plane}.D6_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 6)
|
||||||
create_pip(f"SB_BIG.P{plane}.D7_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 7)
|
create_mux(f"SB_BIG.P{plane}.D7_{i+1}", f"SB_BIG.P{plane}.Y{i+1}", 3, 7)
|
||||||
|
|
||||||
# YDIAG output mux
|
# YDIAG output mux
|
||||||
create_pip(f"SB_BIG.P{plane}.Y1", f"SB_BIG.P{plane}.YDIAG", 3, 0)
|
create_mux(f"SB_BIG.P{plane}.Y1", f"SB_BIG.P{plane}.YDIAG", 3, 0)
|
||||||
create_pip(f"SB_BIG.P{plane}.Y2", f"SB_BIG.P{plane}.YDIAG", 3, 1)
|
create_mux(f"SB_BIG.P{plane}.Y2", f"SB_BIG.P{plane}.YDIAG", 3, 1)
|
||||||
create_pip(f"SB_BIG.P{plane}.Y3", f"SB_BIG.P{plane}.YDIAG", 3, 2)
|
create_mux(f"SB_BIG.P{plane}.Y3", f"SB_BIG.P{plane}.YDIAG", 3, 2)
|
||||||
create_pip(f"SB_BIG.P{plane}.Y4", f"SB_BIG.P{plane}.YDIAG", 3, 3)
|
create_mux(f"SB_BIG.P{plane}.Y4", f"SB_BIG.P{plane}.YDIAG", 3, 3)
|
||||||
create_pip(f"SB_BIG.P{plane}.X34", f"SB_BIG.P{plane}.YDIAG", 3, 4)
|
create_mux(f"SB_BIG.P{plane}.X34", f"SB_BIG.P{plane}.YDIAG", 3, 4)
|
||||||
create_pip(f"SB_BIG.P{plane}.X14", f"SB_BIG.P{plane}.YDIAG", 3, 5)
|
create_mux(f"SB_BIG.P{plane}.X14", f"SB_BIG.P{plane}.YDIAG", 3, 5)
|
||||||
create_pip(f"SB_BIG.P{plane}.X12", f"SB_BIG.P{plane}.YDIAG", 3, 6)
|
create_mux(f"SB_BIG.P{plane}.X12", f"SB_BIG.P{plane}.YDIAG", 3, 6)
|
||||||
create_pip(f"SB_BIG.P{plane}.X23", f"SB_BIG.P{plane}.YDIAG", 3, 7)
|
create_mux(f"SB_BIG.P{plane}.X23", f"SB_BIG.P{plane}.YDIAG", 3, 7)
|
||||||
if "SML" in type:
|
if "SML" in type:
|
||||||
# SB_SML
|
# SB_SML
|
||||||
for p in range(12):
|
for p in range(12):
|
||||||
plane = f"{p+1:02d}"
|
plane = f"{p+1:02d}"
|
||||||
# Per Y output mux
|
# Per Y output mux
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
create_pip(f"SB_SML.P{plane}.D0", f"SB_SML.P{plane}.Y{i+1}", 2, 0)
|
create_mux(f"SB_SML.P{plane}.D0", f"SB_SML.P{plane}.Y{i+1}", 2, 0)
|
||||||
create_pip(f"SB_SML.P{plane}.YDIAG", f"SB_SML.P{plane}.Y{i+1}", 2, 1)
|
create_mux(f"SB_SML.P{plane}.YDIAG", f"SB_SML.P{plane}.Y{i+1}", 2, 1)
|
||||||
create_pip(f"SB_SML.P{plane}.D2_{i+1}", f"SB_SML.P{plane}.Y{i+1}", 2, 2)
|
create_mux(f"SB_SML.P{plane}.D2_{i+1}", f"SB_SML.P{plane}.Y{i+1}", 2, 2)
|
||||||
create_pip(f"SB_SML.P{plane}.D3_{i+1}", f"SB_SML.P{plane}.Y{i+1}", 2, 3)
|
create_mux(f"SB_SML.P{plane}.D3_{i+1}", f"SB_SML.P{plane}.Y{i+1}", 2, 3)
|
||||||
|
|
||||||
# YDIAG output mux
|
# YDIAG output mux
|
||||||
create_pip(f"SB_SML.P{plane}.Y1", f"SB_SML.P{plane}.YDIAG", 3, 0)
|
create_mux(f"SB_SML.P{plane}.Y1", f"SB_SML.P{plane}.YDIAG", 3, 0)
|
||||||
create_pip(f"SB_SML.P{plane}.Y2", f"SB_SML.P{plane}.YDIAG", 3, 1)
|
create_mux(f"SB_SML.P{plane}.Y2", f"SB_SML.P{plane}.YDIAG", 3, 1)
|
||||||
create_pip(f"SB_SML.P{plane}.Y3", f"SB_SML.P{plane}.YDIAG", 3, 2)
|
create_mux(f"SB_SML.P{plane}.Y3", f"SB_SML.P{plane}.YDIAG", 3, 2)
|
||||||
create_pip(f"SB_SML.P{plane}.Y4", f"SB_SML.P{plane}.YDIAG", 3, 3)
|
create_mux(f"SB_SML.P{plane}.Y4", f"SB_SML.P{plane}.YDIAG", 3, 3)
|
||||||
create_pip(f"SB_SML.P{plane}.X34", f"SB_SML.P{plane}.YDIAG", 3, 4)
|
create_mux(f"SB_SML.P{plane}.X34", f"SB_SML.P{plane}.YDIAG", 3, 4)
|
||||||
create_pip(f"SB_SML.P{plane}.X14", f"SB_SML.P{plane}.YDIAG", 3, 5)
|
create_mux(f"SB_SML.P{plane}.X14", f"SB_SML.P{plane}.YDIAG", 3, 5)
|
||||||
create_pip(f"SB_SML.P{plane}.X12", f"SB_SML.P{plane}.YDIAG", 3, 6)
|
create_mux(f"SB_SML.P{plane}.X12", f"SB_SML.P{plane}.YDIAG", 3, 6)
|
||||||
create_pip(f"SB_SML.P{plane}.X23", f"SB_SML.P{plane}.YDIAG", 3, 7)
|
create_mux(f"SB_SML.P{plane}.X23", f"SB_SML.P{plane}.YDIAG", 3, 7)
|
||||||
|
|
||||||
#if "GPIO" in type:
|
#if "GPIO" in type:
|
||||||
# # GPIO
|
# # GPIO
|
||||||
|
|
@ -384,28 +392,27 @@ def get_tile_type(x,y):
|
||||||
else:
|
else:
|
||||||
return "NONE"
|
return "NONE"
|
||||||
|
|
||||||
def get_connections():
|
|
||||||
conn = dict()
|
conn = dict()
|
||||||
|
debug_conn = False
|
||||||
|
|
||||||
def create_conn(src_x,src_y, src, dst_x, dst_y, dst):
|
def create_conn(src_x,src_y, src, dst_x, dst_y, dst):
|
||||||
key_val = f"{src_x}/{src_y}/{src}"
|
key_val = f"{src_x}/{src_y}/{src}"
|
||||||
key = {
|
key = { "x" : src_x, "y" : src_y, "w" : src }
|
||||||
"x" : src_x,
|
item = { "x" : dst_x,"y" : dst_y, "w" : dst }
|
||||||
"y" : src_y,
|
|
||||||
"w" : src
|
|
||||||
}
|
|
||||||
item = {
|
|
||||||
"x" : dst_x,
|
|
||||||
"y" : dst_y,
|
|
||||||
"w" : dst
|
|
||||||
}
|
|
||||||
if key_val not in conn:
|
if key_val not in conn:
|
||||||
conn[key_val] = list()
|
conn[key_val] = list()
|
||||||
conn[key_val].append(key)
|
conn[key_val].append(key)
|
||||||
conn[key_val].append(item)
|
conn[key_val].append(item)
|
||||||
|
if debug_conn:
|
||||||
|
print(f"({src_x},{src_y}) {src} => ({dst_x},{dst_y}) {dst}")
|
||||||
|
|
||||||
for y in range(-2, max_row()+1):
|
|
||||||
for x in range(-2, max_col()+1):
|
def alt_plane(dir,plane):
|
||||||
if is_cpe(x,y):
|
alt = [[5, 6, 7, 8, 1, 2, 3, 4,11,12, 9,10],
|
||||||
|
[9,10,11,12, 9,10,11,12,12,11,10, 9]]
|
||||||
|
return alt[dir][plane-1]
|
||||||
|
|
||||||
|
def create_cpe(x,y):
|
||||||
create_conn(x,y,"INMUX.P01.Y", x,y,"CPE.IN1")
|
create_conn(x,y,"INMUX.P01.Y", x,y,"CPE.IN1")
|
||||||
create_conn(x,y,"INMUX.P02.Y", x,y,"CPE.IN2")
|
create_conn(x,y,"INMUX.P02.Y", x,y,"CPE.IN2")
|
||||||
create_conn(x,y,"INMUX.P03.Y", x,y,"CPE.IN3")
|
create_conn(x,y,"INMUX.P03.Y", x,y,"CPE.IN3")
|
||||||
|
|
@ -417,7 +424,6 @@ def get_connections():
|
||||||
create_conn(x,y,"INMUX.P09.Y", x,y,"CPE.CLK")
|
create_conn(x,y,"INMUX.P09.Y", x,y,"CPE.CLK")
|
||||||
create_conn(x,y,"INMUX.P10.Y", x,y,"CPE.EN")
|
create_conn(x,y,"INMUX.P10.Y", x,y,"CPE.EN")
|
||||||
create_conn(x,y,"INMUX.P11.Y", x,y,"CPE.SR")
|
create_conn(x,y,"INMUX.P11.Y", x,y,"CPE.SR")
|
||||||
|
|
||||||
if is_cpe(x,y-1):
|
if is_cpe(x,y-1):
|
||||||
create_conn(x,y-1,"CPE.COUTY1", x,y,"CPE.CINY1")
|
create_conn(x,y-1,"CPE.COUTY1", x,y,"CPE.CINY1")
|
||||||
create_conn(x,y-1,"CPE.COUTY2", x,y,"CPE.CINY2")
|
create_conn(x,y-1,"CPE.COUTY2", x,y,"CPE.CINY2")
|
||||||
|
|
@ -427,5 +433,87 @@ def get_connections():
|
||||||
create_conn(x-1,y,"CPE.COUTX", x,y,"CPE.CINX")
|
create_conn(x-1,y,"CPE.COUTX", x,y,"CPE.CINX")
|
||||||
create_conn(x-1,y,"CPE.POUTX", x,y,"CPE.PINX")
|
create_conn(x-1,y,"CPE.POUTX", x,y,"CPE.PINX")
|
||||||
|
|
||||||
|
def create_inmux(x,y):
|
||||||
|
for p in range(1,13):
|
||||||
|
plane = f"{p:02d}"
|
||||||
|
|
||||||
|
# D0 - D3 are from nearby SBs
|
||||||
|
offset = 2 if is_sb(x,y) else 1
|
||||||
|
create_conn(x-offset,y,f"{get_sb_type(x-offset,y)}.P{plane}.Y1", x,y,f"INMUX.P{plane}.D0")
|
||||||
|
create_conn(x,y-offset,f"{get_sb_type(x,y-offset)}.P{plane}.Y2", x,y,f"INMUX.P{plane}.D1")
|
||||||
|
create_conn(x+offset,y,f"{get_sb_type(x+offset,y)}.P{plane}.Y3", x,y,f"INMUX.P{plane}.D2")
|
||||||
|
create_conn(x,y+offset,f"{get_sb_type(x,y+offset)}.P{plane}.Y4", x,y,f"INMUX.P{plane}.D3")
|
||||||
|
|
||||||
|
# D4 and D5 are from diagonal INMUX
|
||||||
|
if is_cpe(x-1,y-1):
|
||||||
|
create_conn(x-1,y-1,f"INMUX.P{plane}.Y", x,y,f"INMUX.P{plane}.D4")
|
||||||
|
if is_cpe(x+1,y+1):
|
||||||
|
create_conn(x+1,y+1,f"INMUX.P{plane}.Y", x,y,f"INMUX.P{plane}.D5")
|
||||||
|
|
||||||
|
# D6 and D7 are from alternate planes
|
||||||
|
alt = f"{alt_plane(0,p):02d}"
|
||||||
|
create_conn(x,y,f"INMUX.P{alt}.Y", x,y,f"INMUX.P{plane}.D6")
|
||||||
|
alt = f"{alt_plane(1,p):02d}"
|
||||||
|
create_conn(x,y,f"INMUX.P{alt}.Y", x,y,f"INMUX.P{plane}.D7")
|
||||||
|
|
||||||
|
OUT_PLANE_1 = [ 2, 1, 2, 1, 1, 2, 1, 2]
|
||||||
|
OUT_PLANE_2 = [ 1, 2, 1, 2, 2, 1, 2, 1]
|
||||||
|
|
||||||
|
def create_sb(x,y):
|
||||||
|
block_x = ((x-1) & ~1) + 1
|
||||||
|
block_y = ((y-1) & ~1) + 1
|
||||||
|
sb_type = get_sb_type(x,y)
|
||||||
|
|
||||||
|
for p in range(1,13):
|
||||||
|
plane = f"{p:02d}"
|
||||||
|
# Handling input D0
|
||||||
|
if is_cpe(x,y):
|
||||||
|
# Core section SBs are connected to CPE
|
||||||
|
if (p<9):
|
||||||
|
# planes 1..8
|
||||||
|
# for SB in lower left section of block
|
||||||
|
# x offset +0 y offset +0 output 2 plane 1
|
||||||
|
# x offset +0 y offset +1 output 1 plane 2
|
||||||
|
# x offset +1 y offset +0 output 2 plane 3
|
||||||
|
# x offset +1 y offset +1 output 1 plane 4
|
||||||
|
# x offset +0 y offset +0 output 1 plane 5
|
||||||
|
# x offset +0 y offset +1 output 2 plane 6
|
||||||
|
# x offset +1 y offset +0 output 1 plane 7
|
||||||
|
# x offset +1 y offset +1 output 2 plane 8
|
||||||
|
# for SB in upper right section of block
|
||||||
|
# difference is only that outputs are reversed
|
||||||
|
x_cpe = block_x + (1 if (p-1) & 2 else 0)
|
||||||
|
y_cpe = block_y + (1 if (p-1) & 1 else 0)
|
||||||
|
out = OUT_PLANE_1[p-1] if x & 1 else OUT_PLANE_2[p-1]
|
||||||
|
create_conn(x_cpe,y_cpe,f"CPE.OUT{out}", x,y,f"{sb_type}.P{plane}.D0")
|
||||||
|
else:
|
||||||
|
# planes 9..12
|
||||||
|
create_conn(x,y,f"OUTMUX.P{plane}.Y", x,y,f"{sb_type}.P{plane}.D0")
|
||||||
|
# else:
|
||||||
|
# Handling GPIO connections
|
||||||
|
# Handling other inputs
|
||||||
|
|
||||||
|
|
||||||
|
def create_outmux(x,y):
|
||||||
|
block_x = ((x-1) & ~1) + 1
|
||||||
|
block_y = ((y-1) & ~1) + 1
|
||||||
|
for p in range(9,13):
|
||||||
|
plane = f"{p:02d}"
|
||||||
|
output_1 = 1 if (x % 2) ^ (p % 2) else 2
|
||||||
|
output_2 = 2 if (x % 2) ^ (p % 2) else 1
|
||||||
|
create_conn(block_x, block_y, f"CPE.OUT{output_1}", x,y, f"OUTMUX.P{plane}.D0")
|
||||||
|
create_conn(block_x, block_y+1, f"CPE.OUT{output_1}", x,y, f"OUTMUX.P{plane}.D1")
|
||||||
|
create_conn(block_x+1, block_y, f"CPE.OUT{output_2}", x,y, f"OUTMUX.P{plane}.D2")
|
||||||
|
create_conn(block_x+1, block_y+1, f"CPE.OUT{output_2}", x,y, f"OUTMUX.P{plane}.D3")
|
||||||
|
|
||||||
|
def get_connections():
|
||||||
|
for y in range(-2, max_row()+1):
|
||||||
|
for x in range(-2, max_col()+1):
|
||||||
|
if is_cpe(x,y):
|
||||||
|
create_cpe(x,y)
|
||||||
|
create_inmux(x,y)
|
||||||
|
if is_outmux(x,y):
|
||||||
|
create_outmux(x,y)
|
||||||
|
if is_sb(x,y):
|
||||||
|
create_sb(x,y)
|
||||||
return conn.items()
|
return conn.items()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue