Commit fbdc8af4 authored by Kento HASEGAWA's avatar Kento HASEGAWA
Browse files

Add support for a puzzle with the larger number of lines by dynamically...

Add support for a puzzle with the larger number of lines by dynamically configuring the suitable bitstream for the puzzle
parent 12e539c5
Loading
Loading
Loading
Loading
+19 −2
Changes for solver/adc2018solver.py: 19 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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!')