+ begin
+ next_cpsr_3a = cpsr_2a;
+ next_spsr_3a = spsr_2a;
+ next_cpsrup_3a = 0;
+ next_write_reg_3a = 0;
+ next_write_num_3a = 4'hx;
+ next_write_data_3a = 32'hxxxxxxxx;
+
+ casez(insn_2a)
+ `DECODE_ALU_MULT: /* Multiply -- must come before ALU, because it pattern matches a specific case of ALU */
+ begin
+ next_cpsr_3a = insn_2a[20] /* S */ ? {mult_result[31] /* N */, mult_result == 0 /* Z */, 1'b0 /* C */, cpsr_2a[28] /* V */, cpsr_2a[27:0]} : cpsr_2a;
+ next_cpsrup_3a = insn_2a[20] /* S */;
+ next_write_reg_3a = 1;
+ next_write_num_3a = insn_2a[19:16] /* Rd -- why the fuck isn't this the same place as ALU */;
+ next_write_data_3a = mult_result;
+ end
+ `DECODE_ALU_MRS: /* MRS (Transfer PSR to register) */
+ begin
+ next_write_reg_3a = 1;
+ next_write_num_3a = insn_2a[15:12];
+ if (insn_2a[22] /* Ps */)
+ next_write_data_3a = spsr_2a;
+ else
+ next_write_data_3a = cpsr_2a;
+ end
+ `DECODE_ALU_MSR, /* MSR (Transfer register to PSR) */
+ `DECODE_ALU_MSR_FLAGS: /* MSR (Transfer register or immediate to PSR, flag bits only) */
+ begin
+ if ((cpsr_2a[4:0] == `MODE_USR) || (insn_2a[16] /* that random bit */ == 1'b0)) /* flags only */
+ begin
+ if (insn_2a[22] /* Ps */)
+ next_spsr_3a = {op0_2a[31:29], spsr_2a[28:0]};
+ else
+ next_cpsr_3a = {op0_2a[31:29], cpsr_2a[28:0]};
+ end else begin
+ if (insn_2a[22] /* Ps */)
+ next_spsr_3a = op0_2a;
+ else
+ next_cpsr_3a = op0_2a;
+ end
+ next_cpsrup_3a = 1;
+ end
+ `DECODE_ALU_SWP, /* Atomic swap */
+ `DECODE_ALU_BX, /* Branch */
+ `DECODE_ALU_HDATA_REG, /* Halfword transfer - register offset */
+ `DECODE_ALU_HDATA_IMM: /* Halfword transfer - immediate offset */
+ begin end
+ `DECODE_ALU: /* ALU */
+ begin
+ if (alu_setres_2a) begin
+ next_write_reg_3a = 1;
+ next_write_num_3a = insn_2a[15:12] /* Rd */;
+ next_write_data_3a = alu_result_2a;
+ end
+
+ if (insn_2a[20] /* S */) begin
+ next_cpsrup_3a = 1;
+ next_cpsr_3a = ((insn_2a[15:12] == 4'b1111) && insn_2a[20]) ? spsr_2a : alu_outcpsr_2a;
+ end
+ end
+ `DECODE_LDRSTR_UNDEFINED, /* Undefined. I hate ARM */
+ `DECODE_LDRSTR, /* Single data transfer */
+ `DECODE_LDMSTM: /* Block data transfer */
+ begin end
+ `DECODE_BRANCH: /* Branch */
+ begin
+ if(insn_2a[24] /* L */) begin
+ next_write_reg_3a = 1;
+ next_write_num_3a = 4'hE; /* link register */
+ next_write_data_3a = pc_2a + 32'h4;
+ end
+ end
+ endcase
+ end
+
+ /* Multiplier inputs */
+ always @(*)
+ begin
+ mult_start = 0;
+ mult_acc0 = 32'hxxxxxxxx;
+ mult_in0 = 32'hxxxxxxxx;
+ mult_in1 = 32'hxxxxxxxx;
+
+ casez(insn_2a)
+ `DECODE_ALU_MULT:
+ begin
+ if (!outstall_3a /* i.e., this is a new one */ && !bubble_2a /* i.e., this is a real one */)
+ begin
+ mult_start = 1;
+ mult_acc0 = insn_2a[21] /* A */ ? op0_2a /* Rn */ : 32'h0;
+ mult_in0 = op1_2a /* Rm */;
+ mult_in1 = op2_2a /* Rs */;
+ $display("New MUL instruction");
+ end
+ end
+ endcase
+ end
+
+ /* Miscellaneous cleanup. */
+ always @(*)
+ begin
+ next_bubble_3a = bubble_2a | flush_2a | delayedflush_2a;
+
+ jmp_2a = 1'b0;
+ jmppc_2a = 32'h00000000;
+
+ casez (insn_2a)
+ `DECODE_ALU_MULT: /* Multiply -- must come before ALU, because it pattern matches a specific case of ALU */
+ next_bubble_3a = next_bubble_3a | !mult_done | !outstall_3a;