Line 59... |
Line 59... |
int data_ci, insn_ci;
|
int data_ci, insn_ci;
|
|
|
/* Virtual address of current access. */
|
/* Virtual address of current access. */
|
unsigned long cur_vadd;
|
unsigned long cur_vadd;
|
|
|
/* Temporary variable, which specifies how many cycles did the memory acces require */
|
|
extern int mem_cycles;
|
|
|
|
/* Calculates bit mask to fit the data */
|
/* Calculates bit mask to fit the data */
|
unsigned long bit_mask (unsigned long data) {
|
unsigned long bit_mask (unsigned long data) {
|
int i = 0;
|
int i = 0;
|
data--;
|
data--;
|
while (data >> i)
|
while (data >> i)
|
Line 173... |
Line 170... |
|
|
if (verify_memoryarea(memaddr)) {
|
if (verify_memoryarea(memaddr)) {
|
switch(cur_area->granularity) {
|
switch(cur_area->granularity) {
|
case 4:
|
case 4:
|
temp = cur_area->readfunc(memaddr);
|
temp = cur_area->readfunc(memaddr);
|
mem_cycles += cur_area->delayr;
|
runtime.sim.mem_cycles += cur_area->delayr;
|
break;
|
break;
|
case 1:
|
case 1:
|
temp = cur_area->readfunc(memaddr) << 24;
|
temp = cur_area->readfunc(memaddr) << 24;
|
temp |= cur_area->readfunc(memaddr + 1) << 16;
|
temp |= cur_area->readfunc(memaddr + 1) << 16;
|
temp |= cur_area->readfunc(memaddr + 2) << 8;
|
temp |= cur_area->readfunc(memaddr + 2) << 8;
|
temp |= cur_area->readfunc(memaddr + 3);
|
temp |= cur_area->readfunc(memaddr + 3);
|
mem_cycles += cur_area->delayr * 4;
|
runtime.sim.mem_cycles += cur_area->delayr * 4;
|
break;
|
break;
|
case 2:
|
case 2:
|
temp = cur_area->readfunc(memaddr) << 16;
|
temp = cur_area->readfunc(memaddr) << 16;
|
temp |= cur_area->readfunc(memaddr + 2);
|
temp |= cur_area->readfunc(memaddr + 2);
|
mem_cycles += cur_area->delayr * 2;
|
runtime.sim.mem_cycles += cur_area->delayr * 2;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
return temp;
|
return temp;
|
}
|
}
|
Line 201... |
Line 198... |
if (verify_memoryarea(memaddr)) {
|
if (verify_memoryarea(memaddr)) {
|
switch(cur_area->granularity) {
|
switch(cur_area->granularity) {
|
case 1:
|
case 1:
|
temp = cur_area->readfunc(memaddr) << 8;
|
temp = cur_area->readfunc(memaddr) << 8;
|
temp |= cur_area->readfunc(memaddr + 1);
|
temp |= cur_area->readfunc(memaddr + 1);
|
mem_cycles += cur_area->delayr * 2;
|
runtime.sim.mem_cycles += cur_area->delayr * 2;
|
break;
|
break;
|
case 2:
|
case 2:
|
temp = cur_area->readfunc(memaddr);
|
temp = cur_area->readfunc(memaddr);
|
mem_cycles += cur_area->delayr;
|
runtime.sim.mem_cycles += cur_area->delayr;
|
break;
|
break;
|
case 4:
|
case 4:
|
temp = evalsim_mem32 (memaddr & ~3ul);
|
temp = evalsim_mem32 (memaddr & ~3ul);
|
if (memaddr & 2)
|
if (memaddr & 2)
|
temp &= 0xffff;
|
temp &= 0xffff;
|
Line 227... |
Line 224... |
|
|
if (verify_memoryarea(memaddr)) {
|
if (verify_memoryarea(memaddr)) {
|
switch(cur_area->granularity) {
|
switch(cur_area->granularity) {
|
case 1:
|
case 1:
|
temp = cur_area->readfunc(memaddr);
|
temp = cur_area->readfunc(memaddr);
|
mem_cycles += cur_area->delayr;
|
runtime.sim.mem_cycles += cur_area->delayr;
|
break;
|
break;
|
case 2:
|
case 2:
|
temp = evalsim_mem16 (memaddr & ~1ul);
|
temp = evalsim_mem16 (memaddr & ~1ul);
|
if (memaddr & 1)
|
if (memaddr & 1)
|
temp &= 0xff;
|
temp &= 0xff;
|
Line 413... |
Line 410... |
|
|
if (verify_memoryarea(memaddr)) {
|
if (verify_memoryarea(memaddr)) {
|
switch(cur_area->granularity) {
|
switch(cur_area->granularity) {
|
case 4:
|
case 4:
|
cur_area->writefunc(memaddr, value);
|
cur_area->writefunc(memaddr, value);
|
mem_cycles += cur_area->delayw;
|
runtime.sim.mem_cycles += cur_area->delayw;
|
break;
|
break;
|
case 1:
|
case 1:
|
cur_area->writefunc(memaddr , (value >> 24) & 0xFF);
|
cur_area->writefunc(memaddr , (value >> 24) & 0xFF);
|
cur_area->writefunc(memaddr + 1, (value >> 16) & 0xFF);
|
cur_area->writefunc(memaddr + 1, (value >> 16) & 0xFF);
|
cur_area->writefunc(memaddr + 2, (value >> 8) & 0xFF);
|
cur_area->writefunc(memaddr + 2, (value >> 8) & 0xFF);
|
cur_area->writefunc(memaddr + 3, (value ) & 0xFF);
|
cur_area->writefunc(memaddr + 3, (value ) & 0xFF);
|
mem_cycles += cur_area->delayw * 4;
|
runtime.sim.mem_cycles += cur_area->delayw * 4;
|
break;
|
break;
|
case 2:
|
case 2:
|
cur_area->writefunc(memaddr, (value >> 16) & 0xFFFF);
|
cur_area->writefunc(memaddr, (value >> 16) & 0xFFFF);
|
cur_area->writefunc(memaddr + 2, value & 0xFFFF);
|
cur_area->writefunc(memaddr + 2, value & 0xFFFF);
|
mem_cycles += cur_area->delayw * 2;
|
runtime.sim.mem_cycles += cur_area->delayw * 2;
|
break;
|
break;
|
}
|
}
|
} else {
|
} else {
|
printf("EXCEPTION: write out of memory (32-bit access to %.8lx)\n", memaddr);
|
printf("EXCEPTION: write out of memory (32-bit access to %.8lx)\n", memaddr);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
except_handle(EXCEPT_BUSERR, cur_vadd);
|
Line 442... |
Line 439... |
if (verify_memoryarea(memaddr)) {
|
if (verify_memoryarea(memaddr)) {
|
switch(cur_area->granularity) {
|
switch(cur_area->granularity) {
|
case 1:
|
case 1:
|
cur_area->writefunc(memaddr, (value >> 8) & 0xFF);
|
cur_area->writefunc(memaddr, (value >> 8) & 0xFF);
|
cur_area->writefunc(memaddr + 1, value & 0xFF);
|
cur_area->writefunc(memaddr + 1, value & 0xFF);
|
mem_cycles += cur_area->delayw * 2;
|
runtime.sim.mem_cycles += cur_area->delayw * 2;
|
break;
|
break;
|
case 2:
|
case 2:
|
cur_area->writefunc(memaddr, value & 0xFFFF);
|
cur_area->writefunc(memaddr, value & 0xFFFF);
|
mem_cycles += cur_area->delayw;
|
runtime.sim.mem_cycles += cur_area->delayw;
|
break;
|
break;
|
case 4:
|
case 4:
|
temp = evalsim_mem32 (memaddr & ~3ul);
|
temp = evalsim_mem32 (memaddr & ~3ul);
|
temp &= 0xffff << ((memaddr & 2) ? 16 : 0);
|
temp &= 0xffff << ((memaddr & 2) ? 16 : 0);
|
temp |= (unsigned long)(value & 0xffff) << ((memaddr & 2) ? 0 : 16);
|
temp |= (unsigned long)(value & 0xffff) << ((memaddr & 2) ? 0 : 16);
|
Line 468... |
Line 465... |
unsigned long temp;
|
unsigned long temp;
|
if (verify_memoryarea(memaddr)) {
|
if (verify_memoryarea(memaddr)) {
|
switch (cur_area->granularity) {
|
switch (cur_area->granularity) {
|
case 1:
|
case 1:
|
cur_area->writefunc(memaddr, value);
|
cur_area->writefunc(memaddr, value);
|
mem_cycles += cur_area->delayw;
|
runtime.sim.mem_cycles += cur_area->delayw;
|
break;
|
break;
|
case 2:
|
case 2:
|
temp = evalsim_mem16 (memaddr & ~1ul);
|
temp = evalsim_mem16 (memaddr & ~1ul);
|
temp &= 0xff << ((memaddr & 1) ? 8 : 0);
|
temp &= 0xff << ((memaddr & 1) ? 8 : 0);
|
temp |= (unsigned short)(value & 0xff) << ((memaddr & 1) ? 0 : 8);
|
temp |= (unsigned short)(value & 0xff) << ((memaddr & 1) ? 0 : 8);
|