1 /* Copyright 2009-2024 Free Software Foundation, Inc.
3 This file is part of the Xilinx MicroBlaze simulator.
5 This library is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
19 * MICROBLAZE Instruction Set Architecture
31 CARRY = C_calc(RA, RB, 0);
39 CARRY = C_calc(RB, ~RA, 1);
47 CARRY = C_calc(RA, RB, C_rd);
55 CARRY = C_calc(RB, ~RA, C_rd);
76 int tmp_reg = RB + ~RA + 1;
77 if ((RB & 0x80000000) ^ (RA & 0x80000000)) {
78 tmp_reg = ((tmp_reg & 0x7fffffff) | (RB & 0x80000000));
88 int tmp_reg = RB + ~RA + 1;
89 if ((RB & 0x80000000) ^ (RA & 0x80000000)) {
90 tmp_reg = ((tmp_reg & 0x7fffffff) | (RA & 0x80000000));
105 RD = RB + ~RA + C_rd;
111 CARRY = C_calc(RA, IMM, 0);
113 TRACE_REGISTER (cpu, "r%i = r%i + %i", rd, ra, IMM);
120 CARRY = C_calc(IMM, ~RA, 1);
128 CARRY = C_calc(RA, IMM, C_rd);
129 RD = RA + IMM + C_rd;
136 CARRY = C_calc(IMM, ~RA, C_rd);
137 RD = IMM + ~RA + C_rd;
156 RD = RA + IMM + C_rd;
162 RD = IMM + ~RA + C_rd;
174 RD = (unsigned_4)RA >> RB;
180 RD = (signed_4)RA >> RB;
186 RD = (unsigned_4)RA << RB;
192 RD = (signed_4) RB / (signed_4) RA;
198 RD = (unsigned_4) RB / (unsigned_4) RA;
209 INST_TYPE_RD_RA_IMM5,
210 RD = (unsigned_4)RA >> (IMM & 0x1F);
215 INST_TYPE_RD_RA_IMM5,
216 RD = (signed_4)RA >> (IMM & 0x1F);
221 INST_TYPE_RD_RA_IMM5,
222 RD = (unsigned_4)RA << (IMM & 0x1F);
265 INSTRUCTION(microblaze_or,
271 INSTRUCTION(microblaze_and,
277 INSTRUCTION(microblaze_xor,
293 RD = (int) (RA >> 1);
301 RD = ((((int) (RA >> 1)) & 0x7FFFFFFF) | (unsigned_4)(C_rd << 31));
309 RD = (unsigned_4) ((RA >> 1) & 0x7FFFFFFF);
316 RD = MICROBLAZE_SEXT8(RA);
322 RD = MICROBLAZE_SEXT16(RA);
389 INSTRUCTION(microblaze_brk,
394 MSR = MSR | BIP_MASK;
564 MSR = MSR | INTR_EN_MASK;
572 MSR = MSR & ~BIP_MASK;
623 MSR = MSR | BIP_MASK;
755 RD = (MEM_RD_UBYTE(RA + RB));
761 RD = (MEM_RD_UHALF((RA + RB) & ~0x1));
767 RD = (MEM_RD_WORD((RA + RB) & ~0x3));
773 MEM_WR_BYTE(RA + RB, RD);
779 MEM_WR_HALF((RA + RB) & ~0x1, RD);
785 MEM_WR_WORD((RA + RB) & ~0x3, RD);
791 RD = (MEM_RD_UBYTE(RA + IMM));
797 RD = (MEM_RD_UHALF((RA+IMM) & ~0x1));
803 RD = (MEM_RD_WORD((RA+IMM) & ~0x3));
809 MEM_WR_BYTE(RA + IMM, RD);
815 MEM_WR_HALF((RA + IMM) & ~0x1, RD);
821 MEM_WR_WORD((RA + IMM) & ~0x3, RD);