def assemble_I(PC, A, B):
    I = empty["I"]
    I.file_name = bench_name

    # Thread 0 has implicit first NOP from pipeline, so starts at 1
    # All threads start at 1, to avoid triggering branching unit at 0.
    I.A(1)

    # Instructions to fill branch table
    base_addr = mem_map["BO"]["Origin"]
    I.P("BTM0", None, write_addr = base_addr)
    I.P("BTM1", None, write_addr = base_addr + 1)
    I.P("BTM2", None, write_addr = base_addr + 2)
    I.P("BTM3", None, write_addr = base_addr + 3)

    # Instruction to set indirect access
    base_addr = mem_map["BPO"]["Origin"] 
    I.P("AOM0", None, write_addr = base_addr)
    I.P("AOM1", None, write_addr = base_addr + 1)

# Optimized, Accumulator only, software sliding window
    # set branch entries
    I.I(ADD, "BTM0", "jmp0", 0)
    I.I(ADD, "BTM1", "jmp1", 0)
    I.I(ADD, "BTM2", "jmp2", 0)
    I.I(ADD, "BTM3", "jmp3", 0)

    # Instruction to set indirect access
    I.I(ADD, "AOM0", 0, "pointer_init"),                I.N("init")
    I.I(ADD, "pointer_temp", 0, "pointer_init")
    I.I(ADD, "array_cnt", 0, "array_len")

    # Do convolution
    I.I(MLS, "Acc", "coefficient7", "array_pointers"),  I.N("loop")
    I.I(MLS, "Acc", "coefficient6", "array_pointers")
    I.I(MLS, "Acc", "coefficient5", "array_pointers")
    I.I(MLS, "Acc", "coefficient4", "array_pointers")
    I.I(MLS, "Acc", "coefficient3", "array_pointers")
    I.I(MLS, "Acc", "coefficient2", "array_pointers")
    I.I(MLS, "Acc", "coefficient1", "array_pointers")
    I.I(MLS, "Acc", "coefficient0", "array_pointers")

    # Reset pointer, +1 to slide window
    I.I(ADD, "pointer_temp", "one", "pointer_temp")
    I.I(ADD, "AOM0", 0, "pointer_temp")
    I.I(ADD, "array_cnt", "minus_one", "array_cnt")

    # Read out Accumulator
    I.I(ADD, "array_pointers", "Acc", 0),               I.JNZ("loop", None, "jmp0")

    # and we're done
    I.NOP(), I.N("end"), I.JMP("end", "jmp3")

    I.resolve_forward_jumps()

    # Set programmed offsets
    read_PO  = (mem_map["B"]["PO_INC_base"] + B.R("input_array_top") - mem_map["B"]["Depth"]) & 0x3FF
    write_PO = (mem_map["H"]["Origin"] + mem_map["H"]["Depth"] - mem_map["H"]["PO_INC_base"] + A.W("output_array_top")) & 0xFFF
    PO = (1 << 34) | (1 << 32) | (write_PO << 20) | read_PO
    B.A(B.R("pointer_init"))
    B.L(PO)

    return I

# Leave these all zero for now: only zero-based thread will do something, all
# others will hang at 0 due to empty branch tables.
dataset/ETHPy150Open laforest/Octavo/Assembler/fir_filter_acc.py/assemble_I/swapped operands of `-`