URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 268 to Rev 269
- ↔ Reverse comparison
Rev 268 → Rev 269
/trunk/or1ksim/sim-config.h
77,6 → 77,7
int pattern; /* A user specified memory initialization pattern */ |
int random_seed; /* Initialize the memory with random values, starting with seed */ |
enum { |
MT_UNKNOWN, |
MT_PATTERN, |
MT_RANDOM |
} type; |
103,13 → 104,24
int iprompt; /* Interactive prompt */ |
} sim; |
|
int inhibit_server; /* Don't start up the JTAG proxy server */ |
int server_port; /* A user specified port number for services */ |
|
struct { |
int enabled; /* Whether is debug module enabled */ |
int gdb_enabled; /* Whether is debugging with gdb possible */ |
int server_port; /* A user specified port number for services */ |
} debug; |
|
char *script_file; /* Script file that should be used */ |
char *filename; /* Original Command Simulator file (CZ) */ |
}; |
|
#ifdef DEBUGMOD_OFF |
#define DEBUG_ENABLED 0 |
#define GDB_ENABLED 0 |
#else |
#define DEBUG_ENABLED config.debug.enabled |
#define GDB_ENABLED config.debug.gdb_enabled |
#endif |
|
extern struct config config; |
|
/* Read environment from a script file. Does not fail - assumes defaukt configuration instead. */ |
/trunk/or1ksim/sim.cfg
21,8 → 21,8
memory_table_file = "simmem.cfg" |
/*random_seed = 12345 |
type = random*/ |
pattern = 0xee |
type = pattern |
pattern = 0x00 |
type = unknown /* Fastest */ |
end |
|
section cpu |
39,6 → 39,12
bpb = 0 |
end |
|
section debug |
/*enabled = 0 |
gdb_enabled = 0*/ |
server_port = 9999 |
end |
|
section sim |
debug = 0 |
prof_fn = "sim.profile" |
/trunk/or1ksim/debug/debug_unit.c
140,7 → 140,7
long data = (long)udata; |
int match; |
|
if(in_reset) |
if(DEBUG_ENABLED || in_reset) |
return 0; |
|
/* If we're single stepping, always stop */ |
/trunk/or1ksim/cpu/or32/execute.c
401,7 → 401,7
/* Added by CZ...catch alignment exception here */ |
if(pc_phy & 0x03) |
{ |
except_handle(EXCEPT_ALIGN,0); |
except_handle(EXCEPT_ALIGN, 0); |
return 0; /* We will fetch exception wrapper at new location. */ |
} |
|
410,7 → 410,6
pc_phy %= MEMORY_START + MEMORY_LEN; |
#endif |
|
#ifndef DEBUGMOD_OFF |
/* Fetch instruction. */ |
/* CZ 21/06/01: If there is an instruction waiting in the |
debug unit DIR, execute that first! Note the insn_addr |
419,7 → 418,7
{ |
unsigned int _insn; |
|
if(!OverrideFetch(&_insn)) |
if(!DEBUG_ENABLED && !OverrideFetch(&_insn)) |
{ |
_insn = eval_mem32 (pc_phy, &breakpoint); |
iqueue[0].insn_addr = pc; |
433,7 → 432,6
iqueue[0].insn_index = insn_decode(_insn); |
iqueue[0].insn = _insn; |
} |
#endif |
|
/* update_pc will be called after execution */ |
|
468,16 → 466,14
unsigned long t_pcnext = delay_insn ? pcdelay : pcnext+4; |
extern int cpu_stalled; /* CZ from debug_interface */ |
|
#ifndef DEBUGMOD_OFF |
/* If an insn was injected, don't increment the PC value, |
as it should not affect the existing instruction stream */ |
if(DIR_insn_injected) |
if(DEBUG_ENABLED && DIR_insn_injected) |
{ |
t_pc = pc; |
t_pcnext = delay_insn ? pcdelay : pcnext; |
} |
DIR_insn_injected = 0; |
#endif |
|
if(!cpu_stalled) |
_execute_update_pc(t_pc,t_pcnext); |
506,21 → 502,21
|
void dumpreg() |
{ |
int i; |
|
printf("IQ[0]:"); |
dumpmemory(iqueue[0].insn_addr, iqueue[0].insn_addr + 4, 1); |
printf(" (just executed)\tCYCLES: %u \nSuperscalar CYCLES: %u HAZARDWAIT: %u\n", cycles, supercycles, hazardwait); |
printf("Additional LOAD CYCLES: %u STORE CYCLES: %u\n", loadcycles, storecycles); |
printf("l.nop count: %u maxgap: %u\nPC:", nops, nop_maxperiod); |
dumpmemory(pc, pc + 4, 1); |
printf(" (next insn) %s", (delay_insn?"(delay insn)":"")); |
for(i = 0; i < MAX_GPRS; i++) { |
if (i % 4 == 0) |
printf("\n"); |
printf("GPR%.2u: %.8lx ", i, reg[i]); |
} |
printf("flag: %u\n", flag); |
int i; |
|
printf("IQ[0]:"); |
dumpmemory(iqueue[0].insn_addr, iqueue[0].insn_addr + 4, 1); |
printf(" (just executed)\tCYCLES: %u \nSuperscalar CYCLES: %u HAZARDWAIT: %u\n", cycles, supercycles, hazardwait); |
printf("Additional LOAD CYCLES: %u STORE CYCLES: %u\n", loadcycles, storecycles); |
printf("l.nop count: %u maxgap: %u\nPC:", nops, nop_maxperiod); |
dumpmemory(pc, pc + 4, 1); |
printf(" (next insn) %s", (delay_insn?"(delay insn)":"")); |
for(i = 0; i < MAX_GPRS; i++) { |
if (i % 4 == 0) |
printf("\n"); |
printf("GPR%.2u: %.8lx ", i, reg[i]); |
} |
printf("flag: %u\n", flag); |
} |
|
/* Address calculation changed by CZ on 27/05/01 */ |
532,11 → 528,9
/* MM: temporary exception disabling. */ |
if (temp_disable_except > 0) |
temp_disable_except--; |
|
#ifndef DEBUGMOD_OFF |
if(CheckDebugUnit(DebugInstructionFetch,pc_phy)) |
|
if(DEBUG_ENABLED && CheckDebugUnit(DebugInstructionFetch,pc_phy)) |
breakpoint++; |
#endif |
|
cur = current; |
cur->func_unit = unknown; |
/trunk/or1ksim/cpu/common/labels.c
0,0 → 1,134
/* abstract.c -- Abstract entities, handling labels |
Copyright (C) 2001 Marko Mlinar, markom@opencores.org |
|
This file is part of OpenRISC 1000 Architectural Simulator. |
|
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|
/* Abstract memory and routines that go with this. I need to |
add all sorts of other abstract entities. Currently we have |
only memory. */ |
|
#include <stdlib.h> |
#include <stdio.h> |
#include <ctype.h> |
#include <string.h> |
|
#include "config.h" |
#include "sim-config.h" |
|
#include "labels.h" |
|
static struct label_entry *label_hash[LABELS_HASH_SIZE]; |
static struct breakpoint_entry *breakpoints; |
|
void init_labels () { |
int i; |
for (i = 0; i < LABELS_HASH_SIZE; i++) |
label_hash[i] = NULL; |
} |
|
void add_label (unsigned long addr, char *name) { |
struct label_entry **tmp; |
tmp = &(label_hash[addr % LABELS_HASH_SIZE]); |
for (; *tmp; tmp = &((*tmp)->next)); |
*tmp = malloc(sizeof(**tmp)); |
(*tmp)->name = malloc(strlen(name) + 1); |
(*tmp)->addr = addr; |
strcpy((*tmp)->name, name); |
(*tmp)->next = NULL; |
} |
|
struct label_entry *get_label (unsigned long addr) { |
struct label_entry *tmp = label_hash[addr % LABELS_HASH_SIZE]; |
while (tmp) { |
if (tmp->addr == addr) |
return tmp; |
tmp = tmp->next; |
} |
return NULL; |
} |
|
struct label_entry *find_label (char *name) { |
int i; |
for (i = 0; i < LABELS_HASH_SIZE; i++) { |
struct label_entry *tmp = label_hash[i % LABELS_HASH_SIZE]; |
while (tmp) { |
if (strcmp (tmp->name, name) == 0) |
return tmp; |
tmp = tmp->next; |
} |
} |
return NULL; |
} |
|
/* Searches mem array for a particular label and returns label's address. |
If label does not exist, returns 0. */ |
unsigned long eval_label (char *name) { |
struct label_entry *le; |
char *plus; |
char *minus; |
int positive_offset = 0; |
int negative_offset = 0; |
|
if (plus = strchr(name, '+')) { |
*plus = '\0'; |
positive_offset = atoi(++plus); |
} |
|
if (minus = strchr(name, '-')) { |
*minus = '\0'; |
negative_offset = atoi(++minus); |
} |
le = find_label (name); |
if (!le) |
return 0; |
|
return le->addr + positive_offset - negative_offset; |
} |
|
void init_breakpoints () { |
breakpoints = 0; |
} |
|
void add_breakpoint (unsigned long addr) { |
struct breakpoint_entry *tmp; |
tmp = (struct breakpoint_entry *) malloc (sizeof (struct breakpoint_entry)); |
tmp->next = breakpoints; |
tmp->addr = addr; |
breakpoints = tmp; |
} |
|
void remove_breakpoint (unsigned long addr) { |
struct breakpoint_entry **tmp = &breakpoints; |
while (*tmp) { |
if ((*tmp)->addr == addr) { |
struct breakpoint_entry *t = *tmp; |
(*tmp) = t->next; |
free (t); |
} else |
tmp = &((*tmp)->next); |
} |
} |
|
inline int has_breakpoint (unsigned long addr) { |
struct breakpoint_entry *tmp = breakpoints; |
while (tmp) { |
if (tmp->addr == addr) |
return 1; |
tmp = tmp->next; |
} |
return 0; |
} |
trunk/or1ksim/cpu/common/labels.c
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/or1ksim/cpu/common/abstract.c
===================================================================
--- trunk/or1ksim/cpu/common/abstract.c (revision 268)
+++ trunk/or1ksim/cpu/common/abstract.c (revision 269)
@@ -63,7 +63,7 @@
int ilen = disasm ? 4 : 16;
for(i = from; i < to; i += ilen) {
- printf("%.8x", i);
+ printf("%.8x: ", i);
for (j = 0; j < ilen;) {
int data = -1;
if (!disasm) {
@@ -97,8 +97,9 @@
printf("");
} else printf("XXXXXXXX");
j += len;
- }
+ }
}
+ printf ("\n");
}
}
/trunk/or1ksim/cpu/common/labels.h
0,0 → 1,53
/* labels.h -- Abstract entities header file handling labels |
Copyright (C) 2001 Marko Mlinar, markom@opencores.org |
|
This file is part of OpenRISC 1000 Architectural Simulator. |
|
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|
#ifndef _LABELS_H_ |
#define _LABELS_H_ |
|
#define LABELS_HASH_SIZE 119 |
|
/* Structure for holding one label per particular memory location */ |
struct label_entry { |
char *name; |
unsigned long addr; |
struct label_entry *next; |
}; |
|
struct breakpoint_entry { |
unsigned long addr; |
struct breakpoint_entry *next; |
}; |
|
/* Label handling */ |
void init_labels(); |
void add_label (unsigned long addr, char *name); |
struct label_entry *get_label (unsigned long addr); |
struct label_entry *find_label (char *name); |
|
/* Searches mem array for a particular label and returns label's address. |
If label does not exist, returns 0. */ |
unsigned long eval_label (char *name); |
|
/* Breakpoint handling */ |
void breakpoints_init (); |
void add_breakpoint (unsigned long addr); |
void remove_breakpoint (unsigned long addr); |
inline int has_breakpoint (unsigned long addr); |
|
#endif /* _LABELS_H_ */ |
trunk/or1ksim/cpu/common/labels.h
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/or1ksim/toplevel.c
===================================================================
--- trunk/or1ksim/toplevel.c (revision 268)
+++ trunk/or1ksim/toplevel.c (revision 269)
@@ -79,7 +79,7 @@
void BlockJTAG(void);
/* CVS revision number. */
-const char rcsrev[] = "$Revision: 1.34 $";
+const char rcsrev[] = "$Revision: 1.35 $";
/* Continuos run versus single step tracing switch. */
int cont_run;
@@ -110,7 +110,6 @@
inline void debug(const char *format, ...)
{
-#ifndef DEBUGMOD_OFF
char *p;
va_list ap;
@@ -135,7 +134,6 @@
free(p);
#endif
}
-#endif /* no DEBUGMOD_OFF */
}
/* Strip whitespace from the start and end of STRING. Return a pointer
@@ -251,14 +249,22 @@
#ifdef HAVE_LIBREADLINE
initialize_readline (); /* Bind our completer. */
#endif
+
+ /* Read configuration file. */
+ read_script_file(config.script_file);
+ print_config();
+ init_labels();
+ init_breakpoints();
+ signal(SIGINT, ctrl_c);
+ initstats();
+ build_automata();
+
+ if(GDB_ENABLED) {
+ serverPort = config.debug.server_port;
+ if(server_fd = GetServerSocket("or1ksim","tcp",serverPort))
+ printf("JTAG Proxy server started on port %d\n",serverPort);
+ }
- if(!config.inhibit_server)
- {
- serverPort = config.server_port;
- if(server_fd = GetServerSocket("or1ksim","tcp",serverPort))
- printf("JTAG Proxy server started on port %d\n",serverPort);
- }
-
if(config.sim.profile) {
config.sim.fprof = fopen("sim.profile","wt+");
if(!config.sim.fprof) {
@@ -268,20 +274,11 @@
fprintf(config.sim.fprof, "+00000000 FFFFFFFF FFFFFFFF main\n");
}
- /* Read configuration file. */
- read_script_file(config.script_file);
- print_config();
- init_labels();
- init_breakpoints();
- signal(SIGINT, ctrl_c);
- initstats();
- build_automata();
-
/* Initialize memory */
{
extern struct dev_memarea *dev_list;
int i;
- if(config.memory.type == MT_RANDOM) {
+ if (config.memory.type == MT_RANDOM) {
unsigned int val = 0;
if (config.memory.random_seed == -1) {
@@ -300,7 +297,7 @@
for (cur_area = dev_list; cur_area; cur_area = cur_area->next)
for(i = 0; i < cur_area->size; i++)
setsim_mem8(i + cur_area->addr_compare, config.memory.pattern);
- } else {
+ } else if (config.memory.type != MT_UNKNOWN) {
fprintf(stderr, "Invalid memory configuration type.\n");
exit(1);
}
@@ -313,6 +310,10 @@
exit(1);
}
}
+
+ /* Disable gdb debugging, if debug module is not available. */
+ if (!config.debug.enabled)
+ config.debug.gdb_enabled = 0;
uart_reset();
dma_reset();
@@ -612,7 +613,7 @@
extern int cycle_delay; /* Added by CZ 27/05/01. Set during exception. */
extern int cpu_stalled; /* CZ from debug_interface */
- if(cpu_stalled)
+ if(GDB_ENABLED && cpu_stalled)
{
BlockJTAG();
HandleServerSocket(false);
@@ -681,12 +682,10 @@
dma_clock();
eth_clock();
-#ifndef DEBUGMOD_OFF
- if (debug_slowdown-- == 0) {
+ if (GDB_ENABLED && debug_slowdown-- == 0) {
debug_slowdown = DEBUG_SLOWDOWN;
HandleServerSocket(false); /* block & check_stdin = false */
}
-#endif
}
hush = 0;
fflush(stdout);
/trunk/or1ksim/sim-config.c
68,6 → 68,11
| SPR_UPR_IMP | SPR_UPR_OB32P | SPR_UPR_DUP | SPR_UPR_PICP |
| SPR_UPR_PMP | SPR_UPR_TTP; |
|
/* Debug */ |
config.debug.enabled = 0; |
config.debug.gdb_enabled = 0; |
config.debug.server_port = 0; |
|
/* Old */ |
config.dc.tagtype = NONE/*VIRTUAL*/; |
config.ic.tagtype = NONE/*VIRTUAL*/; |
97,7 → 102,7
argv++; argc--; |
} else |
if (strcmp(*argv, "--nosrv") == 0) { /* (CZ) */ |
config.inhibit_server = 1; |
config.debug.gdb_enabled = 0; |
argv++; argc--; |
} else |
if (strcmp(*argv, "--srv") == 0) { /* (CZ) */ |
104,7 → 109,9
char *s; |
if(!--argc) |
return 1; |
config.server_port = strtol(*(++argv),&s,10); |
config.debug.enabled = 1; |
config.debug.gdb_enabled = 0; |
config.debug.server_port = strtol(*(++argv),&s,10); |
if(*s) |
return 1; |
argv++; argc--; |
175,9 → 182,6
|
char memory_file[256] = "sim.mem"; |
|
#define SF_SUBSECTIONS 1 |
#define SF_REQUIRED 2 |
|
struct section { |
char *name; |
int flags; |
188,7 → 192,8
{"dma", 0}, |
{"memory", 0}, |
{"cpu", 0}, |
{"sim", 0} |
{"sim", 0}, |
{"debug", 0} |
}; |
|
unsigned long tempL; |
246,7 → 251,11
{6, "debug", "= %i", NULL, (void *)(&config.sim.debug)}, |
{6, "prof_fn", "= \"%255s\"", NULL, (void *)(&config.sim.prof_fn[0])}, |
{6, "profile", "= %i", NULL, (void *)(&config.sim.profile)}, |
{6, "iprompt", "= %i", NULL, (void *)(&config.sim.iprompt)} |
{6, "iprompt", "= %i", NULL, (void *)(&config.sim.iprompt)}, |
|
{7, "enabled", "= %i", NULL, (void *)(&config.debug.enabled)}, |
{7, "gdb_enabled", "= %i", NULL, (void *)(&config.debug.gdb_enabled)}, |
{7, "server_port", "= %i", NULL, (void *)(&config.debug.server_port)} |
}; |
|
int current_device = -1; |
313,7 → 322,9
} |
|
void memory_type () { |
if (strcmp (tempS, "random") == 0) |
if (strcmp (tempS, "unknown") == 0) |
config.memory.type = MT_UNKNOWN; |
else if (strcmp (tempS, "random") == 0) |
config.memory.type = MT_RANDOM; |
else if (strcmp (tempS, "pattern") == 0) |
config.memory.type = MT_PATTERN; |
321,7 → 332,7
config.memory.type = MT_PATTERN; |
config.memory.pattern = 0; |
} else { |
fprintf (stderr, "ERROR: invalid memory type."); |
fprintf (stderr, "ERROR: invalid memory type '%s'.\n", tempS); |
exit (-1); |
} |
} |