URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 711 to Rev 712
- ↔ Reverse comparison
Rev 711 → Rev 712
/trunk/or1ksim/cpu/or32/execute.c
537,8 → 537,8
//printf ("|LOAD %i,%i,%i,%i,%i\n", delta, sbuf_count, sbuf_tail, sbuf_head, sbuf_buf[sbuf_tail], sbuf_buf[sbuf_head]); |
} |
|
/* Execution logger. */ |
inline void dump_exe_log() |
/* Outputs dissasembled instruction */ |
void dump_exe_log (const char *disasm) |
{ |
unsigned long i = iqueue[0].insn_addr; |
|
595,17 → 595,26
} |
|
fprintf (runtime.sim.fexe_log, "%.8lx ", i); |
if (index >= 0) { |
extern char *disassembled; |
disassemble_index (iqueue[0].insn, iqueue[0].insn_index); |
fprintf (runtime.sim.fexe_log, "%s\n", disassembled); |
} else |
fprintf (runtime.sim.fexe_log, "<invalid>\n"); |
fprintf (runtime.sim.fexe_log, "%s\n", disasm); |
} |
} |
} |
} |
|
static char exe_log_temp[100]; |
|
/* Execution logger. Dissasemble an instruction and calls executed log. */ |
inline void dump_exe_log_dis () |
{ |
if (index >= 0) { |
extern char *disassembled; |
disassemble_index (iqueue[0].insn, iqueue[0].insn_index); |
sprintf (exe_log_temp, "%s", disassembled); |
} else |
sprintf (exe_log_temp, "<invalid>"); |
dump_exe_log (exe_log_temp); |
} |
|
#if 0 |
void print_time (int cycles, char *output) |
{ |
645,12 → 654,12
printf("flag: %u\n", flag); |
} |
|
static inline void decode_execute (struct iqueue_entry *current, int *breakpoint); |
static inline void decode_execute (struct iqueue_entry *current); |
|
/* Wrapper around real decode_execute function -- some statistics here only */ |
static inline void decode_execute_wrapper (struct iqueue_entry *current) |
{ |
int breakpoint = 0; |
breakpoint = 0; |
next_delay_insn = 0; |
|
#ifndef HAS_EXECUTION |
663,7 → 672,7
breakpoint++; |
|
cur = current; /* globals; needed by eval/set_operand */ |
decode_execute (current, &breakpoint); |
decode_execute (current); |
|
/* Check for range exception */ |
if (testsprbits (SPR_SR, SPR_SR_OVE) && testsprbits (SPR_SR, SPR_SR_OV)) |
773,7 → 782,7
decode_execute_wrapper (&iqueue[0]); |
update_pc(); |
analysis(); |
if (config.sim.exe_log) dump_exe_log(); |
if (config.sim.exe_log) dump_exe_log_dis(); |
return 0; |
} |
|
789,7 → 798,7
|
#if SIMPLE_EXECUTION |
/* Address calculation changed by CZ on 27/05/01 */ |
static inline void decode_execute (struct iqueue_entry *current, int *breakpoint) |
static inline void decode_execute (struct iqueue_entry *current) |
{ |
int insn_index; |
|
799,7 → 808,7
l_invalid(); |
else { |
op = &cur->op[0]; |
eval_operands (cur->insn, insn_index, breakpoint); |
eval_operands (cur->insn, insn_index, &breakpoint); |
or32_opcodes[insn_index].exec(); |
} |
} |
/trunk/or1ksim/cpu/or32/insnset.c
202,7 → 202,6
bpb_update(cur->insn_addr, flag); |
} |
if (flag) { |
debug(5, "\nl.bf relative: pc=%x pcnext=%x\n", pc, pcnext); |
pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4; |
btic_update(pcnext); |
next_delay_insn = 1; |
218,7 → 217,6
bpb_update(cur->insn_addr, flag == 0); |
} |
if (flag == 0) { |
debug(5, "\nl.bnf relative: pc=%x pcnext=%x\n", pc, pcnext); |
pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4; |
btic_update(pcnext); |
next_delay_insn = 1; |
227,13 → 225,11
} |
} |
INSTRUCTION (l_j) { |
debug(5, "\nl.j relative: pc=%x pcnext=%x\n", pc, pcnext); |
pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4; |
IFF (config.cpu.dependstats) cur->func_unit = it_jump; |
next_delay_insn = 1; |
} |
INSTRUCTION (l_jal) { |
debug(5, "\nl.jal relative: pc=%x pcnext=%x\n", pc, pcnext); |
pcdelay = pc + (signed)eval_operand32(0, &breakpoint) * 4; |
|
IFF (config.cpu.dependstats) cur->func_unit = it_jump; |
475,7 → 471,7
} |
INSTRUCTION (l_cmov) { |
IFF (config.cpu.dependstats) cur->func_unit = it_move; |
set_operand32 (0, flag ? eval_operand32(1, &breakpoint) : eval_operand32(2, &breakpoint), &breakpoint); |
set_operand32(0, flag ? eval_operand32(1, &breakpoint) : eval_operand32(2, &breakpoint), &breakpoint); |
} |
INSTRUCTION (l_cust1) { |
/*int destr = cur->insn >> 21; |
/trunk/or1ksim/cpu/or32/generate.c
41,6 → 41,8
} *ti; |
|
static char *in_file; |
unsigned long op[MAX_OPERANDS]; |
int num_op; |
|
inline void debug(int level, const char *format, ...) |
{ |
59,6 → 61,54
#endif |
} |
|
static int olevel; |
|
char *replace_operands (FILE *fo, char *str) { |
int replace = 0; |
if (*str == '}') {olevel--;} |
else if (*str == '{') {olevel++;} |
else if (strncmp ("eval_operand", str, 12) == 0) { |
replace = 1; str += 12; |
} else if (strncmp ("set_operand", str, 11) == 0) { |
replace = 2; str += 11; |
} |
if (replace) { |
int width, oper; |
sscanf (str, "%i(%i", &width, &oper); |
while (*str && *str != '(') str++; |
while (*str && *str != ',') str++; |
str++; |
if (replace == 1) { |
if (op[oper] & OPTYPE_DIS) { |
fprintf (fo, "eval_mem%i (%c", width, 'a' + oper); |
} else { |
if (op[oper] & OPTYPE_REG) { |
fprintf (fo, "eval_reg%i (%c", width, 'a' + oper); |
} else { |
fprintf (fo, "(%c", 'a' + oper); |
} |
} |
} else { |
op[oper] |= OPTYPE_DST; |
if (op[oper] & OPTYPE_DIS) { |
fprintf (fo, "set_mem%i(%c,", width, 'a' + oper); |
} else if (op[oper] & OPTYPE_REG) { |
fprintf (fo, "set_reg%i(%c,",width, 'a' + oper); |
} else { |
fprintf (stderr, "Invalid operand type.\n"); |
exit (1); |
} |
while (*str != ',') str = replace_operands (fo, str) + 1; |
} |
while (*str && *str != ')') str++; |
if (op[oper] & OPTYPE_DIS) fprintf (fo, ", &breakpoint)"); |
else fprintf (fo, ")"); |
} else { |
fputc (*str, fo); |
} |
return str; |
} |
|
int output_function (FILE *fo, const char *func_name, int level) |
{ |
FILE *fi; |
77,8 → 127,7
while (isspace(*(s - 1))) s--; |
*s = 0; |
if (strcmp (str, func_name) == 0) { |
char c; |
int olevel = 1; |
olevel = 1; |
str += strlen (str) + 1; |
while (isspace (*str)) str++; |
s = str; |
90,11 → 139,12
fprintf (fo, " /* \"%s\" */\n", func_name); |
SHIFT; |
do { |
c = fgetc (fi); |
if (c == '}') {olevel--;} |
else if (c == '{') {olevel++;} |
fputc (c, fo); |
if (c == '\n') SHIFT; |
fgets (line, sizeof (line), fi); |
line[sizeof(line) - 1] = 0; |
for (str = line; *str; str++) { |
str = replace_operands (fo, str); |
} |
SHIFT; |
} while (olevel); |
return 0; |
} |
118,7 → 168,7
int dis = 0; |
int no = 0; |
int firstd = 1; |
|
|
while (1) |
{ |
int nbits = 0, first = 1; |
146,11 → 196,12
} else |
{ |
if (dis && (opd->type & OPTYPE_REG)) { |
SHIFT; fprintf (fo, "op[%i] = data + eval_reg32 (tmp);\n", no); |
SHIFT; fprintf (fo, "op[%i] = %c = data + eval_reg32 (tmp);\n", no, 'a' + no); |
} else { |
SHIFT; fprintf (fo, "op[%i] = tmp;\n", no); |
SHIFT; fprintf (fo, "op[%i] = %c = tmp;\n", no, 'a' + no); |
} |
SHIFT; fprintf (fo, "op[%i + MAX_OPERANDS] = 0x%08x;\n", no, opd->type | (dis ? OPTYPE_DIS : 0)); |
op[no] = opd->type | (dis ? OPTYPE_DIS : 0); |
no++; |
firstd = 1; |
dis = 0; |
157,6 → 208,7
} |
if(opd->type & OPTYPE_LAST) { |
SHIFT; fprintf (fo, "num_op = %i;\n", no); |
num_op = no; |
return; |
} |
opd++; |
166,21 → 218,28
|
int output_call (FILE *fo, int index, int level) |
{ |
int i; |
printf ("%i:%s\n", index, insn_name (index)); |
fprintf (fo, "{\n"); |
level++; |
if (index >= 0) { |
SHIFT; fprintf (fo, "unsigned long data = 0, tmp = 0, nbits = 0;\n"); |
SHIFT; fprintf (fo, "unsigned long data, tmp;\n"); |
SHIFT; fprintf (fo, "unsigned long a, b, c; /* operands */\n"); |
} |
SHIFT; fprintf (fo, "insn_index = %i; /* \"%s\" */\n", index, insn_name (index)); |
if (index >= 0) { |
SHIFT; fprintf (fo, "op = &cur->op[0];\n"); |
//SHIFT; fprintf (fo, "eval_operands (insn, insn_index, &breakpoint);\n"); |
SHIFT; fprintf (fo, "insn_index = %i; /* \"%s\" */\n", index, insn_name (index)); |
gen_eval_operands (fo, index, level); |
} else { |
SHIFT; fprintf (fo, "/* insn_index = -1 by default */\n"); |
} |
SHIFT; |
if (index < 0) output_function (fo, "l_invalid", level); |
else output_function (fo, or32_opcodes[index].function_name, level); |
fprintf (fo, "\n"); |
printf ("\n"); |
for (i = 0; i < num_op; i++) |
if (op[i] & OPTYPE_DST) { |
SHIFT; fprintf (fo, "IFF (config.cpu.dependstats) op[%i + MAX_OPERANDS] |= OPTYPE_DST;\n", i); |
} |
level--; |
SHIFT; fprintf (fo, "}"); |
return 0; |
189,9 → 248,10
static int generate_header (FILE *fo) |
{ |
fprintf (fo, "/* This file was automatically generated by generate (see cpu/or32/generate.c) */\n\n"); |
fprintf (fo, "static inline void decode_execute (struct iqueue_entry *current, int *breapoint)\n{\n"); |
fprintf (fo, "static inline void decode_execute (struct iqueue_entry *current)\n{\n"); |
fprintf (fo, " unsigned long insn = current->insn;\n"); |
fprintf (fo, " int insn_index = -1;\n"); |
fprintf (fo, " op = &cur->op[0];\n"); |
return 0; |
} |
|
239,7 → 299,6
fprintf (fo, " break;\n"); |
} |
level--; |
SHIFT; |
if (level > 1) |
fprintf (fo, "} break;\n"); |
else |