From fbdc8af4d4034c95e61f88a7a01b5551b6d67192 Mon Sep 17 00:00:00 2001 From: Kento HASEGAWA Date: Fri, 10 Aug 2018 19:16:55 +0900 Subject: [PATCH] Add support for a puzzle with the larger number of lines by dynamically configuring the suitable bitstream for the puzzle --- solver/adc2018solver.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/solver/adc2018solver.py b/solver/adc2018solver.py index faabcaa..b93f461 100644 --- a/solver/adc2018solver.py +++ b/solver/adc2018solver.py @@ -19,7 +19,6 @@ import BoardStr # Settings -- pynqrouter -IP = 'SEG_pynqrouter_0_Reg' OFFSET_BOARD = 65536 # 0x10000 ~ 0x1ffff OFFSET_SEED = 131072 # 0x20000 OFFSET_STATUS = 131080 # 0x20008 @@ -30,6 +29,11 @@ BITWIDTH_Z = 3 # Settings -- LED IP_LED = 'SEG_axi_gpio_0_Reg' +BS_IP = [ + ('pynqrouter_lines128_length256.bit', 'SEG_pynqrouter_0_Reg'), + ('pynqrouter_lines256_length128.bit', 'SEG_pynqrouter_256x128_0_Reg') +] + solver_thread = None class StoppableThread(threading.Thread): @@ -74,13 +78,26 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()): print(seed) print('') + # LINE数を数えてコンフィグするbitstreamを分岐 + line_num = boardstr.count('L') + if line_num < 127: + BITSTREAM = BS_IP[0][0] + IP = BS_IP[0][1] + elif line_num < 255: + BITSTREAM = BS_IP[1][0] + IP = BS_IP[1][1] + else: + solver_thread.stopped() + solver_thread = None + return {'solved': False, 'solution': '', 'elapsed': -1.0} + # ボード文字列から X, Y, Z を読んでくる size_x = (ord(boardstr[1]) - ord('0')) * 10 + (ord(boardstr[2]) - ord('0')) size_y = (ord(boardstr[4]) - ord('0')) * 10 + (ord(boardstr[5]) - ord('0')) size_z = (ord(boardstr[7]) - ord('0')) # Overlay 読み込み - OL = Overlay('pynqrouter_lines128_length256.bit') + OL = Overlay(BITSTREAM) OL.download() print(OL.ip_dict) print('Overlay loaded!') -- 2.22.0