URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/trunk/orpsocv2/bench/sysc/src
- from Rev 64 to Rev 66
- ↔ Reverse comparison
Rev 64 → Rev 66
/MemoryLoad.cpp
272,32 → 272,10
int *breakpoint) |
{ |
|
// Memory is word addressed, not byte, so /4 the address we get |
int vaddr = (int) address/4; /*(!runtime.sim.filename) ? translate (address, breakpoint) : |
translate (freemem, breakpoint); |
-- jb |
*/ |
/* We can't have set_program32 functions since it is not gauranteed that the |
section we're loading is aligned on a 4-byte boundry */ |
/* |
set_program8 (vaddr, (insn >> 24) & 0xff); |
set_program8 (vaddr + 1, (insn >> 16) & 0xff); |
set_program8 (vaddr + 2, (insn >> 8) & 0xff); |
set_program8 (vaddr + 3, insn & 0xff); |
*/ |
int vaddr = (int) address; |
/* Use the whole-word write */ |
accessor->set_mem(vaddr, insn); |
PRINTF("* addprogram: addr 0x%.8x insn: 0x%.8x (conf: 0x%.8x)\n", vaddr, insn, accessor->get_mem(vaddr)); |
|
|
#if IMM_STATS |
check_insn (insn); |
#endif |
|
//if (runtime.sim.filename) |
//{ |
//freemem += insn_len (insn_decode (insn)); |
//} |
accessor->set_mem32(vaddr, insn); |
PRINTF("* addprogram: addr 0x%.8x insn: 0x%.8x (conf: 0x%.8x)\n", vaddr, insn, accessor->get_mem32(vaddr)); |
freemem += 4; |
|
} /* addprogram () */ |
/GdbServerSC.cpp
256,6 → 256,7
rsp->rspClose (); // Comms failure |
return; |
} |
//Uncomment the next line for the RSP client to print out every packet it gets from GDB |
//cerr << "rspClientRequest: " << pkt->data/*[0]*/ << endl; |
switch (pkt->data[0]) |
{ |
/Or1200MonitorSC.cpp
443,7 → 443,8
case NOP_PRINTF: |
ts = sc_time_stamp().to_seconds() * 1000000000.0; |
std::cout << std::fixed << std::setprecision (2) << ts; |
std::cout << " ns: printf" << std::endl; |
std::cout << " ns: printf: "; |
simPrintf(accessor->getGpr (4), accessor->getGpr (3)); |
break; |
|
case NOP_PUTC: |
815,24 → 816,15
// If we could open the file then turn on logging |
cout << "* Dumping system RAM from 0x" << hex << memdump_start_addr << "-0x" << hex << memdump_end_addr << " to file " << memdumpFileName << endl; |
|
// Convert memdump_start_addr to word address |
memdump_start_addr = memdump_start_addr / 4; |
while (size_words) |
{ |
// Read the data from the simulation memory |
current_word = accessor->get_mem(memdump_start_addr); |
//cout << hex << current_word << " "; |
/* |
cout << hex << ((current_word >> 24 ) & 0xff) << " "; |
cout << hex << ((current_word >> 16) & 0xff) << " "; |
cout << hex << ((current_word >> 8 ) & 0xff) << " " ; |
cout << hex << ((current_word >> 0 ) & 0xff) << " "; |
*/ |
current_word = accessor->get_mem32(memdump_start_addr); |
// Change from whatever endian the host is (most |
// cases little) to big endian |
current_word = htonl(current_word); |
memdumpFile.write((char*) ¤t_word, 4); |
memdump_start_addr++; size_words--; |
memdump_start_addr+=4; size_words--; |
} |
|
// Ideally we've now finished piping out the data |
917,3 → 909,134
return; |
|
} // busMonitor () |
|
void |
Or1200MonitorSC::simPrintf(uint32_t stackaddr, uint32_t regparam) |
{ |
|
//cerr << hex << stackaddr << " " << regparam << endl; |
#define FMTLEN 2000 |
char fmtstr[FMTLEN]; |
uint32_t arg; |
oraddr_t argaddr; |
char *fmtstrend; |
char *fmtstrpart = fmtstr; |
int tee_exe_log; |
|
/*simgetstr (stackaddr, regparam);*/ |
/* Get the format string*/ |
uint32_t fmtaddr; |
int i; |
fmtaddr = regparam; |
|
i = 0; |
while (accessor->get_mem8(fmtaddr) != '\0') |
{ |
fmtstr[i++] = accessor->get_mem8(fmtaddr); |
fmtaddr++; |
if (i == FMTLEN - 1) |
break; |
} |
fmtstr[i] = '\0'; |
|
|
argaddr = stackaddr; |
int index, last_index; |
index = last_index = 0; |
char tmp_char; |
while (1) |
{ |
/* Look for the next format argument, or end of string */ |
while (!(fmtstrpart[index] == '\0' || fmtstrpart[index] == '%')) |
index++; |
|
if (fmtstrpart[index] == '\0' && index == last_index) |
/* We had something like "%d\0", so we're done*/ |
return; |
|
if (fmtstrpart[index] == '\0') |
{ |
/* Final printf */ |
printf("%s", (char*) fmtstrpart + last_index); |
return; |
} |
else |
{ |
/* We have a section between last_index and index that we should print out*/ |
fmtstrpart[index] = '\0'; /* Replace % with \0 for now */ |
printf ("%s",fmtstrpart + last_index); |
fmtstrpart[index] = '%'; /* Replace the % */ |
} |
|
last_index = index; /* last_index now pointing at the % */ |
|
/* Now extract the part that requires formatting */ |
/* Look for the end of the format argument*/ |
while (!(fmtstrpart[index] == 'd' || fmtstrpart[index] == 'i' |
|| fmtstrpart[index] == 'o' || fmtstrpart[index] == 'u' |
|| fmtstrpart[index] == 'x' || fmtstrpart[index] == 'X' |
|| fmtstrpart[index] == 'f' || fmtstrpart[index] == 'e' |
|| fmtstrpart[index] == 'E' || fmtstrpart[index] == 'g' |
|| fmtstrpart[index] == 'G' || fmtstrpart[index] == 'c' |
|| fmtstrpart[index] == 's' || fmtstrpart[index] == '\0' |
|| fmtstrpart[index+1] == '%')) |
index++; |
|
if (fmtstrpart[index] == '\0') |
{ |
// Error |
return; |
} |
else if (fmtstrpart[index] == '%' && fmtstrpart[index+1] == '%') |
{ |
/* Deal with the %% case to print a single % */ |
index++; |
printf("%%"); |
} |
else |
{ |
/* We now will print the part that requires the next argument */ |
/* Same trick, but this time remember what the char was */ |
tmp_char = fmtstrpart[index+1]; |
fmtstrpart[index+1] = '\0'; /* Replace % with \0 for now */ |
/* Check what we're printing*/ |
if (fmtstrpart[index] == 's') |
{ |
/* It's a string, so pull it out of memory into a local char* |
and pass it to printf() */ |
int tmp_string_len, z; |
/* Assume stackaddr already pointing at appropriate value*/ |
oraddr_t ormem_str_ptr = accessor->get_mem32(argaddr); |
|
while (accessor->get_mem8(ormem_str_ptr++) != '\0') |
tmp_string_len++; |
tmp_string_len++; /* One for terminating char */ |
|
char* str = (char *) malloc (tmp_string_len); |
if (str == NULL) return; /* Malloc failed, bigger issues than printf'ing out of sim */ |
ormem_str_ptr = accessor->get_mem32(argaddr); /* Reset start pointer value*/ |
for (z=0;z<tmp_string_len;z++) |
str[z] = accessor->get_mem8(ormem_str_ptr+z); |
|
printf (fmtstrpart + last_index, str); |
free (str); |
} |
else |
{ |
/* |
Some other kind of variable, pull it off the stack and print |
it out. Assume stackaddr already pointing at appropriate |
value |
*/ |
arg = accessor->get_mem32(argaddr); |
printf (fmtstrpart + last_index, arg); |
} |
argaddr+= 4; /* Increment argument pointer in stack */ |
fmtstrpart[index+1] = tmp_char; /* Replace the char we took out */ |
} |
index++; |
last_index = index; |
} |
|
return; |
} // simPrintf () |
/OrpsocAccess.cpp
191,23 → 191,69
|
//! Access the Wishbone SRAM memory |
|
//! @return The value of the memory word at addr |
//! @return The value of the 32-bit memory word at addr |
|
uint32_t |
OrpsocAccess::get_mem (uint32_t addr) |
OrpsocAccess::get_mem32 (uint32_t addr) |
{ |
return (ram_wb_sc_sw->get_mem) (addr); |
return (ram_wb_sc_sw->get_mem) (addr/4); |
|
} // get_mem () |
} // get_mem32 () |
|
|
//! Access a byte from the Wishbone SRAM memory |
|
//! @return The value of the memory byte at addr |
|
uint8_t |
OrpsocAccess::get_mem8 (uint32_t addr) |
{ |
|
uint32_t word; |
static uint32_t cached_word; |
static uint32_t cached_word_addr = 0xffffffff; |
int sel = addr & 0x3; // Remember which byte we want |
addr = addr / 4; |
if (addr != cached_word_addr) |
{ |
cached_word_addr = addr; |
// Convert address to word number here |
word = (ram_wb_sc_sw->get_mem) (addr); |
cached_word = word; |
} |
else |
word = cached_word; |
|
switch(sel) |
{ |
/* Big endian word expected */ |
case 0: |
return ((word >> 24) & 0xff); |
break; |
case 1: |
return ((word >> 16) & 0xff); |
break; |
case 2: |
return ((word >> 8) & 0xff); |
break; |
case 3: |
return ((word >> 0) & 0xff); |
break; |
default: |
return 0; |
} |
|
} // get_mem8 () |
|
|
//! Write value to the Wishbone SRAM memory |
|
void |
OrpsocAccess::set_mem (uint32_t addr, uint32_t data) |
OrpsocAccess::set_mem32 (uint32_t addr, uint32_t data) |
{ |
(ram_wb_sc_sw->set_mem) (addr, data); |
(ram_wb_sc_sw->set_mem) (addr/4, data); |
|
} // set_mem () |
} // set_mem32 () |
|
//! Trigger the $readmemh() system call |
|