From 50fd8aa01fde3426ff74fcf9b0126a24f279efca Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 31 Mar 2019 17:54:52 +0100 Subject: generic: Place a single SLICE Signed-off-by: David Shah --- generic/examples/simple.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 generic/examples/simple.py (limited to 'generic/examples/simple.py') diff --git a/generic/examples/simple.py b/generic/examples/simple.py new file mode 100644 index 00000000..da41dc5b --- /dev/null +++ b/generic/examples/simple.py @@ -0,0 +1,3 @@ +ctx.addBel(name="SLICE_X1Y1", type="SLICE_LUT4", loc=Loc(1, 1, 0), gb=False) +ctx.addBel(name="IO0_I", type="$nextpnr_ibuf", loc=Loc(0, 0, 0), gb=False) +ctx.addBel(name="IO1_O", type="$nextpnr_obuf", loc=Loc(1, 0, 0), gb=False) \ No newline at end of file -- cgit v1.2.3 From ca918078bfe6c4b1a279c7df7c59fb9de0f9710a Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 1 Apr 2019 19:13:16 +0100 Subject: generic: Add a simple packer for generic SLICEs and IOBs Signed-off-by: David Shah --- generic/examples/simple.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'generic/examples/simple.py') diff --git a/generic/examples/simple.py b/generic/examples/simple.py index da41dc5b..17808fc7 100644 --- a/generic/examples/simple.py +++ b/generic/examples/simple.py @@ -1,3 +1,16 @@ -ctx.addBel(name="SLICE_X1Y1", type="SLICE_LUT4", loc=Loc(1, 1, 0), gb=False) -ctx.addBel(name="IO0_I", type="$nextpnr_ibuf", loc=Loc(0, 0, 0), gb=False) -ctx.addBel(name="IO1_O", type="$nextpnr_obuf", loc=Loc(1, 0, 0), gb=False) \ No newline at end of file +X = 12 +Y = 12 + +def is_io(x, y): + return x == 0 or x == X-1 or y == 0 or y == Y-1 + + +for x in range(X): + for y in range(Y): + if is_io(x, y): + if x == y: + continue + for z in range(2): + ctx.addBel(name="X%dY%d_IO%d" % (x, y, z), type="GENERIC_IOB", loc=Loc(x, y, z), gb=False) + else: + ctx.addBel(name="X%dY%d_SLICE%d" % (x, y, z), type="GENERIC_SLICE", loc=Loc(x, y, z), gb=False) -- cgit v1.2.3 From 6a383cd4c57db1f8bab6416daffdb24c0eb093c6 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 1 Apr 2019 19:48:51 +0100 Subject: generic: Simple procedural example works Signed-off-by: David Shah --- generic/examples/simple.py | 75 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) (limited to 'generic/examples/simple.py') diff --git a/generic/examples/simple.py b/generic/examples/simple.py index 17808fc7..b8ca3f78 100644 --- a/generic/examples/simple.py +++ b/generic/examples/simple.py @@ -1,16 +1,87 @@ +# Grid size including IOBs at edges X = 12 Y = 12 +# SLICEs per tile +Z = 8 +# LUT input count +K = 4 +# Number of local wires +L = Z*(K+1) + 8 +# "Sparsity" of bel input wire pips +Si = 4 +# "Sparsity" of Q to local wire pips +Sq = 4 +# "Sparsity" of local to neighbour local wire pips +Sl = 8 def is_io(x, y): return x == 0 or x == X-1 or y == 0 or y == Y-1 - for x in range(X): for y in range(Y): + # Bel port wires + for z in range(Z): + ctx.addWire(name="X%dY%dZ%d_CLK" % (x, y, z), type="BEL_CLK", x=x, y=y) + ctx.addWire(name="X%dY%dZ%d_Q" % (x, y, z), type="BEL_Q", x=x, y=y) + for i in range(K): + ctx.addWire(name="X%dY%dZ%d_I%d" % (x, y, z, i), type="BEL_I", x=x, y=y) + # Local wires + for l in range(L): + ctx.addWire(name="X%dY%d_LOCAL%d" % (x, y, l), type="LOCAL", x=x, y=y) + # Create bels if is_io(x, y): if x == y: continue for z in range(2): ctx.addBel(name="X%dY%d_IO%d" % (x, y, z), type="GENERIC_IOB", loc=Loc(x, y, z), gb=False) + ctx.addBelInput(bel="X%dY%d_IO%d" % (x, y, z), name="I", wire="X%dY%dZ%d_I0" % (x, y, z)) + ctx.addBelInput(bel="X%dY%d_IO%d" % (x, y, z), name="EN", wire="X%dY%dZ%d_I1" % (x, y, z)) + ctx.addBelOutput(bel="X%dY%d_IO%d" % (x, y, z), name="O", wire="X%dY%dZ%d_Q" % (x, y, z)) + else: - ctx.addBel(name="X%dY%d_SLICE%d" % (x, y, z), type="GENERIC_SLICE", loc=Loc(x, y, z), gb=False) + for z in range(Z): + ctx.addBel(name="X%dY%d_SLICE%d" % (x, y, z), type="GENERIC_SLICE", loc=Loc(x, y, z), gb=False) + ctx.addBelInput(bel="X%dY%d_SLICE%d" % (x, y, z), name="CLK", wire="X%dY%dZ%d_CLK" % (x, y, z)) + for k in range(K): + ctx.addBelInput(bel="X%dY%d_SLICE%d" % (x, y, z), name="I[%d]" % k, wire="X%dY%dZ%d_I%d" % (x, y, z, k)) + ctx.addBelOutput(bel="X%dY%d_SLICE%d" % (x, y, z), name="Q", wire="X%dY%dZ%d_Q" % (x, y, z)) + +for x in range(X): + for y in range(Y): + # Pips driving bel input wires + # Bel input wires are driven by every Si'th local with an offset + def create_input_pips(dst, offset, skip): + for i in range(offset % skip, L, skip): + src = "X%dY%d_LOCAL%d" % (x, y, i) + ctx.addPip(name="X%dY%d.%s.%s" % (x, y, src, dst), type="BEL_INPUT", + srcWire=src, dstWire=dst, delay=ctx.getDelayFromNS(0.05), loc=Loc(x, y, 0)) + for z in range(Z): + create_input_pips("X%dY%dZ%d_CLK" % (x, y, z), 0, Si) + for k in range(K): + create_input_pips("X%dY%dZ%d_I%d" % (x, y, z, k), k % Si, Si) + + # Pips from bel outputs to locals + def create_output_pips(dst, offset, skip): + for i in range(offset % skip, Z, skip): + src = "X%dY%dZ%d_Q" % (x, y, i) + ctx.addPip(name="X%dY%d.%s.%s" % (x, y, src, dst), type="BEL_OUTPUT", + srcWire=src, dstWire=dst, delay=ctx.getDelayFromNS(0.05), loc=Loc(x, y, 0)) + # Pips from neighbour locals to locals + def create_neighbour_pips(dst, nx, ny, offset, skip): + if nx < 0 or nx >= X or ny < 0 or ny >= Y: + return + for i in range(offset % skip, L, skip): + src = "X%dY%d_LOCAL%d" % (nx, ny, i) + ctx.addPip(name="X%dY%d.%s.%s" % (x, y, src, dst), type="NEIGHBOUR", + srcWire=src, dstWire=dst, delay=ctx.getDelayFromNS(0.05), loc=Loc(x, y, 0)) + for l in range(L): + dst = "X%dY%d_LOCAL%d" % (x, y, l) + create_output_pips(dst, l % Sq, Sq) + create_neighbour_pips(dst, x-1, y-1, (l + 1) % Sl, Sl) + create_neighbour_pips(dst, x-1, y, (l + 2) % Sl, Sl) + create_neighbour_pips(dst, x-1, y+1, (l + 2) % Sl, Sl) + create_neighbour_pips(dst, x, y-1, (l + 3) % Sl, Sl) + create_neighbour_pips(dst, x, y+1, (l + 4) % Sl, Sl) + create_neighbour_pips(dst, x+1, y-1, (l + 5) % Sl, Sl) + create_neighbour_pips(dst, x+1, y, (l + 6) % Sl, Sl) + create_neighbour_pips(dst, x+1, y+1, (l + 7) % Sl, Sl) \ No newline at end of file -- cgit v1.2.3 From 6fffe24177f9b99d6c332c18e343648cf33d4397 Mon Sep 17 00:00:00 2001 From: David Shah Date: Wed, 3 Apr 2019 16:08:33 +0100 Subject: generic: GUI Python bindings Signed-off-by: David Shah --- generic/examples/simple.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'generic/examples/simple.py') diff --git a/generic/examples/simple.py b/generic/examples/simple.py index b8ca3f78..2628c041 100644 --- a/generic/examples/simple.py +++ b/generic/examples/simple.py @@ -14,6 +14,10 @@ Sq = 4 # "Sparsity" of local to neighbour local wire pips Sl = 8 +# Create graphic elements +# Bels +ctx.addDecalGraphic("bel", GraphicElement(type=TYPE_BOX, style=STYLE_INACTIVE, x1=0, y1=0, x2=0.2, y2=(1/(Z+1))-0.02, z=0)) + def is_io(x, y): return x == 0 or x == X-1 or y == 0 or y == Y-1 @@ -37,7 +41,7 @@ for x in range(X): ctx.addBelInput(bel="X%dY%d_IO%d" % (x, y, z), name="I", wire="X%dY%dZ%d_I0" % (x, y, z)) ctx.addBelInput(bel="X%dY%d_IO%d" % (x, y, z), name="EN", wire="X%dY%dZ%d_I1" % (x, y, z)) ctx.addBelOutput(bel="X%dY%d_IO%d" % (x, y, z), name="O", wire="X%dY%dZ%d_Q" % (x, y, z)) - + ctx.setBelDecal(bel="X%dY%d_IO%d" % (x, y, z), decalxy=ctx.DecalXY("bel", 0.6, z * (1/(Z+1)))) else: for z in range(Z): ctx.addBel(name="X%dY%d_SLICE%d" % (x, y, z), type="GENERIC_SLICE", loc=Loc(x, y, z), gb=False) @@ -45,6 +49,7 @@ for x in range(X): for k in range(K): ctx.addBelInput(bel="X%dY%d_SLICE%d" % (x, y, z), name="I[%d]" % k, wire="X%dY%dZ%d_I%d" % (x, y, z, k)) ctx.addBelOutput(bel="X%dY%d_SLICE%d" % (x, y, z), name="Q", wire="X%dY%dZ%d_Q" % (x, y, z)) + ctx.setBelDecal(bel="X%dY%d_SLICE%d" % (x, y, z), decalxy=ctx.DecalXY("bel", 0.6, z * (1/(Z+1)))) for x in range(X): for y in range(Y): -- cgit v1.2.3 From 3f98084021b64420c36c171cc1245248d6968f03 Mon Sep 17 00:00:00 2001 From: David Shah Date: Thu, 4 Apr 2019 15:40:48 +0100 Subject: generic: Improve example Signed-off-by: David Shah --- generic/examples/simple.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'generic/examples/simple.py') diff --git a/generic/examples/simple.py b/generic/examples/simple.py index 2628c041..f87a6049 100644 --- a/generic/examples/simple.py +++ b/generic/examples/simple.py @@ -2,21 +2,21 @@ X = 12 Y = 12 # SLICEs per tile -Z = 8 +N = 8 # LUT input count K = 4 # Number of local wires -L = Z*(K+1) + 8 -# "Sparsity" of bel input wire pips +Wl = N*(K+1) + 8 +# 1/Fc for bel input wire pips Si = 4 -# "Sparsity" of Q to local wire pips +# 1/Fc for Q to local wire pips Sq = 4 -# "Sparsity" of local to neighbour local wire pips +# ~1/Fc local to neighbour local wire pips Sl = 8 # Create graphic elements # Bels -ctx.addDecalGraphic("bel", GraphicElement(type=TYPE_BOX, style=STYLE_INACTIVE, x1=0, y1=0, x2=0.2, y2=(1/(Z+1))-0.02, z=0)) +ctx.addDecalGraphic("bel", GraphicElement(type=TYPE_BOX, style=STYLE_INACTIVE, x1=0, y1=0, x2=0.2, y2=(1/(N+1))-0.02, z=0)) def is_io(x, y): return x == 0 or x == X-1 or y == 0 or y == Y-1 @@ -24,13 +24,13 @@ def is_io(x, y): for x in range(X): for y in range(Y): # Bel port wires - for z in range(Z): + for z in range(N): ctx.addWire(name="X%dY%dZ%d_CLK" % (x, y, z), type="BEL_CLK", x=x, y=y) ctx.addWire(name="X%dY%dZ%d_Q" % (x, y, z), type="BEL_Q", x=x, y=y) for i in range(K): ctx.addWire(name="X%dY%dZ%d_I%d" % (x, y, z, i), type="BEL_I", x=x, y=y) # Local wires - for l in range(L): + for l in range(Wl): ctx.addWire(name="X%dY%d_LOCAL%d" % (x, y, l), type="LOCAL", x=x, y=y) # Create bels if is_io(x, y): @@ -41,33 +41,33 @@ for x in range(X): ctx.addBelInput(bel="X%dY%d_IO%d" % (x, y, z), name="I", wire="X%dY%dZ%d_I0" % (x, y, z)) ctx.addBelInput(bel="X%dY%d_IO%d" % (x, y, z), name="EN", wire="X%dY%dZ%d_I1" % (x, y, z)) ctx.addBelOutput(bel="X%dY%d_IO%d" % (x, y, z), name="O", wire="X%dY%dZ%d_Q" % (x, y, z)) - ctx.setBelDecal(bel="X%dY%d_IO%d" % (x, y, z), decalxy=ctx.DecalXY("bel", 0.6, z * (1/(Z+1)))) + ctx.setBelDecal(bel="X%dY%d_IO%d" % (x, y, z), decalxy=ctx.DecalXY("bel", 0.6, z * (1/(N+1)))) else: - for z in range(Z): + for z in range(N): ctx.addBel(name="X%dY%d_SLICE%d" % (x, y, z), type="GENERIC_SLICE", loc=Loc(x, y, z), gb=False) ctx.addBelInput(bel="X%dY%d_SLICE%d" % (x, y, z), name="CLK", wire="X%dY%dZ%d_CLK" % (x, y, z)) for k in range(K): ctx.addBelInput(bel="X%dY%d_SLICE%d" % (x, y, z), name="I[%d]" % k, wire="X%dY%dZ%d_I%d" % (x, y, z, k)) ctx.addBelOutput(bel="X%dY%d_SLICE%d" % (x, y, z), name="Q", wire="X%dY%dZ%d_Q" % (x, y, z)) - ctx.setBelDecal(bel="X%dY%d_SLICE%d" % (x, y, z), decalxy=ctx.DecalXY("bel", 0.6, z * (1/(Z+1)))) + ctx.setBelDecal(bel="X%dY%d_SLICE%d" % (x, y, z), decalxy=ctx.DecalXY("bel", 0.6, z * (1/(N+1)))) for x in range(X): for y in range(Y): # Pips driving bel input wires # Bel input wires are driven by every Si'th local with an offset def create_input_pips(dst, offset, skip): - for i in range(offset % skip, L, skip): + for i in range(offset % skip, Wl, skip): src = "X%dY%d_LOCAL%d" % (x, y, i) ctx.addPip(name="X%dY%d.%s.%s" % (x, y, src, dst), type="BEL_INPUT", srcWire=src, dstWire=dst, delay=ctx.getDelayFromNS(0.05), loc=Loc(x, y, 0)) - for z in range(Z): + for z in range(N): create_input_pips("X%dY%dZ%d_CLK" % (x, y, z), 0, Si) for k in range(K): create_input_pips("X%dY%dZ%d_I%d" % (x, y, z, k), k % Si, Si) # Pips from bel outputs to locals def create_output_pips(dst, offset, skip): - for i in range(offset % skip, Z, skip): + for i in range(offset % skip, N, skip): src = "X%dY%dZ%d_Q" % (x, y, i) ctx.addPip(name="X%dY%d.%s.%s" % (x, y, src, dst), type="BEL_OUTPUT", srcWire=src, dstWire=dst, delay=ctx.getDelayFromNS(0.05), loc=Loc(x, y, 0)) @@ -75,11 +75,11 @@ for x in range(X): def create_neighbour_pips(dst, nx, ny, offset, skip): if nx < 0 or nx >= X or ny < 0 or ny >= Y: return - for i in range(offset % skip, L, skip): + for i in range(offset % skip, Wl, skip): src = "X%dY%d_LOCAL%d" % (nx, ny, i) ctx.addPip(name="X%dY%d.%s.%s" % (x, y, src, dst), type="NEIGHBOUR", srcWire=src, dstWire=dst, delay=ctx.getDelayFromNS(0.05), loc=Loc(x, y, 0)) - for l in range(L): + for l in range(Wl): dst = "X%dY%d_LOCAL%d" % (x, y, l) create_output_pips(dst, l % Sq, Sq) create_neighbour_pips(dst, x-1, y-1, (l + 1) % Sl, Sl) -- cgit v1.2.3 From 48c4c1ed0561e643a591ed7fca21c69954abd8d2 Mon Sep 17 00:00:00 2001 From: David Shah Date: Wed, 17 Apr 2019 11:00:23 +0100 Subject: generic/examples: Add FASM writer Python script Signed-off-by: David Shah --- generic/examples/simple.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'generic/examples/simple.py') diff --git a/generic/examples/simple.py b/generic/examples/simple.py index f87a6049..9339b68a 100644 --- a/generic/examples/simple.py +++ b/generic/examples/simple.py @@ -1,22 +1,4 @@ -# Grid size including IOBs at edges -X = 12 -Y = 12 -# SLICEs per tile -N = 8 -# LUT input count -K = 4 -# Number of local wires -Wl = N*(K+1) + 8 -# 1/Fc for bel input wire pips -Si = 4 -# 1/Fc for Q to local wire pips -Sq = 4 -# ~1/Fc local to neighbour local wire pips -Sl = 8 - -# Create graphic elements -# Bels -ctx.addDecalGraphic("bel", GraphicElement(type=TYPE_BOX, style=STYLE_INACTIVE, x1=0, y1=0, x2=0.2, y2=(1/(N+1))-0.02, z=0)) +from simple_config import * def is_io(x, y): return x == 0 or x == X-1 or y == 0 or y == Y-1 @@ -41,7 +23,6 @@ for x in range(X): ctx.addBelInput(bel="X%dY%d_IO%d" % (x, y, z), name="I", wire="X%dY%dZ%d_I0" % (x, y, z)) ctx.addBelInput(bel="X%dY%d_IO%d" % (x, y, z), name="EN", wire="X%dY%dZ%d_I1" % (x, y, z)) ctx.addBelOutput(bel="X%dY%d_IO%d" % (x, y, z), name="O", wire="X%dY%dZ%d_Q" % (x, y, z)) - ctx.setBelDecal(bel="X%dY%d_IO%d" % (x, y, z), decalxy=ctx.DecalXY("bel", 0.6, z * (1/(N+1)))) else: for z in range(N): ctx.addBel(name="X%dY%d_SLICE%d" % (x, y, z), type="GENERIC_SLICE", loc=Loc(x, y, z), gb=False) @@ -49,7 +30,6 @@ for x in range(X): for k in range(K): ctx.addBelInput(bel="X%dY%d_SLICE%d" % (x, y, z), name="I[%d]" % k, wire="X%dY%dZ%d_I%d" % (x, y, z, k)) ctx.addBelOutput(bel="X%dY%d_SLICE%d" % (x, y, z), name="Q", wire="X%dY%dZ%d_Q" % (x, y, z)) - ctx.setBelDecal(bel="X%dY%d_SLICE%d" % (x, y, z), decalxy=ctx.DecalXY("bel", 0.6, z * (1/(N+1)))) for x in range(X): for y in range(Y): -- cgit v1.2.3