+
+ if (have_out1) begin
+ `onwrite(out1_r, out1_d) have_out1 = 0; end
+ end
+ if (have_out2) begin
+ `onwrite(out2_r, out2_d) have_out2 = 0; end
+ end
+
+ if (have_in && !have_out1 && !have_out2) begin
+ case (reg_in[`PACKET_WIDTH-1:`DATAWIDTH])
+ 00: /* in.swapIfZero */ fire = reg_in[`DATAWIDTH-1:0] == 0;
+ 06: /* in.muxIfZero */ fire = reg_in[`DATAWIDTH-1:0] == 0;
+ 12: /* in.deMuxIfZero */ fire = reg_in[`DATAWIDTH-1:0] == 0;
+ 01: /* in.swapIfNonZero */ fire = reg_in[`DATAWIDTH-1:0] != 0;
+ 07: /* in.muxIfNonZero */ fire = reg_in[`DATAWIDTH-1:0] != 0;
+ 13: /* in.deMuxIfNonZero */ fire = reg_in[`DATAWIDTH-1:0] != 0;
+ 02: /* in.swapIfNegative */ fire = reg_in[`DATAWIDTH-1:0] < 0;
+ 08: /* in.muxIfNegative */ fire = reg_in[`DATAWIDTH-1:0] < 0;
+ 14: /* in.deMuxIfNegative */ fire = reg_in[`DATAWIDTH-1:0] < 0;
+ 03: /* in.swapIfPositive */ fire = reg_in[`DATAWIDTH-1:0] > 0;
+ 09: /* in.muxIfPositive */ fire = reg_in[`DATAWIDTH-1:0] > 0;
+ 15: /* in.deMuxIfPositive */ fire = reg_in[`DATAWIDTH-1:0] > 0;
+ 04: /* in.swapIfNonNegative */ fire = reg_in[`DATAWIDTH-1:0] >= 0;
+ 16: /* in.deMuxIfNonNegative */ fire = reg_in[`DATAWIDTH-1:0] >= 0;
+ 10: /* in.muxIfNonNegative */ fire = reg_in[`DATAWIDTH-1:0] >= 0;
+ 05: /* in.swapIfNonPositive */ fire = reg_in[`DATAWIDTH-1:0] <= 0;
+ 11: /* in.muxIfNonPositive */ fire = reg_in[`DATAWIDTH-1:0] <= 0;
+ 17: /* in.deMuxIfNonPositive */ fire = reg_in[`DATAWIDTH-1:0] <= 0;
+ endcase
+
+ if (reg_in[`PACKET_WIDTH-1:`DATAWIDTH] <= 5) begin
+ if (have_in1 && have_in2) begin
+ have_out1 = 1;
+ have_out2 = 1;
+ have_in1 = 0;
+ have_in2 = 0;
+ out1_d = fire ? reg_in2 : reg_in1;
+ out2_d = fire ? reg_in1 : reg_in2;
+ end
+ end else if (reg_in[`PACKET_WIDTH-1:`DATAWIDTH] <= 11) begin
+ if (fire && have_in2) begin
+ have_out1 = 1;
+ have_in2 = 0;
+ out1_d = in2_d;
+ end else if (!fire && have_in1) begin
+ have_out1 = 1;
+ have_in1 = 0;
+ out1_d = in1_d;
+ end
+ end else begin
+ if (have_in1) begin
+ if (fire) begin
+ have_out2 = 1;
+ out2_d = in1_d;
+ have_in1 = 0;
+ end else begin
+ have_out1 = 1;
+ out1_d = in1_d;
+ have_in1 = 0;
+ end
+ end