1 /* Copyright 2016-2021 Free Software Foundation, Inc.
2 Contributed by Dimitar Dimitrov <dimitar@dinux.eu>
4 This file is part of the PRU simulator.
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
20 PRU Instruction Set Architecture
27 OP2 = (IO ? IMM8 : RS2);
29 CARRY = (((uint64_t) RS1 + (uint64_t) OP2) >> RD_WIDTH) & 1;
33 OP2 = (IO ? IMM8 : RS2);
34 RD = RS1 + OP2 + CARRY;
35 CARRY = (((uint64_t) RS1 + (uint64_t) OP2 + (uint64_t) CARRY)
40 OP2 = (IO ? IMM8 : RS2);
42 CARRY = (((uint64_t) RS1 - (uint64_t) OP2) >> RD_WIDTH) & 1;
46 OP2 = (IO ? IMM8 : RS2);
47 RD = RS1 - OP2 - CARRY;
48 CARRY = (((uint64_t) RS1 - (uint64_t) OP2 - (uint64_t) CARRY)
53 OP2 = (IO ? IMM8 : RS2);
55 CARRY = (((uint64_t) OP2 - (uint64_t) RS1) >> RD_WIDTH) & 1;
59 OP2 = (IO ? IMM8 : RS2);
60 RD = OP2 - RS1 - CARRY;
61 CARRY = (((uint64_t) OP2 - (uint64_t) RS1 - (uint64_t) CARRY)
66 OP2 = (IO ? IMM8 : RS2);
67 RD = RS1 << (OP2 & 0x1f);
71 OP2 = (IO ? IMM8 : RS2);
72 RD = RS1 >> (OP2 & 0x1f);
76 OP2 = (IO ? IMM8 : RS2);
81 OP2 = (IO ? IMM8 : RS2);
86 OP2 = (IO ? IMM8 : RS2);
95 OP2 = (IO ? IMM8 : RS2);
96 RD = RS1 < OP2 ? RS1 : OP2;
100 OP2 = (IO ? IMM8 : RS2);
101 RD = RS1 > OP2 ? RS1 : OP2;
105 OP2 = (IO ? IMM8 : RS2);
106 RD = RS1 & ~(1u << (OP2 & 0x1f));
110 OP2 = (IO ? IMM8 : RS2);
111 RD = RS1 | (1u << (OP2 & 0x1f));
115 OP2 = (IO ? IMM16 : RS2);
119 OP2 = (IO ? IMM16 : RS2);
128 pru_sim_syscall (sd, cpu);
142 OP2 = (IO ? IMM8 : RS2);
143 PC = (OP2 > RS1) ? (PC + BROFF) : (PC + 1))
146 OP2 = (IO ? IMM8 : RS2);
147 PC = (OP2 >= RS1) ? (PC + BROFF) : (PC + 1))
150 OP2 = (IO ? IMM8 : RS2);
151 PC = (OP2 < RS1) ? (PC + BROFF) : (PC + 1))
154 OP2 = (IO ? IMM8 : RS2);
155 PC = (OP2 <= RS1) ? (PC + BROFF) : (PC + 1))
158 OP2 = (IO ? IMM8 : RS2);
159 PC = (OP2 == RS1) ? (PC + BROFF) : (PC + 1))
162 OP2 = (IO ? IMM8 : RS2);
163 PC = (OP2 != RS1) ? (PC + BROFF) : (PC + 1))
166 OP2 = (IO ? IMM8 : RS2);
170 OP2 = (IO ? IMM8 : RS2);
171 PC = (RS1 & (1u << (OP2 & 0x1f))) ? (PC + BROFF) : (PC + 1))
174 OP2 = (IO ? IMM8 : RS2);
175 PC = !(RS1 & (1u << (OP2 & 0x1f))) ? (PC + BROFF) : (PC + 1))
178 pru_dmem2reg (cpu, XBBO_BASEREG + (IO ? IMM8 : RS2),
179 BURSTLEN, RD_REGN, RDB);
183 pru_reg2dmem (cpu, XBBO_BASEREG + (IO ? IMM8 : RS2),
184 BURSTLEN, RD_REGN, RDB);
188 pru_dmem2reg (cpu, CTABLE[CB] + (IO ? IMM8 : RS2),
189 BURSTLEN, RD_REGN, RDB);
193 pru_reg2dmem (cpu, CTABLE[CB] + (IO ? IMM8 : RS2),
194 BURSTLEN, RD_REGN, RDB);
198 DO_XIN (XFR_WBA, RD_REGN, RDB, XFR_LENGTH);
202 DO_XOUT (XFR_WBA, RD_REGN, RDB, XFR_LENGTH);
206 DO_XCHG (XFR_WBA, RD_REGN, RDB, XFR_LENGTH);
210 sim_io_eprintf (sd, "SXIN instruction not supported by sim\n");
214 sim_io_eprintf (sd, "SXOUT instruction not supported by sim\n");
218 sim_io_eprintf (sd, "SXCHG instruction not supported by sim\n");
222 OP2 = (IO ? IMM8 + 1 : RS2_w0);
230 LOOPEND = PC + LOOP_JMPOFFS;
232 LOOP_IN_PROGRESS = 1;
237 OP2 = (IO ? IMM8 + 1 : RS2_w0);
245 LOOPEND = PC + LOOP_JMPOFFS;
247 LOOP_IN_PROGRESS = 1;
255 OP2 = (IO ? IMM8 : RS2);
257 for (lmbd_i = RS1_WIDTH - 1; lmbd_i >= 0; lmbd_i--)
259 if (!(((RS1 >> lmbd_i) ^ OP2) & 1))
262 RD = (lmbd_i < 0) ? 32 : lmbd_i;