95 const int A[8] = { 22, 5, -9, 3, -17, 38, 0, 11 };
96 const int outData[8] = { -17, -9, 0, 3, 5, 11, 22, 38 };
98 #define IADDR(x) (((x)&0x000000ff)>>2) 99 #define DADDR(x) (((x)&0x000000ff)>>2) 101 #pragma map generate_hw 104 mips_call(
int reg[32],
unsigned long m_imem[44],
int n_inst[1],
int dmem[64])
126 ins = m_imem[
IADDR (pc)];
135 shamt = (ins >> 6) & 0x1f;
136 rd = (ins >> 11) & 0x1f;
137 rt = (ins >> 16) & 0x1f;
138 rs = (ins >> 21) & 0x1f;
144 reg[rd] = reg[rs] + reg[rt];
147 reg[rd] = reg[rs] - reg[rt];
151 hilo = (
long long) reg[rs] * (
long long) reg[rt];
152 Lo = hilo & 0x00000000ffffffffULL;
153 Hi = ((int) (hilo >> 32)) & 0xffffffffUL;
157 (
unsigned long long) ((
unsigned int) (reg[rs])) *
158 (
unsigned long long) ((
unsigned int) (reg[rt]));
159 Lo = hilo & 0x00000000ffffffffULL;
160 Hi = ((int) (hilo >> 32)) & 0xffffffffUL;
171 reg[rd] = reg[rs] & reg[rt];
174 reg[rd] = reg[rs] | reg[rt];
177 reg[rd] = reg[rs] ^ reg[rt];
180 reg[rd] = reg[rt] << shamt;
183 reg[rd] = reg[rt] >> shamt;
186 reg[rd] = reg[rt] << reg[rs];
189 reg[rd] = reg[rt] >> reg[rs];
193 reg[rd] = reg[rs] < reg[rt];
196 reg[rd] = (
unsigned int) reg[rs] < (
unsigned int) reg[rt];
209 tgtadr = ins & 0x3ffffff;
213 tgtadr = ins & 0x3ffffff;
220 address = ins & 0xffff;
221 rt = (ins >> 16) & 0x1f;
222 rs = (ins >> 21) & 0x1f;
226 reg[rt] = reg[rs] + address;
230 reg[rt] = reg[rs] & (
unsigned short) address;
233 reg[rt] = reg[rs] | (
unsigned short) address;
236 reg[rt] = reg[rs] ^ (
unsigned short) address;
240 reg[rt] = dmem[
DADDR (reg[rs] + address)];
243 dmem[
DADDR (reg[rs] + address)] = reg[rt];
247 reg[rt] = address << 16;
251 if (reg[rs] == reg[rt])
252 pc = pc - 4 + (address << 2);
255 if (reg[rs] != reg[rt])
256 pc = pc - 4 + (address << 2);
260 pc = pc - 4 + (address << 2);
264 reg[rt] = reg[rs] < address;
268 reg[rt] = (
unsigned int) reg[rs] < (
unsigned short) address;
278 *n_inst = *n_inst + 1;
305 int *m_A, *m_outData;
306 unsigned long *m_imem;
310 m_A = (
int *)malloc(8 *
sizeof(
int));
311 m_outData = (
int *)malloc(8 *
sizeof(
int));
312 m_imem = (
unsigned long *)malloc(44 *
sizeof(
unsigned long));
314 for( i = 0; i < 8; i++)
319 for( i = 0; i < 44; i++)
329 for (i = 0; i < 32; i++)
333 reg[29] = 0x7fffeffc;
335 for (i = 0; i < 8; i++)
342 mips_call(reg, m_imem, &n_inst, dmem);
344 main_result += (n_inst != 611);
345 for (j = 0; j < 8; j++)
347 main_result += (dmem[j] != m_outData[j]);
350 printf (
"%d\n", main_result);
385 for (i = 0; i < 32; i++)
389 reg[29] = 0x7fffeffc;
391 for (i = 0; i < 8; i++)
398 mips_call(reg,
imem, &n_inst, dmem);
401 for (j = 0; j < 8; j++)
void __builtin_bambu_time_start()
void __attribute__((noinline))
const unsigned long imem[44]
void __builtin_bambu_time_stop()