Skip to content

Commit 5235555

Browse files
committed
Update himbaechel examples to support NR aliases
1 parent ab9df5f commit 5235555

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

apycula/family_aliases.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import importlib.resources
2+
import json
3+
4+
def replace_family_alias(family):
5+
with importlib.resources.path('apycula', f'family_info.json') as path:
6+
with open(path, 'r') as f:
7+
family_info = json.load(f)
8+
9+
if family in family_info:
10+
return family_info[family]["base_family"]
11+
else:
12+
return family
13+

apycula/gowin_pack.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from apycula import attrids
1818
from apycula import bslib
1919
from apycula.wirenames import wirenames, wirenumbers
20+
from apycula.family_aliases import replace_family_alias
2021

2122
device = ""
2223
pnr = None
@@ -1029,16 +1030,6 @@ def route(db, tilemap, pips):
10291030
for row, col in bits:
10301031
tile[row][col] = 1
10311032

1032-
def replace_family_alias(family):
1033-
with importlib.resources.path('apycula', f'family_info.json') as path:
1034-
with open(path, 'r') as f:
1035-
family_info = json.load(f)
1036-
1037-
if family in family_info:
1038-
return family_info[family]["base_family"]
1039-
else:
1040-
return family
1041-
10421033
def header_footer(db, bs, compress, family):
10431034
"""
10441035
Generate fs header and footer
@@ -1180,7 +1171,7 @@ def main():
11801171
parser.add_argument('--png')
11811172

11821173
args = parser.parse_args()
1183-
device = args.device
1174+
device = replace_family_alias(args.device)
11841175

11851176
with open(args.netlist) as f:
11861177
pnr = json.load(f)
@@ -1198,8 +1189,7 @@ def main():
11981189
device = f"GW1N{mods}-{luts}"
11991190
device = replace_family_alias(device)
12001191

1201-
family = replace_family_alias(args.device)
1202-
with importlib.resources.path('apycula', f'{family}.pickle') as path:
1192+
with importlib.resources.path('apycula', f'{device}.pickle') as path:
12031193
with closing(gzip.open(path, 'rb')) as f:
12041194
db = pickle.load(f)
12051195

apycula/gowin_unpack.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from apycula import attrids
1515
from apycula.bslib import read_bitstream
1616
from apycula.wirenames import wirenames
17+
from apycula.family_aliases import replace_family_alias
1718

1819
_device = ""
1920
_pinout = ""
@@ -1074,7 +1075,7 @@ def main():
10741075
args = parser.parse_args()
10751076

10761077
global _device
1077-
_device = args.device
1078+
_device = replace_family_alias(args.device)
10781079
# For tool integration it is allowed to pass a full part number
10791080
m = re.match("GW1N(S?)[A-Z]*-(LV|UV|UX)([0-9])C?([A-Z]{2}[0-9]+P?)(C[0-9]/I[0-9])", _device)
10801081
if m:

examples/himbaechel/Makefile.himbaechel

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ clean:
141141
# ============================================================
142142
# Tangnano20k
143143
%-tangnano20k.fs: %-tangnano20k.json
144-
gowin_pack -d GW2A-18C -o $@ $<
144+
gowin_pack -d GW2AR-18C -o $@ $<
145145

146146
%-tangnano20k.json: %-tangnano20k-synth.json tangnano20k.cst
147-
$(NEXTPNR) --json $< --write $@ --device GW2AR-LV18QN88C8/I7 --vopt family=GW2A-18C --vopt cst=tangnano20k.cst
147+
$(NEXTPNR) --json $< --write $@ --device GW2AR-LV18QN88C8/I7 --vopt family=GW2AR-18C --vopt cst=tangnano20k.cst
148148

149149
%-tangnano20k-synth.json: %.v
150150
$(YOSYS) -D LEDS_NR=6 -D OSC_TYPE_OSC -D INV_BTN=1 -p "read_verilog $^; synth_gowin -json $@"
@@ -223,7 +223,7 @@ blinky-pll-tangnano4k-synth.json: pll/GW1NS-4-dyn.vh blinky-pll-vr.v
223223
gowin_pack -d GW1N-9C -o $@ $^
224224

225225
%-tangnano9k.json: %-tangnano9k-synth.json tangnano9k.cst
226-
$(NEXTPNR) --json $< --write $@ --device GW1NR-LV9QN88PC6/I5 --vopt family=GW1N-9C --vopt cst=tangnano9k.cst
226+
$(NEXTPNR) --json $< --write $@ --device GW1NR-LV9QN88PC6/I5 --vopt family=GW1NR-9C --vopt cst=tangnano9k.cst
227227

228228
%-tangnano9k-synth.json: %.v
229229
$(YOSYS) -D LEDS_NR=6 -D OSC_TYPE_OSC -D INV_BTN=0 -p "read_verilog $^; synth_gowin -json $@"
@@ -232,7 +232,7 @@ pll-nanolcd-tangnano9k-synth.json: pll/GW1N-9C-dyn.vh pll-nanolcd/TOP.v pll-nano
232232
$(YOSYS) -D INV_BTN=0 -p "read_verilog $^; synth_gowin -json $@"
233233

234234
pll-nanolcd-tangnano9k.fs: pll-nanolcd-tangnano9k.json
235-
gowin_pack -d GW1N-9C --sspi_as_gpio --mspi_as_gpio -o $@ $^
235+
gowin_pack -d GW1NR-9C --sspi_as_gpio --mspi_as_gpio -o $@ $^
236236

237237
# ============================================================
238238
# szfpga (GW1N-9)
@@ -288,10 +288,10 @@ blinky-pll-runber-synth.json: pll/GW1N-4-dyn.vh blinky-pll.v
288288
gowin_unpack -d GW1NS-4 -o $@ $^
289289

290290
%-tangnano9k-unpacked.v: %-tangnano9k.fs
291-
gowin_unpack -d GW1N-9C -o $@ $^
291+
gowin_unpack -d GW1NR-9C -o $@ $^
292292

293293
%-tangnano20k-unpacked.v: %-tangnano20k.fs
294-
gowin_unpack -d GW2A-18C -o $@ $^
294+
gowin_unpack -d GW2AR-18C -o $@ $^
295295

296296
%-runber-unpacked.v: %-runber.fs
297297
gowin_unpack -d GW1N-4 -o $@ $^

0 commit comments

Comments
 (0)