# set up instruction, pick fn unit
         comb += e.nia.eq(0)    # XXX TODO (or remove? not sure yet)
         fu = op.function_unit
-        itype = Mux(fu == Function.NONE, InternalOp.OP_ILLEGAL, op.internal_op)
-        comb += do.insn_type.eq(itype)
+        with m.If((fu == Function.NONE) |
+                   (op.internal_op == InternalOp.OP_ATTN)):
+            comb += do.insn_type.eq(op.internal_op)
+        with m.Else():
+            comb += do.insn_type.eq(InternalOp.OP_ILLEGAL)
         comb += do.fn_unit.eq(fu)
 
         # registers a, b, c and out and out2 (LD/ST EA)
 
 def wait_for_busy_clear(cu):
     while True:
         busy_o = yield cu.busy_o
-        if not busy_o:
+        terminated_o = yield cu.core_terminated_o
+        if not busy_o or terminated_o:
+            print("busy/terminated:", busy_o, terminated_o)
             break
         print("busy",)
         yield
 
                     yield from wait_for_busy_hi(core)
                     yield from wait_for_busy_clear(core)
 
+                    terminated = yield core.core_terminated_o
+                    print ("terminated", terminated)
+
                     print ("sim", code)
                     # call simulated operation
                     opname = code.split(' ')[0]